| 1 |
\documentclass[parskip=false, DIV=8, headings=normal, pagesize=auto]{scrartcl} |
| 2 |
|
| 3 |
\usepackage{fixltx2e} |
| 4 |
\usepackage{etex} |
| 5 |
\usepackage{xspace} |
| 6 |
\usepackage{lmodern} |
| 7 |
\usepackage[T1]{fontenc} |
| 8 |
\usepackage{textcomp} |
| 9 |
\usepackage{microtype} |
| 10 |
\usepackage[unicode=true]{hyperref} |
| 11 |
|
| 12 |
\newenvironment*{noverb}{% |
| 13 |
\flushleft |
| 14 |
\vskip\parskip |
| 15 |
\parskip=0pt\relax |
| 16 |
}{% |
| 17 |
\endflushleft |
| 18 |
} |
| 19 |
|
| 20 |
\newcommand*{\mail}[1]{\href{mailto:#1}{\texttt{#1}}} |
| 21 |
\newcommand*{\pkg}[1]{\textsf{#1}} |
| 22 |
\newcommand*{\cs}[1]{\texttt{\textbackslash#1}} |
| 23 |
\makeatletter |
| 24 |
\newcommand*{\cmd}[1]{\cs{\expandafter\@gobble\string#1}} |
| 25 |
\makeatother |
| 26 |
\newcommand*{\env}[1]{\texttt{#1}} |
| 27 |
\newcommand*{\meta}[1]{\textlangle\textsl{#1}\textrangle} |
| 28 |
\newcommand*{\marg}[1]{\texttt{\{}\meta{#1}\texttt{\}}} |
| 29 |
|
| 30 |
\addtokomafont{title}{\rmfamily} |
| 31 |
|
| 32 |
\title{The \pkg{comment} package\thanks{This manual corresponds to |
| 33 |
\pkg{comment}~v3.8 of July 2016.}} |
| 34 |
% |
| 35 |
\author{Victor Eijkhout\\\mail{[email protected]}} \date{August 2016} |
| 36 |
|
| 37 |
|
| 38 |
\begin{document} |
| 39 |
|
| 40 |
\maketitle |
| 41 |
|
| 42 |
\section{Purpose:} |
| 43 |
|
| 44 |
Selectively in/exclude pieces of text: the user can define new |
| 45 |
comment versions, and each is controlled separately. |
| 46 |
Special comments can be defined where the user specifies the |
| 47 |
action that is to be taken with each comment line. |
| 48 |
|
| 49 |
Plain \TeX\ support has been phased out. |
| 50 |
|
| 51 |
As of 3.8 the package will increasingly use e\TeX\ features, for |
| 52 |
instance to solve Unicode support issues. |
| 53 |
|
| 54 |
\section{Usage:} |
| 55 |
|
| 56 |
All text included between |
| 57 |
% |
| 58 |
\begin{verbatim} |
| 59 |
\begin{comment} |
| 60 |
... |
| 61 |
\end{comment} |
| 62 |
\end{verbatim} |
| 63 |
% |
| 64 |
is discarded. |
| 65 |
|
| 66 |
The opening and closing commands should appear on a line |
| 67 |
of their own. No starting spaces, nothing after it. |
| 68 |
This environment should work with arbitrary amounts |
| 69 |
of comment, and the comment can be arbitrary text. |
| 70 |
|
| 71 |
Other `\env{comment}' environments are defined by |
| 72 |
and are selected/deselected with |
| 73 |
% |
| 74 |
\begin{verbatim} |
| 75 |
\includecomment{versiona} |
| 76 |
\excludecoment{versionb} |
| 77 |
\end{verbatim} |
| 78 |
% |
| 79 |
These environments are used as |
| 80 |
% |
| 81 |
\begin{verbatim} |
| 82 |
\versiona ... \endversiona |
| 83 |
\end{verbatim} |
| 84 |
% |
| 85 |
or |
| 86 |
% |
| 87 |
\begin{verbatim} |
| 88 |
\begin{versiona} ... \end{versiona} |
| 89 |
\end{verbatim} |
| 90 |
% |
| 91 |
with the opening and closing commands again on a line of |
| 92 |
their own. |
| 93 |
|
| 94 |
\pagebreak[1] |
| 95 |
|
| 96 |
\LaTeX\ users note: for an included comment, the |
| 97 |
\cmd{\begin} and \cmd{\end} lines act as if they don't exist. |
| 98 |
In particular, they don't imply grouping, so assignments |
| 99 |
\&c are not local. |
| 100 |
|
| 101 |
\pagebreak[2] |
| 102 |
|
| 103 |
Special comments are defined as |
| 104 |
% |
| 105 |
\begin{noverb} |
| 106 |
\cmd{\specialcomment}\marg{name}\marg{before commands}\marg{after commands} |
| 107 |
\end{noverb} |
| 108 |
% |
| 109 |
where the second and third arguments are executed before |
| 110 |
and after each comment block. You can use this for global |
| 111 |
formatting commands. |
| 112 |
To keep definitions \&c local, you can include \cmd{\begingroup} |
| 113 |
in the `\meta{before commands}' and \cmd{\endgroup} in the `\meta{after commands}'. |
| 114 |
ex: |
| 115 |
% |
| 116 |
\begin{verbatim} |
| 117 |
\specialcomment{smalltt} |
| 118 |
{\begingroup\ttfamily\footnotesize}{\endgroup} |
| 119 |
\end{verbatim} |
| 120 |
% |
| 121 |
You do \emph{not} have to do an additional |
| 122 |
% |
| 123 |
\begin{verbatim} |
| 124 |
\includecomment{smalltt} |
| 125 |
\end{verbatim} |
| 126 |
% |
| 127 |
To remove `\env{smalltt}' blocks, give \verb+\excludecomment{smalltt}+ |
| 128 |
after the definition. |
| 129 |
|
| 130 |
Processing comments can apply processing to each line. |
| 131 |
% |
| 132 |
\begin{noverb} |
| 133 |
\cmd{\processcomment}\marg{name}\marg{each-line commands}\marg{before commands}\marg{after commands} |
| 134 |
\end{noverb} |
| 135 |
% |
| 136 |
By defining a control sequence |
| 137 |
% |
| 138 |
\begin{verbatim} |
| 139 |
\def\Thiscomment##1{...} |
| 140 |
\end{verbatim} |
| 141 |
% |
| 142 |
in the before commands the user can |
| 143 |
specify what is to be done with each comment line. |
| 144 |
BUG this does not work quite yet BUG |
| 145 |
|
| 146 |
Trick for short in/exclude macros (such as \verb+\maybe{this snippet}+): |
| 147 |
% |
| 148 |
\begin{verbatim} |
| 149 |
\includecomment{cond} |
| 150 |
\newcommand{\maybe}[1]{} |
| 151 |
\begin{cond} |
| 152 |
\renewcommand{\maybe}[1]{#1} |
| 153 |
\end{cond} |
| 154 |
\end{verbatim} |
| 155 |
|
| 156 |
|
| 157 |
\section{Basic approach of the implementation:} |
| 158 |
|
| 159 |
to comment something out, scoop up every line in verbatim mode |
| 160 |
as macro argument, then throw it away. |
| 161 |
For inclusions, in \LaTeX\ the block is written out to |
| 162 |
a file \cmd{\CommentCutFile} (default ``\texttt{comment.cut}''), which is |
| 163 |
then included. |
| 164 |
In plain \TeX\ (and other formats) both the opening and |
| 165 |
closing comands are defined as noop. |
| 166 |
|
| 167 |
|
| 168 |
\section{Changes in version 3.1} |
| 169 |
|
| 170 |
\begin{itemize} |
| 171 |
\item updated author's address |
| 172 |
\item cleaned up some code |
| 173 |
\item trailing contents on \cmd{\begin}\marg{env} line is always discarded |
| 174 |
even if you've done \cmd{\includecomment}\marg{env} |
| 175 |
\item comments no longer define grouping!! you can even |
| 176 |
% |
| 177 |
\begin{verbatim} |
| 178 |
\includecomment{env} |
| 179 |
\begin{env} |
| 180 |
\begin{itemize} |
| 181 |
\end{env} |
| 182 |
\end{verbatim} |
| 183 |
% |
| 184 |
Isn't that something\ldots |
| 185 |
\item included comments are written to file and input again. |
| 186 |
\end{itemize} |
| 187 |
|
| 188 |
|
| 189 |
\section{Changes in 3.2} |
| 190 |
|
| 191 |
\begin{itemize} |
| 192 |
\item \cmd{\specialcomment} brought up to date (thanks to Ivo Welch). |
| 193 |
\end{itemize} |
| 194 |
|
| 195 |
|
| 196 |
\section{Changes in 3.3} |
| 197 |
|
| 198 |
\begin{itemize} |
| 199 |
\item updated author's address again |
| 200 |
\item parametrised \cmd{\CommentCutFile} |
| 201 |
\end{itemize} |
| 202 |
|
| 203 |
|
| 204 |
\section{Changes in 3.4} |
| 205 |
|
| 206 |
\begin{itemize} |
| 207 |
\item added GNU public license |
| 208 |
\item added \cmd{\processcomment}, because Ivo's fix (above) brought an |
| 209 |
inconsistency to light. |
| 210 |
\end{itemize} |
| 211 |
|
| 212 |
|
| 213 |
\section{Changes in 3.5} |
| 214 |
|
| 215 |
\begin{itemize} |
| 216 |
\item corrected typo in header. |
| 217 |
\item changed author email |
| 218 |
\item corrected \cmd{\specialcomment} yet again. |
| 219 |
\item fixed excludecomment of an earlier defined environment. |
| 220 |
\end{itemize} |
| 221 |
|
| 222 |
|
| 223 |
\section{Changes in 3.6} |
| 224 |
|
| 225 |
\begin{itemize} |
| 226 |
\item The `cut' file is now written more verbatim, using \cmd{\meaning}; |
| 227 |
some people reported having trouble with ISO~latin~1, or \texttt{umlaute.sty}. |
| 228 |
\item removed some \cmd{\newif} statements. |
| 229 |
Has this suddenly become \cmd{\outer} again? |
| 230 |
\end{itemize} |
| 231 |
|
| 232 |
|
| 233 |
\section{Changes in 3.8} |
| 234 |
|
| 235 |
T1 font encoding is now supported. See t1test.tex. |
| 236 |
|
| 237 |
%% \section{Known bugs:} |
| 238 |
|
| 239 |
%% \begin{itemize} |
| 240 |
%% \item \texttt{excludecomment} leads to one superfluous space |
| 241 |
%% \item \texttt{processcomment} leads to a superfluous line break |
| 242 |
%% \end{itemize} |
| 243 |
|
| 244 |
\end{document} |