summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/mindflow/mindflow.dtx
blob: 221a7e3c789291d8ef418209dd04dbdd1a4e7629 (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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
% \iffalse meta-comment
%
% Copyright (C) 2021-2022 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
%
% \fi
%
% \iffalse
%<*driver>
\ProvidesFile{mindflow.dtx}
%</driver>
%<package>\NeedsTeXFormat{LaTeX2e}
%<package>\ProvidesPackage{mindflow}
%<*package>
    [2022/01/31 The mindflow environment]
%</package>
%
%<*driver>
\documentclass{article}
\usepackage{doc}
\usepackage[a4paper,top=1.2in,bottom=1.2in,left=1.6in,right=1.2in]{geometry}
\usepackage{titlesec}
\titleformat{\section}{\large\scshape\centering}{\textcolor{black!55}{$\thesection$}}{.5em}{}
\titleformat{\subsection}{\normalsize\scshape}{\textcolor{black!55}{$\thesubsection$}}{.5em}{}
\titlespacing{\section}{0pt}{.75pc}{.5pc}
\titlespacing{\subsection}{0pt}{.75pc}{.5pc}
\usepackage{titling}
\setlength{\droptitle}{-.75in}
\usepackage{enumitem}
\setlist{noitemsep}
\setlist[itemize,1]{label=\textcolor{black!55}{$\bullet$}}
\usepackage{newpxtext}
\useosf
\usepackage{amssymb}
\usepackage[euler-digits]{eulervm}
% \usepackage{ebgaramond,ebgaramond-maths}
\usepackage[symbol]{footmisc}
\usepackage{microtype}
\usepackage[mathlines,linenumber,rightmarker]{mindflow}
\usepackage{parskip}
\usepackage{listings}
\definecolor{maintheme}{RGB}{50,100,150}
\definecolor{forestgreen}{RGB}{21,122,81}
\definecolor{lightergray}{gray}{0.99}
\lstset{language=[LaTeX]TeX,
    keywordstyle=\color{maintheme},
    basicstyle=\ttfamily,
    commentstyle=\color{forestgreen}\ttfamily,
    stringstyle=\rmfamily,
    showstringspaces=false,
    breaklines=true,
    frame=lines,
    backgroundcolor=\color{lightergray},
    flexiblecolumns=true,
    escapeinside={(*}{*)},
    % numbers=left,
    % numberstyle=\scriptsize, stepnumber=1, numbersep=5pt,
    % firstnumber=last,
} 
\providecommand{\meta}[1]{$\langle${\normalfont\itshape#1}$\rangle$}
\lstset{moretexcs=%
    {linenumbers,nolinenumbers,mindflowLeft,mindflowRight,mindflowTextFont,mindflowNumFont,mindflowMarkerFont,mindflowLineHeight,setlength,colorlet,color,
    RequirePackage,SetupKeyvalOptions,DeclareBoolOption,ProcessKeyvalOptions,PassOptionsToPackage,
    PackageWarning,MessageBreak,
    @mindflow@incolumntrue,if@mindflow@linenumber,@mindflow@leftlinenumbertrue,if@mindflow@on,if@mindflow@off,@mindflow@offfalse,if@mindflow@incolumn,if@mindflow@leftlinenumber,if@mindflow@rightlinenumber,if@mindflow@leftmarker,if@mindflow@rightmarker,if@mindflow@nonbreakable,if@mindflow@mathlines,
    mindflow@parindent,mindflow@parskip,
    ifLNturnsON,LNturnsONtrue,LNturnsONfalse,ifLineNumbers,
    mindflowset,
    mindflow,endmindflow,comment,endcomment,
    mindflowON,endmindflowON,mindflowOFF,endmindflowOFF,
    mfSepLine,makeLineNumber,LineNumber,
    mindflow@makeLineNumber,LocallyStopLineNumbers,ResumeLineNumbers,
    if@twocolumn,
    ifICturnsON,ICturnsONtrue,ICturnsONfalse,AutoIncolumn,ResumeIncolumn,
    newtcolorbox,
    ifdefined,linenomathpatch,cspreto,csappto,patchcmd,linenomathpatchAMS,linenomathAMS,linenomathWithnumbers,linenomath,endlinenomath,linenomathNonumbers,linenopenalty,
    define@key,setkeys,
    nowidow,
    }
}
\lstnewenvironment{code*}% 
{\setkeys{lst}{columns=fullflexible,keepspaces=true}}{}
\lstnewenvironment{code}% 
{\setkeys{lst}{columns=fullflexible,keepspaces=true,numbers=left,numberstyle=\scriptsize, stepnumber=1, numbersep=5pt,lastline=236}}{}
\EnableCrossrefs
\CodelineIndex
\RecordChanges
\begin{document}
  \DocInput{mindflow.dtx}
\end{document}
%</driver>
% \fi
%
% \CheckSum{0}
%
% \GetFileInfo{mindflow.dtx}
%
%
% \title{{\huge\scshape\textsf{mindflow}}\\[.15\baselineskip]\itshape\large write your ideas in a clear way\smallskip}
% \author{\scshape Jinwen XU}
% \footnotetext{\hspace*{-1em}Corresponding to: \textsf{mindflow} \ttfamily\filedate}
% \date{\normalsize January 2022, in Paris}
%
% \maketitle
%
% \section{Introduction}
%
% The \textsf{mindflow} package provides you a way to write your ideas 
% and annotations clearly. For example, with the options \verb|linenumber|
% and \verb|rightmarker|, you will get something like this:
% \begin{mindflow}
%     What to write next:
%     \begin{itemize}
%         \item usage: the initialization, options and configuration;
%         \item an example maybe;
%         \item some word on the line numbering feature;
%         \item some internal macros and the complete code.
%     \end{itemize}
% \end{mindflow}
% This example only shows the default effect. You can customize it further according to the instructions in the next section.
%
% \section{The usage}
%
% \subsection{How to load it\,?}
% Simply load the package with
% \iffalse
%<*example>
% \fi
\begin{code*}
\usepackage{mindflow}
\end{code*}
% \iffalse
%</example>
% \fi
%
% By default, there are no decorations like line numbers or markers. To enable 
% them, you can use the following options (they can be specified directly, like 
% \verb|off|, or as a boolean optional, like \verb|off=false|):
%
% \begin{center}
% \begin{tabular}{ll}
%     \verb|linenumber|\hspace{5em} & Enable line numbering feature, same as \verb|leftlinenumber|\\
%     \verb|mathlines| & Enable line numbers for displayed equations\\
%     \verb|leftlinenumber| & Enable left line numbers\\
%     \verb|rightlinenumber| & Enable right line numbers\\
%     \verb|leftmarker| & Enable left marker, by default it is an asterisk ``\verb|*|''\\
%     \verb|rightmarker| & Enable right marker, by default it is an asterisk ``\verb|*|''\\
%     \verb|incolumn| & The separation line would fit in the column \\&(\emph{automatically applied in two-column documents})\\
%     \verb|off|, \verb|on| & Turn the \verb|mindflow| environments \emph{off} or \emph{on}
% \end{tabular}
% \end{center}
%
% There is also an option \verb|nonbreakable|, which enables the \textsf{tcolorbox} version, permitting a background color, but is not breakable and does not support line numbering quite well.
%
% \subsection{How to use it\,?}
% \DescribeEnv{\{mindflow\}}
% You can then use the \verb|mindflow| environment as
% \iffalse
%<*example>
% \fi
\begin{code*}
\begin{mindflow}
    (*{\normalfont\meta{text}}*)
\end{mindflow}
\end{code*}
% \iffalse
%</example>
% \fi
%
% \subsection{Further configurations}
%
% \DescribeMacro{\mindflowset}
% You can use \lstinline|\mindflowset{|\meta{configuration}\lstinline|}| to
% further configure the \texttt{mindflow} environment. The available keys are
% listed at the top of the next page.
% \clearpage
%
% \begin{center}
% \begin{tabular}{ll|ll}
%	  \hline
%     \verb|left| & The left marker & \verb|right| & The right marker\\
%     \verb|textcolor| & Color of the text & \verb|textfont| & Font of the text\\
%     \verb|numcolor| & Color of line numbers & \verb|numfont| & Font of line numbers\\
%     \verb|markercolor| & Color of the markers & \verb|markerfont| & Font of the marker\\
%     \verb|linecolor| & Color of the separation line & \verb|lineheight| & Height of the separation line\\
%	  \hline
% \end{tabular}
% \end{center}
%
% Additionally, most of the options mentioned in the previous section (except for \verb|nonbreakable| and \verb|mathlines|) can be set with \lstinline|\mindflowset|.%
% \footnote{If the package option \texttt{nonbreakable} is enabled, then there is also a key \texttt{backgroundcolor}, similar to \texttt{textcolor}, for configuring the background color of the \texttt{mindflow} environments.}
%
% \section{An example}
% With the following settings:
% \iffalse
%<*example>
% \fi
\begin{code*}
\mindflowset{
    leftlinenumber, rightlinenumber, leftmarker, rightmarker,
    linecolor   = green!50!black,
    textcolor   = blue!50!cyan,
    numcolor    = red!50!orange,
    markercolor = orange,
    textfont    = \footnotesize\sffamily\itshape,
    numfont     = \small\footnotesize\ttfamily,
    markerfont  = \footnotesize\sffamily,
    left        = \hspace{1em}\(\succ\),
    right       = \(\prec\)\hspace{1em},
    lineheight  = 1pt
}
\end{code*}
% \iffalse
%</example>
% \fi
% \vspace{-.5\baselineskip}
% One will get something like this (a little bit exaggerated, to be honest):
% \begingroup
% \makeatletter
% \@mindflow@leftmarkertrue
% \@mindflow@rightlinenumbertrue
% \makeatother
% \colorlet{mindflowLine}{green!50!black}
% \colorlet{mindflowText}{blue!50!cyan}
% \colorlet{mindflowNum}{red!50!orange}
% \colorlet{mindflowMarker}{orange}
% \renewcommand{\mindflowTextFont}{\footnotesize\sffamily\itshape}
% \renewcommand{\mindflowNumFont}{\small\footnotesize\ttfamily}
% \renewcommand{\mindflowMarkerFont}{\footnotesize\sffamily}
% \renewcommand{\mindflowLeft}{\hspace{1em}\(\succ\)}
% \renewcommand{\mindflowRight}{\(\prec\)\hspace{1em}}
% \setlength{\mindflowLineHeight}{1pt}
% \begin{mindflow}
%     Hello, here is some text without a meaning. This text should show what a printed text will look like at this place. If you read this text, you will get no information. Really? Is there no information? Is there a difference between this text and some nonsense like “Huardest gefburn”? Kjift – not at all! A blind text like this gives you information about the selected font, how the letters are written and an impression of the look. 
% \end{mindflow}
% \endgroup
%
% \section{About the line numbers}
% \linenumbers
%
% You can also add line numbers to the other part of your document in the usual
% way. For example, line numbers have been turned on for this paragraph with
% \lstinline|\linenumbers|.
%
% \begin{mindflow}
%   Line numbers within the \textsf{mindflow} environments are independent from
%   those of the main text.
% \end{mindflow}
% (\emph{I recommend that you put an empty line before and after the mindflow
% environments, i.e.~make the \emph{\textsf{mindflow}} environment a paragraph
% of its own. This way, your paragraph structure won't get changed when you use
% the} \verb|off|\emph{ option.})
%
% \nolinenumbers
%
% The line numbering feature is provided by package \textsf{lineno}. For
% more details, please refer to its documentation. Notice that
% displayed equations are not numbered by default. To enable the line numbers for them, you can use the option \verb|mathlines|. The result would be like:
%
% \begin{mindflow}\vspace{-\baselineskip}
% \begin{align*}
%     \sum_{i_1 < \cdots < i_n} \prod_{1 \leqslant j \leqslant n} i_j^{-2}  &= \frac{\pi^{2n}}{(2n+1)!}\\
%     \implies \frac{e^{\pi}-e^{-\pi}}{2\pi} &= 1+ \sum_{n \geqslant 1} \sum_{i_1 < \cdots < i_n} \prod_{1 \leqslant j \leqslant n} i_j^{-2}
% \end{align*}
% \end{mindflow}
%
% \clearpage
% {\color{black!55}
% \makebox[\linewidth]{\rule{4\paperwidth}{\mindflowLineHeight}}%
% \centerline{\itshape ---~~Readers who are not interested in technical details can skip the rest~~---}
%
% \vspace{-\baselineskip}
% \makebox[\linewidth]{\rule{4\paperwidth}{\mindflowLineHeight}}%
% }
%
% \section{Some \TeX{}nical details}
%
% \subsection{Internal macros for text elements}
% \DescribeMacro{\mindflowTextFont}
% \DescribeMacro{\mindflowNumFont}
% \DescribeMacro{\mindflowMarkerFont}
% The font for text, line numbers and markers within the \verb|mindflow|
% environments can be specified by redefining \lstinline|\mindflowTextFont|,
% \lstinline|\mindflowNumFont| and \lstinline|\mindflowMarkerFont|. By default, 
% they are defined as:
% \iffalse
%<*example>
% \fi
\begin{code*}
\newcommand{\mindflowTextFont}{\footnotesize}
\newcommand{\mindflowNumFont}{\scriptsize\ttfamily}
\newcommand{\mindflowMarkerFont}{\scriptsize\ttfamily}
\end{code*}
% \iffalse
%</example>
% \fi
% \vspace{-.5\baselineskip}
%
% \DescribeMacro{\mindflowLeft}
% \DescribeMacro{\mindflowRight}
% The left and right markers is defined by
% \lstinline|\mindflowLeft| and \lstinline|\mindflowRight|. Both have the default
% value ``\verb|*|''.
%
% \DescribeMacro{\mindflowLineHeight}
% The height of the separation lines is a length macro named \lstinline|\mindflowLineHeight|, 
% with default value \verb|0.4pt|. You can change this with \lstinline|\setlength|.
%
% \subsection{Internal names of the colors}
% \DescribeMacro{mindflowLine}
% \DescribeMacro{mindflowText}
% \DescribeMacro{mindflowNum}
% \DescribeMacro{mindflowMarker}
% And finally, the colors for the separation lines, text, line numbers and
% markers within the \verb|mindflow| environments are called
% \verb|mindflowLine|, \verb|mindflowText|, \verb|mindflowNum| and
% \verb|mindflowMarker|, respectively. By default, they have the same color as
% the context, with opacity 40\% for the separation lines and text, 20\% for 
% the markers, and 8\% for line numbers. 
% 
% \DescribeMacro{*mindflowBackground}
% If the package option \verb|nonbreakable| is enabled, then there is also the background color \verb|mindflowBackground|, which by default is white.
%
% \section{The same example revisited}
% With option \verb|leftlinenumber, rightlinenumber, leftmarker, rightmarker| 
% and the following settings:
% \iffalse
%<*example>
% \fi
\begin{code*}
\colorlet{mindflowLine}{green!50!black}
\colorlet{mindflowText}{blue!50!cyan}
\colorlet{mindflowNum}{red!50!orange}
\colorlet{mindflowMarker}{orange}
\renewcommand{\mindflowTextFont}{\footnotesize\sffamily\itshape}
\renewcommand{\mindflowNumFont}{\small\footnotesize\ttfamily}
\renewcommand{\mindflowMarkerFont}{\footnotesize\sffamily}
\renewcommand{\mindflowLeft}{\hspace{1em}\(\succ\)}
\renewcommand{\mindflowRight}{\(\prec\)\hspace{1em}}
\setlength{\mindflowLineHeight}{1pt}
\end{code*}
% \iffalse
%</example>
% \fi
% \vspace{-.5\baselineskip}
% One will get the same result as in the previous example.
%
% \section{Known issues}
% 
% \begin{itemize}
%     \item There is no absolute guarantee that the separation lines will not fall alone at the top or bottom of the page, though great effort has been made to reduce the occurrence of such situation.
%     \item The \texttt{nonbreakable} version does not support line numbering quite well, especially for displayed equations. This is due to the usage of \verb|internallinenumbers|.
% \end{itemize}
%
% \StopEventually{}
%
% \clearpage
% \section{Implementation}
% Below is the complete source code of this package.
%
% \begin{code}
\RequirePackage{kvoptions}
\SetupKeyvalOptions{%
    family = @mindflow,
    prefix = @mindflow@
}
\DeclareBoolOption[true]{on}               % Turn on mindflow
\DeclareBoolOption[false]{off}             % Turn off mindflow
\DeclareBoolOption[false]{leftmarker}      % Left marker
\DeclareBoolOption[false]{rightmarker}     % Right marker
\DeclareBoolOption[false]{linenumber}      % Left line numbers
\DeclareBoolOption[false]{leftlinenumber}  % Left line numbers
\DeclareBoolOption[false]{rightlinenumber} % Right line numbers
\DeclareBoolOption[false]{incolumn}        % Separation line fits in column
\DeclareBoolOption[false]{nonbreakable}    % Use the tcolorbox version
\DeclareBoolOption[false]{mathlines}       % Add line numbers to equations

\ProcessKeyvalOptions*\relax

\if@mindflow@on
  \@mindflow@offfalse
\fi
\if@mindflow@linenumber
  \@mindflow@leftlinenumbertrue
\fi
\if@mindflow@mathlines
  \PassOptionsToPackage{mathlines}{lineno}
\fi

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

\colorlet{mfSavedColor}{.}
\colorlet{mindflowLine}{mfSavedColor!40}
\colorlet{mindflowText}{mfSavedColor!40}
\colorlet{mindflowMarker}{mfSavedColor!20}
\colorlet{mindflowNum}{mfSavedColor!8}

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

%%================================
%% The mindflow environment
%%================================
\PassOptionsToPackage{all}{nowidow}
\RequirePackage{nowidow}
\RequirePackage{verbatim}

\newif\ifLNturnsON
\def\LocallyStopLineNumbers{\LNturnsONfalse%
    \ifLineNumbers\LNturnsONtrue\fi\nolinenumbers}
\def\ResumeLineNumbers{\ifLNturnsON\linenumbers\fi}

\newif\ifICturnsON
\def\AutoIncolumn{\ICturnsONfalse%
    \if@mindflow@incolumn\ICturnsONtrue\fi%
    \if@twocolumn\@mindflow@incolumntrue\fi%
}
\def\ResumeIncolumn{\ifICturnsON\@mindflow@incolumntrue\fi}

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

\newcommand*{\mfSepLine}{%
  \par%\nobreak%
  \LocallyStopLineNumbers%
  \vspace*{-.5\baselineskip}%
  \noindent%
  \if@mindflow@incolumn%
    \makebox[\linewidth]{\color{mindflowLine}\rule{\linewidth}{\mindflowLineHeight}}%
  \else%
    \hspace*{-\paperwidth}%
    \makebox[\linewidth]{\color{mindflowLine}\rule{4\paperwidth}{\mindflowLineHeight}}%
  \fi%
  \par%\nobreak%
  \ResumeLineNumbers%
}

\newcommand{\mindflow@makeLineNumber}{%
  \hss%
  \if@mindflow@leftlinenumber%
    \normalfont\mindflowNumFont\color{mindflowNum}\LineNumber\hspace{1em}%
  \fi%
  \color{mindflowMarker}%
  \if@mindflow@leftmarker%
    \normalfont\mindflowMarkerFont\mindflowLeft\hspace{1em}%
  \fi%
  \rlap{\hskip\textwidth%
    \if@mindflow@rightmarker%
      \hspace{1em}\mindflowRight%
    \fi%
    \if@mindflow@rightlinenumber%
      \hspace{1em}%
      \normalfont\mindflowNumFont\color{mindflowNum}\LineNumber%
    \fi%
  }%
}%

\let\mindflowOFF=\comment
\let\endmindflowOFF=\endcomment

\def\mindflowON{%
  \postdisplaypenalty=10000
  \parskip=0pt
  \medskip%
  \setcounter{recordLN}{\value{linenumber}}%
  \setcounter{linenumber}{\value{mfLN}}%
  \AutoIncolumn%
  \mfSepLine%
  \normalfont\mindflowTextFont\color{mindflowText}%
  \linenumbers%
  \let\makeLineNumber\mindflow@makeLineNumber%
  \nopagebreak%
}
\def\endmindflowON{%
  \nowidow[3]%
  \mfSepLine%
  \setcounter{mfLN}{\value{linenumber}}%
  \setcounter{linenumber}{\value{recordLN}}%
  \ResumeIncolumn%
  \medskip%
}

\colorlet{mindflowBackground}{white}

\if@mindflow@nonbreakable
\PassOptionsToPackage{many}{tcolorbox}
\RequirePackage{tcolorbox}
\newlength{\mindflow@parindent}
\newlength{\mindflow@parskip}
\newtcolorbox{mindflow@nonbreakable}[1]{
  enhanced jigsaw,
  colback=mindflowBackground,colframe=mindflowLine,
  leftrule=0pt, rightrule=0pt, sharp corners,
  toprule=\mindflowLineHeight, bottomrule=\mindflowLineHeight,
  boxsep=0pt, top=.3\baselineskip, bottom=.3\baselineskip,
  fontupper=\mindflowTextFont,extras={colupper={mindflowText}},
  before upper={
    \setlength{\parindent}{\mindflow@parindent}%
    \setlength{\parskip}{\mindflow@parskip}%
  },#1
}
\def\mindflowON{%
  \LocallyStopLineNumbers%
  \setcounter{recordLN}{\value{linenumber}}%
  \setcounter{linenumber}{\value{mfLN}}%
  \AutoIncolumn%
  \setlength{\mindflow@parindent}{\parindent}%
  \setlength{\mindflow@parskip}{\parskip}%
  \if@mindflow@incolumn%
    \begin{mindflow@nonbreakable}{left=0pt,right=0pt}
  \else%
    \begin{mindflow@nonbreakable}{%
      grow to left by=\linewidth,left=\linewidth,
      grow to right by=\linewidth,right=\linewidth}
  \fi
    \begin{internallinenumbers}%
      \let\makeLineNumber\mindflow@makeLineNumber%
}
\def\endmindflowON{%
      \nowidow[3]%
    \end{internallinenumbers}%
  \end{mindflow@nonbreakable}\par%
  \ResumeLineNumbers%
  \setcounter{mfLN}{\value{linenumber}}%
  \setcounter{linenumber}{\value{recordLN}}%
  \ResumeIncolumn%
}
\fi

\if@mindflow@off
  \let\mindflow=\mindflowOFF
  \let\endmindflow=\endmindflowOFF
\else
  \let\mindflow=\mindflowON
  \let\endmindflow=\endmindflowON
\fi

%%================================
%% \mindflowset
%%================================
\define@key{mindflow}{on}[true]{%
  \csname @mindflow@on#1\endcsname%
  \if@mindflow@off%
    \let\mindflow=\mindflowOFF%
    \let\endmindflow=\endmindflowOFF%
  \else%
    \let\mindflow=\mindflowON%
    \let\endmindflow=\endmindflowON%
  \fi%
}
\define@key{mindflow}{off}[true]{%
  \csname @mindflow@off#1\endcsname%
  \if@mindflow@off%
    \let\mindflow=\mindflowOFF%
    \let\endmindflow=\endmindflowOFF%
  \else%
    \let\mindflow=\mindflowON%
    \let\endmindflow=\endmindflowON%
  \fi%
}
\define@key{mindflow}{leftmarker}[true]{\csname @mindflow@leftmarker#1\endcsname}
\define@key{mindflow}{rightmarker}[true]{\csname @mindflow@rightmarker#1\endcsname}
\define@key{mindflow}{linenumber}[true]{\csname @mindflow@leftlinenumber#1\endcsname}
\define@key{mindflow}{leftlinenumber}[true]{\csname @mindflow@leftlinenumber#1\endcsname}
\define@key{mindflow}{rightlinenumber}[true]{\csname @mindflow@rightlinenumber#1\endcsname}
\define@key{mindflow}{incolumn}[true]{\csname @mindflow@incolumn#1\endcsname}
\define@key{mindflow}{linecolor}{\colorlet{mindflowLine}{#1}}
\define@key{mindflow}{textcolor}{\colorlet{mindflowText}{#1}}
\define@key{mindflow}{numcolor}{\colorlet{mindflowNum}{#1}}
\define@key{mindflow}{markercolor}{\colorlet{mindflowMarker}{#1}}
\define@key{mindflow}{backgroundcolor}{
  \if@mindflow@nonbreakable
    \colorlet{mindflowBackground}{#1}
  \else
    \PackageWarning{mindflow}{The key ``backgroundcolor'' is only available when the package option\MessageBreak ``nonbreakable'' is enabled.}
  \fi
}
\define@key{mindflow}{textfont}{\renewcommand{\mindflowTextFont}{#1}}
\define@key{mindflow}{numfont}{\renewcommand{\mindflowNumFont}{#1}}
\define@key{mindflow}{markerfont}{\renewcommand{\mindflowMarkerFont}{#1}}
\define@key{mindflow}{left}{\renewcommand{\mindflowLeft}{#1}}
\define@key{mindflow}{right}{\renewcommand{\mindflowRight}{#1}}
\define@key{mindflow}{lineheight}{\setlength{\mindflowLineHeight}{#1}}

\newcommand{\mindflowset}[1]{%
  \setkeys{mindflow}{#1}%
}
% \end{code}
%
% \Finale
\endinput