thys2/Journal/comment.sty
author Chengsong
Fri, 30 Dec 2022 23:41:44 +0000
changeset 640 bd1354127574
parent 369 e00950ba4514
permissions -rw-r--r--
more proofreading done, last version before submission
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
369
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
     1
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
     2
% Comment.sty   version 3.6, October 1999
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
     3
%
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
     4
% Purpose:
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
     5
% selectively in/exclude pieces of text: the user can define new
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
     6
% comment versions, and each is controlled separately.
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
     7
% Special comments can be defined where the user specifies the
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
     8
% action that is to be taken with each comment line.
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
     9
%
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    10
% Author
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    11
%    Victor Eijkhout
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    12
%    Department of Computer Science
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    13
%    University of Tennessee
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    14
%    107 Ayres Hall
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    15
%    Knoxville TN 37996
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    16
%    USA
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    17
%
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    18
%    victor@eijkhout.net
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    19
%
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    20
% This program is free software; you can redistribute it and/or
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    21
% modify it under the terms of the GNU General Public License
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    22
% as published by the Free Software Foundation; either version 2
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    23
% of the License, or (at your option) any later version.
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    24
% 
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    25
% This program is distributed in the hope that it will be useful,
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    26
% but WITHOUT ANY WARRANTY; without even the implied warranty of
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    27
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    28
% GNU General Public License for more details.
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    29
%
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    30
% For a copy of the GNU General Public License, write to the 
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    31
% Free Software Foundation, Inc.,
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    32
% 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA,
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    33
% or find it on the net, for instance at
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    34
% http://www.gnu.org/copyleft/gpl.html
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    35
%
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    36
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    37
% This style can be used with plain TeX or LaTeX, and probably
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    38
% most other packages too.
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    39
%
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    40
% Usage: all text included between
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    41
%    \comment ... \endcomment
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    42
% or \begin{comment} ... \end{comment}
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    43
% is discarded. 
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    44
%
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    45
% The opening and closing commands should appear on a line
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    46
% of their own. No starting spaces, nothing after it.
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    47
% This environment should work with arbitrary amounts
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    48
% of comment, and the comment can be arbitrary text.
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    49
%
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    50
% Other `comment' environments are defined by
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    51
% and are selected/deselected with
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    52
% \includecomment{versiona}
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    53
% \excludecoment{versionb}
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    54
%
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    55
% These environments are used as
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    56
% \versiona ... \endversiona
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    57
% or \begin{versiona} ... \end{versiona}
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    58
% with the opening and closing commands again on a line of 
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    59
% their own.
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    60
%
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    61
% LaTeX users note: for an included comment, the
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    62
% \begin and \end lines act as if they don't exist.
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    63
% In particular, they don't imply grouping, so assignments 
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    64
% &c are not local.
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    65
%
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    66
% Special comments are defined as
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    67
% \specialcomment{name}{before commands}{after commands}
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    68
% where the second and third arguments are executed before
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    69
% and after each comment block. You can use this for global
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    70
% formatting commands.
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    71
% To keep definitions &c local, you can include \begingroup
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    72
% in the `before commands' and \endgroup in the `after commands'.
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    73
% ex:
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    74
% \specialcomment{smalltt}
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    75
%     {\begingroup\ttfamily\footnotesize}{\endgroup}
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    76
% You do *not* have to do an additional
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    77
% \includecomment{smalltt}
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    78
% To remove 'smalltt' blocks, give \excludecomment{smalltt}
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    79
% after the definition.
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    80
%
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    81
% Processing comments can apply processing to each line.
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    82
% \processcomment{name}{each-line commands}%
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    83
%    {before commands}{after commands}
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    84
% By defining a control sequence 
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    85
% \def\Thiscomment##1{...} in the before commands the user can
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    86
% specify what is to be done with each comment line.
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    87
% BUG this does not work quite yet BUG
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    88
%
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    89
% Trick for short in/exclude macros (such as \maybe{this snippet}):
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    90
%\includecomment{cond}
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    91
%\newcommand{\maybe}[1]{}
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    92
%\begin{cond}
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    93
%\renewcommand{\maybe}[1]{#1}
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    94
%\end{cond}
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    95
%
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    96
% Basic approach of the implementation:
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    97
% to comment something out, scoop up  every line in verbatim mode
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    98
% as macro argument, then throw it away.
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
    99
% For inclusions, in LaTeX the block is written out to
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   100
% a file \CommentCutFile (default "comment.cut"), which is
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   101
% then included.
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   102
% In plain TeX (and other formats) both the opening and
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   103
% closing comands are defined as noop.
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   104
%
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   105
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   106
% Changes in version 3.1
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   107
% - updated author's address
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   108
% - cleaned up some code
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   109
% - trailing contents on \begin{env} line is always discarded
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   110
%  even if you've done \includecomment{env}
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   111
% - comments no longer define grouping!! you can even
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   112
%   \includecomment{env}
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   113
%   \begin{env}
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   114
%   \begin{itemize}
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   115
%   \end{env}
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   116
%  Isn't that something ...
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   117
% - included comments are written to file and input again.
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   118
% Changes in 3.2
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   119
% - \specialcomment brought up to date (thanks to Ivo Welch).
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   120
% Changes in 3.3
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   121
% - updated author's address again
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   122
% - parametrised \CommentCutFile
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   123
% Changes in 3.4
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   124
% - added GNU public license
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   125
% - added \processcomment, because Ivo's fix (above) brought an
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   126
%   inconsistency to light.
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   127
% Changes in 3.5
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   128
% - corrected typo in header.
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   129
% - changed author email
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   130
% - corrected \specialcomment yet again.
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   131
% - fixed excludecomment of an earlier defined environment.
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   132
% Changes in 3.6
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   133
% - The 'cut' file is now written more verbatim, using \meaning;
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   134
%   some people reported having trouble with ISO latin 1, or umlaute.sty.
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   135
% - removed some \newif statements.
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   136
%   Has this suddenly become \outer again?
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   137
%
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   138
% Known bugs:
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   139
% - excludecomment leads to one superfluous space
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   140
% - processcomment leads to a superfluous line break
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   141
%
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   142
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   143
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   144
\def\makeinnocent#1{\catcode`#1=12 }
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   145
\def\csarg#1#2{\expandafter#1\csname#2\endcsname}
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   146
\def\latexname{lplain}\def\latexename{LaTeX2e}
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   147
\newwrite\CommentStream
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   148
\def\CommentCutFile{comment.cut}
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   149
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   150
\def\ProcessComment#1% start it all of
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   151
   {\begingroup
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   152
    \def\CurrentComment{#1}%
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   153
    \let\do\makeinnocent \dospecials 
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   154
    \makeinnocent\^^L% and whatever other special cases
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   155
    \endlinechar`\^^M \catcode`\^^M=12 \xComment}
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   156
%\def\ProcessCommentWithArg#1#2% to be used in \leveledcomment
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   157
%   {\begingroup
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   158
%    \def\CurrentComment{#1}%
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   159
%    \let\do\makeinnocent \dospecials 
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   160
%    \makeinnocent\^^L% and whatever other special cases
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   161
%    \endlinechar`\^^M \catcode`\^^M=12 \xComment}
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   162
{\catcode`\^^M=12 \endlinechar=-1 %
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   163
 \gdef\xComment#1^^M{%
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   164
    \expandafter\ProcessCommentLine}
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   165
 \gdef\ProcessCommentLine#1^^M{\def\test{#1}
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   166
      \csarg\ifx{End\CurrentComment Test}\test
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   167
          \edef\next{\noexpand\EndOfComment{\CurrentComment}}%
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   168
      \else \ThisComment{#1}\let\next\ProcessCommentLine
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   169
      \fi \next}
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   170
}
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   171
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   172
\def\CSstringmeaning#1{\expandafter\CSgobblearrow\meaning#1}
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   173
\def\CSstringcsnoescape#1{\expandafter\CSgobbleescape\string#1}
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   174
{\escapechar-1
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   175
\expandafter\expandafter\expandafter\gdef
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   176
  \expandafter\expandafter\expandafter\CSgobblearrow
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   177
    \expandafter\string\csname macro:->\endcsname{}
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   178
}
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   179
\def\CSgobbleescape#1{\ifnum`\\=`#1 \else #1\fi}
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   180
\def\WriteCommentLine#1{\def\CStmp{#1}%
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   181
    \immediate\write\CommentStream{\CSstringmeaning\CStmp}}
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   182
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   183
% 3.1 change: in LaTeX and LaTeX2e prevent grouping
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   184
\if 0%
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   185
\ifx\fmtname\latexename 
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   186
    0%
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   187
\else \ifx\fmtname\latexname 
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   188
          0%
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   189
      \else 
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   190
          1%
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   191
\fi   \fi
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   192
%%%%
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   193
%%%% definitions for LaTeX
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   194
%%%%
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   195
\def\AfterIncludedComment
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   196
   {\immediate\closeout\CommentStream
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   197
    \input{\CommentCutFile}\relax
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   198
    }%
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   199
\def\TossComment{\immediate\closeout\CommentStream}
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   200
\def\BeforeIncludedComment
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   201
   {\immediate\openout\CommentStream=\CommentCutFile
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   202
    \let\ThisComment\WriteCommentLine}
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   203
\def\includecomment
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   204
 #1{\message{Include comment '#1'}%
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   205
    \csarg\let{After#1Comment}\AfterIncludedComment
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   206
    \csarg\def{#1}{\BeforeIncludedComment
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   207
        \ProcessComment{#1}}%
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   208
    \CommentEndDef{#1}}
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   209
\long\def\specialcomment
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   210
 #1#2#3{\message{Special comment '#1'}%
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   211
    % note: \AfterIncludedComment does \input, so #2 goes here!
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   212
    \csarg\def{After#1Comment}{#2\AfterIncludedComment#3}%
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   213
    \csarg\def{#1}{\BeforeIncludedComment\relax
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   214
          \ProcessComment{#1}}%
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   215
    \CommentEndDef{#1}}
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   216
\long\def\processcomment
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   217
 #1#2#3#4{\message{Lines-Processing comment '#1'}%
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   218
    \csarg\def{After#1Comment}{#3\AfterIncludedComment#4}%
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   219
    \csarg\def{#1}{\BeforeIncludedComment#2\relax
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   220
          \ProcessComment{#1}}%
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   221
    \CommentEndDef{#1}}
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   222
\def\leveledcomment
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   223
 #1#2{\message{Include comment '#1' up to level '#2'}%
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   224
    %\csname #1IsLeveledCommenttrue\endcsname
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   225
    \csarg\let{After#1Comment}\AfterIncludedComment
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   226
    \csarg\def{#1}{\BeforeIncludedComment
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   227
        \ProcessCommentWithArg{#1}}%
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   228
    \CommentEndDef{#1}}
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   229
\else 
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   230
%%%%
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   231
%%%%plain TeX and other formats
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   232
%%%%
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   233
\def\includecomment
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   234
 #1{\message{Including comment '#1'}%
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   235
    \csarg\def{#1}{}%
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   236
    \csarg\def{end#1}{}}
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   237
\long\def\specialcomment
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   238
 #1#2#3{\message{Special comment '#1'}%
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   239
    \csarg\def{#1}{\def\ThisComment{}\def\AfterComment{#3}#2%
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   240
           \ProcessComment{#1}}%
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   241
    \CommentEndDef{#1}}
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   242
\fi
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   243
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   244
%%%%
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   245
%%%% general definition of skipped comment
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   246
%%%%
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   247
\def\excludecomment
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   248
 #1{\message{Excluding comment '#1'}%
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   249
    \csarg\def{#1}{\let\AfterComment\relax
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   250
           \def\ThisComment####1{}\ProcessComment{#1}}%
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   251
    \csarg\let{After#1Comment}\TossComment
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   252
    \CommentEndDef{#1}}
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   253
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   254
\if 0%
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   255
\ifx\fmtname\latexename 
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   256
    0%
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   257
\else \ifx\fmtname\latexname 
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   258
          0%
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   259
      \else 
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   260
          1%
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   261
\fi   \fi
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   262
% latex & latex2e:
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   263
\def\EndOfComment#1{\endgroup\end{#1}%
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   264
    \csname After#1Comment\endcsname}
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   265
\def\CommentEndDef#1{{\escapechar=-1\relax
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   266
    \csarg\xdef{End#1Test}{\string\\end\string\{#1\string\}}%
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   267
    }}
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   268
\else
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   269
% plain & other
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   270
\def\EndOfComment#1{\endgroup\AfterComment}
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   271
\def\CommentEndDef#1{{\escapechar=-1\relax
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   272
    \csarg\xdef{End#1Test}{\string\\end#1}%
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   273
    }}
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   274
\fi
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   275
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   276
\excludecomment{comment}
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   277
e00950ba4514 added all files in Journal folder
Chengsong
parents:
diff changeset
   278
\endinput