summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/mindflow/mindflow.sty
blob: 13f8f51f2eec9f70e59d30454c3fab9139504318 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
%%
%% This is file `mindflow.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% mindflow.dtx  (with options: `package')
%% 
%% Copyright (C) 2021 by Jinwen XU
%% 
%% This file may be distributed and/or modified under the conditions of
%% the LaTeX Project Public License, either version 1.3c of this license
%% or (at your option) any later version.  The latest version of this
%% license is in:
%% 
%%    http://www.latex-project.org/lppl.txt
%% 
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{mindflow}
    [2021/03/12 Mindflow environment]


\RequirePackage{kvoptions}
\SetupKeyvalOptions{%
    family = @mindflow,
    prefix = @mindflow@
}
\DeclareBoolOption[false]{off}           % Turn off mindflow
\DeclareBoolOption[false]{leftmarker}    % Left marker
\DeclareBoolOption[false]{rightmarker}   % Right marker
\DeclareBoolOption[false]{linenumber}    % Line numbers
\DeclareBoolOption[false]{twocolumn}     % Two column
\DeclareBoolOption[false]{incolumn}      % Separation line fits in the column

\ProcessKeyvalOptions*\relax

\if@mindflow@twocolumn
  \@mindflow@incolumntrue
\fi

%%================================
%% Initialization
%%================================
\RequirePackage{lineno}
\RequirePackage{xcolor}

\colorlet{mfSavedColor}{.}
\colorlet{mindflowText}{mfSavedColor!30}
\colorlet{mindflowNum}{mfSavedColor!8}

\newcommand{\mindflowTextFont}{\normalfont\footnotesize}
\newcommand{\mindflowNumFont}{\normalfont\scriptsize\ttfamily}
\newcommand{\mindflowLeft}{*}
\newcommand{\mindflowRight}{*}
\newlength{\mindflowLineHeight}
\setlength{\mindflowLineHeight}{0.4pt}

%%================================
%% The mindflow environment
%%================================
\newif\ifLNturnsON

\newcommand*{\mfSepLine}{%
  \parskip=0pt
  \LNturnsONfalse%
  \ifLineNumbers\LNturnsONtrue\fi\nolinenumbers%
  \par\noindent\nopagebreak%
  \if@mindflow@incolumn%
    \makebox[\linewidth]{\rule{\linewidth}{\mindflowLineHeight}}%
  \else%
    \hspace*{-\paperwidth}\makebox[\linewidth]{\rule{4\paperwidth}{\mindflowLineHeight}}%
  \fi%
  \nopagebreak\par%
  \ifLNturnsON\linenumbers\fi%
}

\newcounter{recordLN}
\newcounter{mfLN}
\setcounter{mfLN}{1}

\if@mindflow@off
  \RequirePackage{verbatim}
  \let\mindflow=\comment
  \let\endmindflow=\endcomment
\else
  \newenvironment{mindflow}
  {%
    \setcounter{recordLN}{\value{linenumber}}%
    \setcounter{linenumber}{\value{mfLN}}%
    \LNturnsONfalse%
    \ifLineNumbers\LNturnsONtrue\fi\nolinenumbers%
    \mindflowTextFont\color{mindflowText}%
    \mfSepLine%
    \linenumbers%
    \renewcommand\makeLineNumber{%
      \hss\color{mindflowNum}%
      \if@mindflow@linenumber%
        \mindflowNumFont\LineNumber~%
      \fi%
      \if@mindflow@leftmarker%
        \mindflowLeft\hspace{1em}%
      \fi%
      \if@mindflow@rightmarker%
        \rlap{\hskip\textwidth\hspace{1em}\mindflowRight}%
      \fi%
    }%
  }
  {%
    \par%
    \vspace{-.5\baselineskip}\mfSepLine%
    \ifLNturnsON\linenumbers\fi%
    \setcounter{mfLN}{\value{linenumber}}%
    \setcounter{linenumber}{\value{recordLN}}%
  }
\fi
\endinput
%%
%% End of file `mindflow.sty'.