| 1 |
\documentclass[parskip=false, DIV=8, headings=normal, pagesize=auto]{artikel3}%{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 |
The `\env{comment}' environment is defined by default: |
| 57 |
all text included between |
| 58 |
% |
| 59 |
\begin{verbatim} |
| 60 |
\begin{comment} |
| 61 |
... |
| 62 |
\end{comment} |
| 63 |
\end{verbatim} |
| 64 |
% |
| 65 |
is discarded. |
| 66 |
|
| 67 |
The opening and closing commands should appear on a line |
| 68 |
of their own. No starting spaces, nothing after it. |
| 69 |
This environment should work with arbitrary amounts |
| 70 |
of comment, and the comment can be arbitrary text. |
| 71 |
|
| 72 |
Other `\env{comment}' environments are defined by |
| 73 |
and are selected/deselected with |
| 74 |
% |
| 75 |
\begin{verbatim} |
| 76 |
\includecomment{versiona} |
| 77 |
\excludecoment{versionb} |
| 78 |
\end{verbatim} |
| 79 |
% |
| 80 |
These environments are used as |
| 81 |
% |
| 82 |
\begin{verbatim} |
| 83 |
\begin{versiona} |
| 84 |
... |
| 85 |
\end{versiona} |
| 86 |
\end{verbatim} |
| 87 |
% |
| 88 |
with the opening and closing commands again on a line of |
| 89 |
their own. |
| 90 |
|
| 91 |
Note: for an included comment, the |
| 92 |
\cmd{\begin} and \cmd{\end} lines act as if they don't exist. |
| 93 |
In particular, they don't imply grouping, so assignments |
| 94 |
\&c are not local. |
| 95 |
|
| 96 |
Trick for short in/exclude macros (such as \verb+\maybe{this snippet}+): |
| 97 |
% |
| 98 |
\begin{verbatim} |
| 99 |
\includecomment{cond} |
| 100 |
\newcommand{\maybe}[1]{} |
| 101 |
\begin{cond} |
| 102 |
\renewcommand{\maybe}[1]{#1} |
| 103 |
\end{cond} |
| 104 |
\end{verbatim} |
| 105 |
|
| 106 |
\section{Special comments} |
| 107 |
|
| 108 |
It is possible to make highly customized versions of the comment environment. |
| 109 |
Special comments are defined as |
| 110 |
% |
| 111 |
\begin{noverb} |
| 112 |
\cmd{\specialcomment}\marg{name}\marg{before commands}\marg{after commands} |
| 113 |
\end{noverb} |
| 114 |
% |
| 115 |
where the second and third arguments are executed before |
| 116 |
and after each comment block. You can use this for global |
| 117 |
formatting commands. |
| 118 |
|
| 119 |
To keep definitions \&c local, you can include \cmd{\begingroup} |
| 120 |
in the `\meta{before commands}' and \cmd{\endgroup} in the `\meta{after commands}'. |
| 121 |
|
| 122 |
Example: |
| 123 |
% |
| 124 |
\begin{verbatim} |
| 125 |
\specialcomment{smalltt} |
| 126 |
{\begingroup\ttfamily\footnotesize}{\endgroup} |
| 127 |
\end{verbatim} |
| 128 |
% |
| 129 |
Special comments are automatically included. |
| 130 |
|
| 131 |
The comment environments use two auxiliary commands. You can get |
| 132 |
nifty special effects by redefining them. |
| 133 |
|
| 134 |
\subsection{The cutfile} |
| 135 |
|
| 136 |
The commented text is written to an external file, the `cutfile'. Default definition: |
| 137 |
\begin{verbatim} |
| 138 |
\def\CommentCutFile{comment.cut} |
| 139 |
\end{verbatim} |
| 140 |
|
| 141 |
Included comments are processed like this: |
| 142 |
\begin{verbatim} |
| 143 |
\def\ProcessCutFile{\input{\CommentCutFile}\relax} |
| 144 |
\end{verbatim} |
| 145 |
and excluded files have |
| 146 |
\begin{verbatim} |
| 147 |
\def\ProcessCutFile{} |
| 148 |
\end{verbatim} |
| 149 |
|
| 150 |
\begin{itemize} |
| 151 |
\item By redefining the name of the cutfile, the value of the macro |
| 152 |
\cmd{CommentCutFile}, it becomes possible to have nested comment environments. |
| 153 |
\item If you are writing a textbook, you could have the answers to |
| 154 |
exercises in your source, but write them to file rather than |
| 155 |
formatting them: |
| 156 |
\begin{verbatim} |
| 157 |
\generalcomment{answer} |
| 158 |
{\begingroup |
| 159 |
\edef\tmp{\def\noexpand\CommentCutFile |
| 160 |
{answers/\chapshortname-an\noexpand\arabic{excounter}.tex}}\tmp |
| 161 |
\def\ProcessCutFile{}} |
| 162 |
{\ifIncludeAnswers \begin{quote} |
| 163 |
\leavevmode |
| 164 |
\hbox{\kern-\unitindent |
| 165 |
\textbf Solution to exercise \arabic{chapter}.\arabic{excounter}.\hspace{1em}}% |
| 166 |
\ignorespaces\it |
| 167 |
\input{\CommentCutFile} |
| 168 |
\end{quote}\fi |
| 169 |
\endgroup} |
| 170 |
\end{verbatim} |
| 171 |
\end{itemize} |
| 172 |
|
| 173 |
\subsection{Comment inclusion} |
| 174 |
|
| 175 |
The inclusion of the comment is done |
| 176 |
by \cmd{\ProcessCutFile}, so you can redefine that: |
| 177 |
\begin{verbatim} |
| 178 |
\specialcomment |
| 179 |
{mathexamplewithcode} |
| 180 |
{\begingroup\def\ProcessCutFile{}} % arg1 |
| 181 |
{\verbatiminput{\CommentCutFile} % arg2 |
| 182 |
\endgroup |
| 183 |
This gives: |
| 184 |
\begin{equation} \input{\CommentCutFile} \end{equation} |
| 185 |
} |
| 186 |
\end{verbatim} |
| 187 |
The idea here is to disable inclusion of the file, |
| 188 |
but include it in the after commands, in display math. |
| 189 |
|
| 190 |
\subsection{Processing each line} |
| 191 |
|
| 192 |
You can also apply processing to each line. |
| 193 |
By defining a control sequence |
| 194 |
\begin{verbatim} |
| 195 |
\def\Thiscomment##1{...} |
| 196 |
\end{verbatim} |
| 197 |
in the before commands the user can |
| 198 |
specify what is to be done with each comment line. If something |
| 199 |
needs to be written to file, use \verb+\WriteCommentLine{the stuff}+ |
| 200 |
Example: |
| 201 |
\begin{verbatim} |
| 202 |
\specialcomment |
| 203 |
{underlinecomment} |
| 204 |
{\def\ThisComment##1{\WriteCommentLine{\underline{##1}\par}} |
| 205 |
\par} |
| 206 |
{\par} |
| 207 |
\end{verbatim} |
| 208 |
|
| 209 |
\subsection{More examples} |
| 210 |
|
| 211 |
\begin{verbatim} |
| 212 |
\newcount\comlines |
| 213 |
\specialcomment{countedcomment} |
| 214 |
{\comlines=0\relax \def\ProcessCutFile{}% |
| 215 |
\def\ThisComment##1{\global\advance\comlines1\relax}} |
| 216 |
{**Comment: \number\comlines\ line(s) removed**} |
| 217 |
\end{verbatim} |
| 218 |
|
| 219 |
\begin{verbatim} |
| 220 |
\specialcomment |
| 221 |
{underlinecomment} |
| 222 |
{% |
| 223 |
\def\ProcessCutFile{\input{\CommentCutFile}\relax} |
| 224 |
\def\ThisComment##1{\WriteCommentLine{u: \underline{##1}\par}} |
| 225 |
\par |
| 226 |
} |
| 227 |
{\par} |
| 228 |
\end{verbatim} |
| 229 |
|
| 230 |
\section{Unicode support} |
| 231 |
|
| 232 |
Unicode support works if you use e\TeX, which is for instance the case |
| 233 |
if you use pdflatex. You need the following lines: |
| 234 |
\begin{verbatim} |
| 235 |
\usepackage[T1]{fontenc} |
| 236 |
\usepackage[utf8]{inputenc} |
| 237 |
\end{verbatim} |
| 238 |
in your preamble. |
| 239 |
|
| 240 |
\section{Change log} |
| 241 |
|
| 242 |
\subsection{Changes in version 3.1} |
| 243 |
|
| 244 |
\begin{itemize} |
| 245 |
\item updated author's address |
| 246 |
\item cleaned up some code |
| 247 |
\item trailing contents on \cmd{\begin}\marg{env} line is always discarded |
| 248 |
even if you've done \cmd{\includecomment}\marg{env} |
| 249 |
\item comments no longer define grouping!! you can even |
| 250 |
% |
| 251 |
\begin{verbatim} |
| 252 |
\includecomment{env} |
| 253 |
\begin{env} |
| 254 |
\begin{itemize} |
| 255 |
\end{env} |
| 256 |
\end{verbatim} |
| 257 |
% |
| 258 |
Isn't that something\ldots |
| 259 |
\item included comments are written to file and input again. |
| 260 |
\end{itemize} |
| 261 |
|
| 262 |
|
| 263 |
\subsection{Changes in 3.2} |
| 264 |
|
| 265 |
\begin{itemize} |
| 266 |
\item \cmd{\specialcomment} brought up to date (thanks to Ivo Welch). |
| 267 |
\end{itemize} |
| 268 |
|
| 269 |
|
| 270 |
\subsection{Changes in 3.3} |
| 271 |
|
| 272 |
\begin{itemize} |
| 273 |
\item updated author's address again |
| 274 |
\item parametrised \cmd{\CommentCutFile} |
| 275 |
\end{itemize} |
| 276 |
|
| 277 |
|
| 278 |
\subsection{Changes in 3.4} |
| 279 |
|
| 280 |
\begin{itemize} |
| 281 |
\item added GNU public license |
| 282 |
\item added \cmd{\processcomment}, because Ivo's fix (above) brought an |
| 283 |
inconsistency to light. |
| 284 |
\end{itemize} |
| 285 |
|
| 286 |
|
| 287 |
\subsection{Changes in 3.5} |
| 288 |
|
| 289 |
\begin{itemize} |
| 290 |
\item corrected typo in header. |
| 291 |
\item changed author email |
| 292 |
\item corrected \cmd{\specialcomment} yet again. |
| 293 |
\item fixed excludecomment of an earlier defined environment. |
| 294 |
\end{itemize} |
| 295 |
|
| 296 |
|
| 297 |
\subsection{Changes in 3.6} |
| 298 |
|
| 299 |
\begin{itemize} |
| 300 |
\item The `cut' file is now written more verbatim, using \cmd{\meaning}; |
| 301 |
some people reported having trouble with ISO~latin~1, or \texttt{umlaute.sty}. |
| 302 |
\item removed some \cmd{\newif} statements. |
| 303 |
Has this suddenly become \cmd{\outer} again? |
| 304 |
\end{itemize} |
| 305 |
|
| 306 |
|
| 307 |
\subsection{Changes in 3.8} |
| 308 |
|
| 309 |
T1 font encoding is now supported. See t1test.tex. |
| 310 |
|
| 311 |
\end{document} |