From e0c6872cf40896c7be36b11dcc744620f10adf1d Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Mon, 2 Sep 2019 13:46:59 +0900 Subject: Initial commit --- macros/latex/contrib/comment/Makefile | 6 + macros/latex/contrib/comment/README | 7 + macros/latex/contrib/comment/comm_bug.tex | 32 +++ macros/latex/contrib/comment/comm_test.pdf | Bin 0 -> 38450 bytes macros/latex/contrib/comment/comm_test.tex | 97 ++++++++ macros/latex/contrib/comment/comm_test_ivo.tex | 32 +++ macros/latex/contrib/comment/comm_test_l.tex | 78 +++++++ macros/latex/contrib/comment/comment.pdf | Bin 0 -> 236600 bytes macros/latex/contrib/comment/comment.sty | 294 +++++++++++++++++++++++ macros/latex/contrib/comment/comment.tex | 311 +++++++++++++++++++++++++ macros/latex/contrib/comment/comment_plain.tex | 263 +++++++++++++++++++++ macros/latex/contrib/comment/t1test.pdf | Bin 0 -> 11855 bytes macros/latex/contrib/comment/t1test.tex | 24 ++ macros/latex/contrib/comment/writeup.pdf | Bin 0 -> 244307 bytes macros/latex/contrib/comment/writeup.tex | 244 +++++++++++++++++++ 15 files changed, 1388 insertions(+) create mode 100644 macros/latex/contrib/comment/Makefile create mode 100644 macros/latex/contrib/comment/README create mode 100644 macros/latex/contrib/comment/comm_bug.tex create mode 100644 macros/latex/contrib/comment/comm_test.pdf create mode 100644 macros/latex/contrib/comment/comm_test.tex create mode 100644 macros/latex/contrib/comment/comm_test_ivo.tex create mode 100644 macros/latex/contrib/comment/comm_test_l.tex create mode 100644 macros/latex/contrib/comment/comment.pdf create mode 100644 macros/latex/contrib/comment/comment.sty create mode 100644 macros/latex/contrib/comment/comment.tex create mode 100644 macros/latex/contrib/comment/comment_plain.tex create mode 100644 macros/latex/contrib/comment/t1test.pdf create mode 100644 macros/latex/contrib/comment/t1test.tex create mode 100644 macros/latex/contrib/comment/writeup.pdf create mode 100644 macros/latex/contrib/comment/writeup.tex (limited to 'macros/latex/contrib/comment') diff --git a/macros/latex/contrib/comment/Makefile b/macros/latex/contrib/comment/Makefile new file mode 100644 index 0000000000..d405592566 --- /dev/null +++ b/macros/latex/contrib/comment/Makefile @@ -0,0 +1,6 @@ +info : + @echo "there is nothing to make here" +clean : + @/bin/rm -f *~ *.{aux,log,out} *.cut +zip : clean + @cd .. ; zip comment.zip comment/* diff --git a/macros/latex/contrib/comment/README b/macros/latex/contrib/comment/README new file mode 100644 index 0000000000..41ffe8ab84 --- /dev/null +++ b/macros/latex/contrib/comment/README @@ -0,0 +1,7 @@ +Files: +- comment.sty : LaTeX comment style +- comment_plain.tex : plain TeX version, no longer maintained +- comment.{tex,pdf} : description of how the style works + +- comm_test.tex : illustrative test +- t1test.tex : test of T1 non-ascii characters diff --git a/macros/latex/contrib/comment/comm_bug.tex b/macros/latex/contrib/comment/comm_bug.tex new file mode 100644 index 0000000000..f0e8473b04 --- /dev/null +++ b/macros/latex/contrib/comment/comm_bug.tex @@ -0,0 +1,32 @@ +\documentclass[12pt]{article} + +\usepackage{comment} +\excludecomment{conditional} + +\specialcomment{redcomment}{\begingroup\em\Large}{\endgroup\tiny} + +\begin{document} + +plain text. + +\newcommand{\Redcomment}[1]{Original Definition. (#1).} + +\begin{conditional} +Conditional Text. + +More Conditional Text in next paragraph. + +\renewcommand{\Redcomment}[1]{Redefinition Worked! (#1).} +\end{conditional} + +\begin{redcomment} +the first redcomment paragraph. + +the second redcomment paragraph. +\end{redcomment} + +Because redcomment has ended, this should be tiny. + +\Redcomment{This is the command line version.} + +\end{document} diff --git a/macros/latex/contrib/comment/comm_test.pdf b/macros/latex/contrib/comment/comm_test.pdf new file mode 100644 index 0000000000..ecee94c27e Binary files /dev/null and b/macros/latex/contrib/comment/comm_test.pdf differ diff --git a/macros/latex/contrib/comment/comm_test.tex b/macros/latex/contrib/comment/comm_test.tex new file mode 100644 index 0000000000..ec1feb3a51 --- /dev/null +++ b/macros/latex/contrib/comment/comm_test.tex @@ -0,0 +1,97 @@ +% An illustration of comment.sty by Victor Eijkhout, +% version 3.4 and later. +% +\documentclass{article} + +\usepackage{comment} + +\begin{document} + +\includecomment{thisone} +\excludecomment{notthisone} + +This sentence +\begin{comment} +has +\end{comment} +no verb. + +Check for\begin{notthisone} +superfluous +\end{notthisone} +spaces (there should be none between `for' and `spaces'), +and around +\begin{thisone} +inclusion +\end{thisone} +of proper texts (one space between `around' and `inclusion', +and one between `inclusion' and `of'). + +Als check for +\begin{thisone} +multiple paragraphs. + +Such as +\end{thisone} +here. (`Such as' should be a new paragraph.) + +% a test of the special comments +\specialcomment{smallfry}{\begingroup\rmfamily\footnotesize}{\endgroup} +%\tracingmacros=2 \tracingcommands=2 +This text is +\begin{smallfry} +rather small +\end{smallfry} +don't you think? (The `rather small' should be footnotesize.) + +And now we disable +\excludecomment{smallfry} +\begin{smallfry} +the special comment +\end{smallfry} +environment +(in between `disable' and `environment' is some excluded material). + +% test of weird grouping +We switch to +\begin{thisone} +\bf bold face +\end{thisone} +inside \rm a comment. (The phrase `bold face inside' should be bold.) + +\newcount\comlines +\specialcomment{countedcomment} + {\comlines=0\relax \def\ProcessCutFile{}% + \def\ThisComment##1{\global\advance\comlines1\relax}} + {**Comment: \number\comlines\ line(s) removed**} + +This is a line of text +\begin{countedcomment} +Oneline +\end{countedcomment} +another line of text +\begin{countedcomment} +One line +Two line +Three line +\end{countedcomment} +last line of text. + +\specialcomment + {underlinecomment} + {% + \def\ProcessCutFile{\input{\CommentCutFile}\relax}% Bug! this + % should not be necessary. + \def\ThisComment##1{\WriteCommentLine{u: \underline{##1}\par}} + \par + } + {\par} + +A block of two underlined lines in between this line +\begin{underlinecomment} +line 1 +line 2 +\end{underlinecomment} +and before this line. + +\end{document} diff --git a/macros/latex/contrib/comment/comm_test_ivo.tex b/macros/latex/contrib/comment/comm_test_ivo.tex new file mode 100644 index 0000000000..8792052558 --- /dev/null +++ b/macros/latex/contrib/comment/comm_test_ivo.tex @@ -0,0 +1,32 @@ +\documentclass[12pt]{article} + +\usepackage{comment} +\excludecomment{conditional} + +\specialcomment{redcomment}{\em\Large}{\tiny} + +\begin{document} + +plain text. + +\newcommand{\Redcomment}[1]{Original Definition. (#1).} + +\begin{conditional} +Conditional Text. + +More Conditional Text in next paragraph. + +\renewcommand{\Redcomment}[1]{Redefinition Worked! (#1).} +\end{conditional} + +\begin{redcomment} +the first redcomment paragraph. + +the second redcomment paragraph. +\end{redcomment} + +Because redcomment has ended, this should be tiny. + +\Redcomment{This is the command line version.} + +\end{document} diff --git a/macros/latex/contrib/comment/comm_test_l.tex b/macros/latex/contrib/comment/comm_test_l.tex new file mode 100644 index 0000000000..ac9778b176 --- /dev/null +++ b/macros/latex/contrib/comment/comm_test_l.tex @@ -0,0 +1,78 @@ +% An illustration of comment.sty by Victor Eijkhout. +% This file belongs to comment.sty version 3.0 or later, +% it is meant to be used with LaTeX + +\documentstyle[comment]{article} +\begin{document} + +\excludecomment{begone} + +\includecomment{thisone} +\excludecomment{notthisone} + +% under development \leveledcomment{maybethis}{1} + +\parskip=20pt +This sentence +\begin{comment} +has +\end{comment} +no verb. + +Check for\begin{notthisone} +superfluous +\end{notthisone} +spaces, and +\begin{thisone} +inclusion +\end{thisone} +of proper texts. + +% a test of the special comments +\newcount\comlines +\processcomment{countedcomment} + {\comlines=0\relax + \def\ThisComment##1{\global\advance\comlines1\relax}} + {}{\endgraf **Comment: \number\comlines\ line(s) removed**\endgraf} + +This is a line of text +\begin{countedcomment} +Oneline +\end{countedcomment} +another line of text +\begin{countedcomment} +One line +Two line +Three line +\end{countedcomment} +last line of text + +Let's test paragraphs: +\begin{notthisone} +This one is missing. + +As is this one. +\end{notthisone} +For starters. + +On the other hand: +\begin{thisone} +This is one is present. + +As is this one. +\end{thisone} +And that's it. + +\begin{comment} % future project +\maybethis 0 +Level zero. +\endmaybethis +\maybethis 1 +Level one. +\endmaybethis +\maybethis 2 +Level two. +\endmaybethis +\end{comment} + +\end{document} diff --git a/macros/latex/contrib/comment/comment.pdf b/macros/latex/contrib/comment/comment.pdf new file mode 100644 index 0000000000..afd8173246 Binary files /dev/null and b/macros/latex/contrib/comment/comment.pdf differ diff --git a/macros/latex/contrib/comment/comment.sty b/macros/latex/contrib/comment/comment.sty new file mode 100644 index 0000000000..84aa9074e5 --- /dev/null +++ b/macros/latex/contrib/comment/comment.sty @@ -0,0 +1,294 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Comment.sty version 3.8, July 2016 +% copyright 1998-2016 Victor Eijkhout +% +% Purpose: +% selectively in/exclude pieces of text: the user can define new +% comment versions, and each is controlled separately. +% Special comments can be defined where the user specifies the +% action that is to be taken with each comment line. +% +% Author +% Victor Eijkhout +% Texas Advanced Computing Center +% The University of Texas at Austin +% Austin TX 78758 +% USA +% +% victor@eijkhout.net +% +% This program is free software; you can redistribute it and/or +% modify it under the terms of the GNU General Public License +% as published by the Free Software Foundation; either version 2 +% of the License, or (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% For a copy of the GNU General Public License, write to the +% Free Software Foundation, Inc., +% 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA, +% or find it on the net, for instance at +% http://www.gnu.org/copyleft/gpl.html +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Usage: all text included between +% \begin{comment} +% ... +% \end{comment} +% is discarded. +% +% The opening and closing commands should appear on a line +% of their own. No starting spaces, nothing after it. +% This environment should work with arbitrary amounts +% of comment, and the comment can be arbitrary text. +% +% Other `comment' environments are defined by +% and are selected/deselected with +% \includecomment{versiona} +% \excludecoment{versionb} +% +% These environments are used as +% \begin{versiona} ... \end{versiona} +% with the opening and closing commands again on a line of +% their own. +% +% This is not a LaTeX environment: for an included comment, the +% \begin and \end lines act as if they don't exist. +% In particular, they don't imply grouping, so assignments +% &c are not local. +% +%% +%% Guide to special effects +%% +% To understand what happens here, you need to know just a bit about +% the implementation. Lines inside a comment are scooped up one at a +% time, and written to an external file. This file can then be +% included, or ignored. Or you can do stuff with it as you'll see now. +% +% Special comments are defined as +% \specialcomment{name}{before commands}{after commands} +% where the second and third arguments are executed before +% and after each comment block. You can use this for global +% formatting commands. +% To keep definitions &c local, you can include \begingroup +% in the `before commands' and \endgroup in the `after commands'. +% ex: +% \specialcomment{smalltt} +% {\begingroup\ttfamily\footnotesize}{\endgroup} +% Of course, in this case you could probably have used the standard +% LaTeX \newenvironment. +% +% With \specialcomment you do *not* have to do an additional +% \includecomment{smalltt} +% To remove 'smalltt' blocks, give \excludecomment{smalltt} +% after the definition. +% +% The comment environments use two auxiliary commands. You can get +% nifty special effects by redefining them. +% 1/ the commented text is written to an external file. Default definition: +% \def\CommentCutFile{comment.cut} +% 2/ included comments are processed like this: +% \def\ProcessCutFile{\input{\CommentCutFile}\relax} +% and excluded files have +% \def\ProcessCutFile{} +% +% Fun use of special comments: the inclusion of the comment is done +% by \ProcessCutFile, so you can redefine that: +% \specialcomment{mathexamplewithcode} +% {\begingroup\def\ProcessCutFile{}} %1 +% {\verbatiminput{\CommentCutFile} %2 +% \endgroup +% This gives: +% \begin{equation} \input{\CommentCutFile} \end{equation} +% } +% 1: do not standard include the file +% 2: input it verbatim, then again inside display math +% +% You can also apply processing to each line. +% By defining a control sequence +% \def\Thiscomment##1{...} in the before commands the user can +% specify what is to be done with each comment line. If something +% needs to be written to file, use \WriteCommentLine{the stuff} +% Example: +% \specialcomment{underlinecomment} +% {\def\ThisComment##1{\WriteCommentLine{\underline{##1}\par}} +% \par} +% {\par} +% +% Trick for short in/exclude macros (such as \maybe{this snippet}): +%\includecomment{cond} +%\newcommand{\maybe}[1]{} +%\begin{cond} +%\renewcommand{\maybe}[1]{#1} +%\end{cond} +% +% Changes in 3.8 +% - utf8 is now correctly handled, at least if you use eTeX. +% (Thanks Henry Gregory for the solution) +% Changes in 3.7 +% - only LaTeX support from now on +% - code cleanup, and improvements on \specialcomment +% - cleanup of the docs. +% Changed in 3.6 +% - documentation update +% - comment file inclusion is now a customizable command +% Changes in 3.5 +% - corrected typo in header. +% - changed author email +% - corrected \specialcomment yet again. +% - fixed excludecomment of an earlier defined environment. +% Changes in 3.4 +% - added GNU public license +% - added \processcomment, because Ivo's fix (above) brought an +% inconsistency to light. +% Changes in 3.3 +% - updated author's address again +% - parametrised \CommentCutFile +% Changes in 3.2 +% - \specialcomment brought up to date (thanks to Ivo Welch). +% Changes in version 3.1 +% - updated author's address +% - cleaned up some code +% - trailing contents on \begin{env} line is always discarded +% even if you've done \includecomment{env} +% - comments no longer define grouping!! you can even +% \includecomment{env} +% \begin{env} +% \begin{itemize} +% \end{env} +% Isn't that something ... +% - included comments are written to file and input again. +% +% Known bugs: +% - excludecomment leads to one superfluous space +% - processcomment leads to a superfluous line break at the start +% +\def\makeinnocent#1{\catcode`#1=12 } +\def\csarg#1#2{\expandafter#1\csname#2\endcsname} +\def\latexname{lplain}\def\latexename{LaTeX2e} +\newwrite\CommentStream +\def\DefaultCutFileName{\def\CommentCutFile{comment.cut}} +\DefaultCutFileName + +% begin / end processing +% +% this contains the only real begin/endgroup commands, to keep the +% catcode changes local. +\def\ProcessComment#1% start it all of + {\def\CurrentComment{#1}% + \begingroup + \let\do\makeinnocent \dospecials + \makeinnocent\^^L% and whatever other special cases + \endlinechar`\^^M\relax \catcode`\^^M=12\relax \xComment} +{\catcode`\^^M=12 \endlinechar=-1 % + \gdef\xComment#1^^M{\ProcessCommentLine} + \gdef\ProcessCommentLine#1^^M{\def\test{#1} + \csarg\ifx{End\CurrentComment Test}\test + \edef\next{\endgroup\noexpand\EndOfComment{\CurrentComment}}% + \else \ThisComment{#1}\let\next\ProcessCommentLine + \fi \next} +} + +%% +%% Initial action: SetUpCutFile opens the CommentCutFile +%% hook for initial actions: PrepareCutFile, default null +%% +\def\SetUpCutFile + {\immediate\openout\CommentStream=\CommentCutFile + \PrepareCutFile} +\def\PrepareCutFile{} + +%% +%% Each line action: ThisComment, +%% default: WriteCommentLine on line contents +%% version 3.8: write unexpanded if using eTeX +%% +\expandafter\ifx\csname eTeXversion\endcsname\relax + \long\def\WriteCommentLine#1{\immediate\write\CommentStream{#1}} +\else + \long\def\WriteCommentLine#1{\immediate\write\CommentStream{\unexpanded{#1}}} +\fi +\let\ThisComment\WriteCommentLine + +%% +%% Final action: ProcessCutFile +%% hook for final action before file closing: FinalizeCutFile, default null +%% +\def\ProcessCutFile + {\message{Straight input of \CommentCutFile.}% + \input{\CommentCutFile}\relax} +\def\CloseAndInputCutFile + {\FinalizeCutFile + \immediate\closeout\CommentStream + \ProcessCutFile} +\def\FinalizeCutFile{} + +%% +%% Define the different comment types +%% +% included comments: all the default actions +\def\includecomment + #1{\message{Include comment '#1'}% + \csarg\def{After#1Comment}{\CloseAndInputCutFile} + \csarg\def{#1}{\endgroup \message{Including '#1' comment.}% + \DefaultCutFileName \SetUpCutFile \ProcessComment{#1}}% + \CommentEndDef{#1}} +% excluded comment: also default +\def\excludecomment + #1{\message{Excluding comment '#1'}% + \csarg\def{#1}{\endgroup \message{Excluding '#1' comment.}% + \begingroup + \DefaultCutFileName \def\ProcessCutFile{}% + \def\ThisComment####1{}\ProcessComment{#1}}% + \csarg\def{After#1Comment}{\CloseAndInputCutFile \endgroup} + \CommentEndDef{#1}} +% special comment +\long\def\specialcomment + #1#2#3{\message{Special comment '#1'}% + \csarg\def{#1}{\endgroup \message{Processing '#1' comment.}% + \DefaultCutFileName + #2\relax \SetUpCutFile + % #2 before SetUp, so we can do renaming. + \message{Comment '#1' writing to \CommentCutFile.}% + \ProcessComment{#1}}% + \csarg\def{After#1Comment}{\CloseAndInputCutFile #3}% + \CommentEndDef{#1}} +\long\def\generalcomment + #1#2#3{\message{General comment '#1'}% + \csarg\def{#1}{\endgroup % counter the environment open of LaTeX + #2 \relax \SetUpCutFile \ProcessComment{#1}}% + \csarg\def{After#1Comment}{\CloseAndInputCutFile #3}% + \CommentEndDef{#1}} +\long\def\processcomment + #1#2#3#4{\message{Lines-Processing comment '#1'}% + \csarg\def{#1}{\endgroup \SetUpCutFile #2\relax + \ProcessComment{#1}}% + \csarg\def{After#1Comment}{#3\CloseAndInputCutFile #4}% + \CommentEndDef{#1}} +\def\leveledcomment + #1#2{\message{Include comment '#1' up to level '#2'}% + %\csarg\newif{if#1IsStreamingComment} + %\csarg\newif{if#1IsLeveledComment} + %\csname #1IsLeveledCommenttrue\endcsname + \csarg\let{After#1Comment}\CloseAndInputCutFile + \csarg\def{#1}{\SetUpCutFile + \ProcessCommentWithArg{#1}}% + \CommentEndDef{#1}} + +\makeatletter +\def\EndOfComment#1{% + \csname After#1Comment\endcsname + % sabotage LaTeX's environment testing + \begingroup\def\@currenvir{#1}\end{#1}} +\def\CommentEndDef#1{{\escapechar=-1\relax + \csarg\xdef{End#1Test}{\string\\end\string\{#1\string\}}% + }} +\makeatother + +\excludecomment{comment} + +\endinput diff --git a/macros/latex/contrib/comment/comment.tex b/macros/latex/contrib/comment/comment.tex new file mode 100644 index 0000000000..e6f3d5422c --- /dev/null +++ b/macros/latex/contrib/comment/comment.tex @@ -0,0 +1,311 @@ +\documentclass[parskip=false, DIV=8, headings=normal, pagesize=auto]{artikel3}%{scrartcl} + +\usepackage{fixltx2e} +\usepackage{etex} +\usepackage{xspace} +\usepackage{lmodern} +\usepackage[T1]{fontenc} +\usepackage{textcomp} +\usepackage{microtype} +\usepackage[unicode=true]{hyperref} + +\newenvironment*{noverb}{% + \flushleft + \vskip\parskip + \parskip=0pt\relax +}{% + \endflushleft +} + +\newcommand*{\mail}[1]{\href{mailto:#1}{\texttt{#1}}} +\newcommand*{\pkg}[1]{\textsf{#1}} +\newcommand*{\cs}[1]{\texttt{\textbackslash#1}} +\makeatletter +\newcommand*{\cmd}[1]{\cs{\expandafter\@gobble\string#1}} +\makeatother +\newcommand*{\env}[1]{\texttt{#1}} +\newcommand*{\meta}[1]{\textlangle\textsl{#1}\textrangle} +\newcommand*{\marg}[1]{\texttt{\{}\meta{#1}\texttt{\}}} + +%\addtokomafont{title}{\rmfamily} + +\title{The \pkg{comment} package\thanks{This manual corresponds to + \pkg{comment}~v3.8 of July 2016.}} +% +\author{Victor Eijkhout\\\mail{victor@eijkhout.net}} \date{August 2016} + + +\begin{document} + +\maketitle + +\section{Purpose:} + +Selectively in/exclude pieces of text: the user can define new +comment versions, and each is controlled separately. +Special comments can be defined where the user specifies the +action that is to be taken with each comment line. + +Plain \TeX\ support has been phased out. + +As of 3.8 the package will increasingly use e\TeX\ features, for +instance to solve Unicode support issues. + +\section{Usage:} + +The `\env{comment}' environment is defined by default: +all text included between +% +\begin{verbatim} +\begin{comment} + ... +\end{comment} +\end{verbatim} +% +is discarded. + +The opening and closing commands should appear on a line +of their own. No starting spaces, nothing after it. +This environment should work with arbitrary amounts +of comment, and the comment can be arbitrary text. + +Other `\env{comment}' environments are defined by +and are selected/deselected with +% +\begin{verbatim} +\includecomment{versiona} +\excludecoment{versionb} +\end{verbatim} +% +These environments are used as +% +\begin{verbatim} +\begin{versiona} + ... +\end{versiona} +\end{verbatim} +% +with the opening and closing commands again on a line of +their own. + +Note: for an included comment, the +\cmd{\begin} and \cmd{\end} lines act as if they don't exist. +In particular, they don't imply grouping, so assignments +\&c are not local. + +Trick for short in/exclude macros (such as \verb+\maybe{this snippet}+): +% +\begin{verbatim} +\includecomment{cond} +\newcommand{\maybe}[1]{} +\begin{cond} +\renewcommand{\maybe}[1]{#1} +\end{cond} +\end{verbatim} + +\section{Special comments} + +It is possible to make highly customized versions of the comment environment. +Special comments are defined as +% +\begin{noverb} +\cmd{\specialcomment}\marg{name}\marg{before commands}\marg{after commands} +\end{noverb} +% +where the second and third arguments are executed before +and after each comment block. You can use this for global +formatting commands. + +To keep definitions \&c local, you can include \cmd{\begingroup} +in the `\meta{before commands}' and \cmd{\endgroup} in the `\meta{after commands}'. + +Example: +% +\begin{verbatim} +\specialcomment{smalltt} + {\begingroup\ttfamily\footnotesize}{\endgroup} +\end{verbatim} +% +Special comments are automatically included. + +The comment environments use two auxiliary commands. You can get +nifty special effects by redefining them. + +\subsection{The cutfile} + +The commented text is written to an external file, the `cutfile'. Default definition: +\begin{verbatim} + \def\CommentCutFile{comment.cut} +\end{verbatim} + +Included comments are processed like this: +\begin{verbatim} + \def\ProcessCutFile{\input{\CommentCutFile}\relax} +\end{verbatim} + and excluded files have +\begin{verbatim} + \def\ProcessCutFile{} +\end{verbatim} + +\begin{itemize} +\item By redefining the name of the cutfile, the value of the macro + \cmd{CommentCutFile}, it becomes possible to have nested comment environments. +\item If you are writing a textbook, you could have the answers to + exercises in your source, but write them to file rather than + formatting them: +\begin{verbatim} +\generalcomment{answer} + {\begingroup + \edef\tmp{\def\noexpand\CommentCutFile + {answers/\chapshortname-an\noexpand\arabic{excounter}.tex}}\tmp + \def\ProcessCutFile{}} + {\ifIncludeAnswers \begin{quote} + \leavevmode + \hbox{\kern-\unitindent + \textbf Solution to exercise \arabic{chapter}.\arabic{excounter}.\hspace{1em}}% + \ignorespaces\it + \input{\CommentCutFile} + \end{quote}\fi + \endgroup} +\end{verbatim} +\end{itemize} + +\subsection{Comment inclusion} + +The inclusion of the comment is done +by \cmd{\ProcessCutFile}, so you can redefine that: +\begin{verbatim} + \specialcomment + {mathexamplewithcode} + {\begingroup\def\ProcessCutFile{}} % arg1 + {\verbatiminput{\CommentCutFile} % arg2 + \endgroup + This gives: + \begin{equation} \input{\CommentCutFile} \end{equation} + } +\end{verbatim} +The idea here is to disable inclusion of the file, +but include it in the after commands, in display math. + +\subsection{Processing each line} + +You can also apply processing to each line. +By defining a control sequence +\begin{verbatim} + \def\Thiscomment##1{...} +\end{verbatim} +in the before commands the user can +specify what is to be done with each comment line. If something +needs to be written to file, use \verb+\WriteCommentLine{the stuff}+ +Example: +\begin{verbatim} + \specialcomment + {underlinecomment} + {\def\ThisComment##1{\WriteCommentLine{\underline{##1}\par}} + \par} + {\par} +\end{verbatim} + +\subsection{More examples} + +\begin{verbatim} +\newcount\comlines +\specialcomment{countedcomment} + {\comlines=0\relax \def\ProcessCutFile{}% + \def\ThisComment##1{\global\advance\comlines1\relax}} + {**Comment: \number\comlines\ line(s) removed**} +\end{verbatim} + +\begin{verbatim} +\specialcomment + {underlinecomment} + {% + \def\ProcessCutFile{\input{\CommentCutFile}\relax} + \def\ThisComment##1{\WriteCommentLine{u: \underline{##1}\par}} + \par + } + {\par} +\end{verbatim} + +\section{Unicode support} + +Unicode support works if you use e\TeX, which is for instance the case +if you use pdflatex. You need the following lines: +\begin{verbatim} +\usepackage[T1]{fontenc} +\usepackage[utf8]{inputenc} +\end{verbatim} +in your preamble. + +\section{Change log} + +\subsection{Changes in version 3.1} + +\begin{itemize} +\item updated author's address +\item cleaned up some code +\item trailing contents on \cmd{\begin}\marg{env} line is always discarded + even if you've done \cmd{\includecomment}\marg{env} +\item comments no longer define grouping!! you can even + % +\begin{verbatim} +\includecomment{env} +\begin{env} +\begin{itemize} +\end{env} +\end{verbatim} + % + Isn't that something\ldots +\item included comments are written to file and input again. +\end{itemize} + + +\subsection{Changes in 3.2} + +\begin{itemize} +\item \cmd{\specialcomment} brought up to date (thanks to Ivo Welch). +\end{itemize} + + +\subsection{Changes in 3.3} + +\begin{itemize} +\item updated author's address again +\item parametrised \cmd{\CommentCutFile} +\end{itemize} + + +\subsection{Changes in 3.4} + +\begin{itemize} +\item added GNU public license +\item added \cmd{\processcomment}, because Ivo's fix (above) brought an + inconsistency to light. +\end{itemize} + + +\subsection{Changes in 3.5} + +\begin{itemize} +\item corrected typo in header. +\item changed author email +\item corrected \cmd{\specialcomment} yet again. +\item fixed excludecomment of an earlier defined environment. +\end{itemize} + + +\subsection{Changes in 3.6} + +\begin{itemize} +\item The `cut' file is now written more verbatim, using \cmd{\meaning}; + some people reported having trouble with ISO~latin~1, or \texttt{umlaute.sty}. +\item removed some \cmd{\newif} statements. + Has this suddenly become \cmd{\outer} again? +\end{itemize} + + +\subsection{Changes in 3.8} + +T1 font encoding is now supported. See t1test.tex. + +\end{document} diff --git a/macros/latex/contrib/comment/comment_plain.tex b/macros/latex/contrib/comment/comment_plain.tex new file mode 100644 index 0000000000..9470a3e5a4 --- /dev/null +++ b/macros/latex/contrib/comment/comment_plain.tex @@ -0,0 +1,263 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Comment.sty version 3.5, August 1998 +% +% Purpose: +% selectively in/exclude pieces of text: the user can define new +% comment versions, and each is controlled separately. +% Special comments can be defined where the user specifies the +% action that is to be taken with each comment line. +% +% Author +% Victor Eijkhout +% Department of Computer Science +% University of Tennessee +% 107 Ayres Hall +% Knoxville TN 37996 +% USA +% +% victor@eijkhout.net +% +% This program is free software; you can redistribute it and/or +% modify it under the terms of the GNU General Public License +% as published by the Free Software Foundation; either version 2 +% of the License, or (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% For a copy of the GNU General Public License, write to the +% Free Software Foundation, Inc., +% 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA, +% or find it on the net, for instance at +% http://www.gnu.org/copyleft/gpl.html +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% This style can be used with plain TeX or LaTeX, and probably +% most other packages too. +% +% Usage: all text included between +% \comment ... \endcomment +% or \begin{comment} ... \end{comment} +% is discarded. +% +% The opening and closing commands should appear on a line +% of their own. No starting spaces, nothing after it. +% This environment should work with arbitrary amounts +% of comment, and the comment can be arbitrary text. +% +% Other `comment' environments are defined by +% and are selected/deselected with +% \includecomment{versiona} +% \excludecoment{versionb} +% +% These environments are used as +% \versiona ... \endversiona +% or \begin{versiona} ... \end{versiona} +% with the opening and closing commands again on a line of +% their own. +% +% LaTeX users note: for an included comment, the +% \begin and \end lines act as if they don't exist. +% In particular, they don't imply grouping, so assignments +% &c are not local. +% +% Special comments are defined as +% \specialcomment{name}{before commands}{after commands} +% where the second and third arguments are executed before +% and after each comment block. You can use this for global +% formatting commands. +% To keep definitions &c local, you can include \begingroup +% in the `before commands' and \endgroup in the `after commands'. +% ex: +% \specialcomment{smalltt} +% {\begingroup\ttfamily\footnotesize}{\endgroup} +% You do *not* have to do an additional +% \includecomment{smalltt} +% To remove 'smalltt' blocks, give \excludecomment{smalltt} +% after the definition. +% +% Processing comments can apply processing to each line. +% \processcomment{name}{each-line commands}% +% {before commands}{after commands} +% By defining a control sequence +% \def\Thiscomment##1{...} in the before commands the user can +% specify what is to be done with each comment line. +% BUG this does not work quite yet BUG +% +% Trick for short in/exclude macros (such as \maybe{this snippet}): +%\includecomment{cond} +%\newcommand{\maybe}[1]{} +%\begin{cond} +%\renewcommand{\maybe}[1]{#1} +%\end{cond} +% +% Basic approach of the implementation: +% to comment something out, scoop up every line in verbatim mode +% as macro argument, then throw it away. +% For inclusions, in LaTeX the block is written out to +% a file \CommentCutFile (default "comment.cut"), which is +% then included. +% In plain TeX (and other formats) both the opening and +% closing comands are defined as noop. +% +% Changes in version 3.1 +% - updated author's address +% - cleaned up some code +% - trailing contents on \begin{env} line is always discarded +% even if you've done \includecomment{env} +% - comments no longer define grouping!! you can even +% \includecomment{env} +% \begin{env} +% \begin{itemize} +% \end{env} +% Isn't that something ... +% - included comments are written to file and input again. +% Changes in 3.2 +% - \specialcomment brought up to date (thanks to Ivo Welch). +% Changes in 3.3 +% - updated author's address again +% - parametrised \CommentCutFile +% Changes in 3.4 +% - added GNU public license +% - added \processcomment, because Ivo's fix (above) brought an +% inconsistency to light. +% Changes in 3.5 +% - corrected typo in header. +% - changed author email +% - corrected \specialcomment yet again. +% - fixed excludecomment of an earlier defined environment. +% +% Known bugs: +% - excludecomment leads to one superfluous space +% - processcomment leads to a superfluous line break +% +\def\makeinnocent#1{\catcode`#1=12 } +\def\csarg#1#2{\expandafter#1\csname#2\endcsname} +\def\latexname{lplain}\def\latexename{LaTeX2e} +\newwrite\CommentStream +\def\CommentCutFile{comment.cut} + +\def\ProcessComment#1% start it all of + {\begingroup + \def\CurrentComment{#1}% + \let\do\makeinnocent \dospecials + \makeinnocent\^^L% and whatever other special cases + \endlinechar`\^^M \catcode`\^^M=12 \xComment} +%\def\ProcessCommentWithArg#1#2% to be used in \leveledcomment +% {\begingroup +% \def\CurrentComment{#1}% +% \let\do\makeinnocent \dospecials +% \makeinnocent\^^L% and whatever other special cases +% \endlinechar`\^^M \catcode`\^^M=12 \xComment} +{\catcode`\^^M=12 \endlinechar=-1 % + \gdef\xComment#1^^M{% + \expandafter\ProcessCommentLine} + \gdef\ProcessCommentLine#1^^M{\def\test{#1} + \csarg\ifx{End\CurrentComment Test}\test + \edef\next{\noexpand\EndOfComment{\CurrentComment}}% + \else \ThisComment{#1}\let\next\ProcessCommentLine + \fi \next} +} + +% 3.1 change: in LaTeX and LaTeX2e prevent grouping +\if 0% +\ifx\fmtname\latexename + 0% +\else \ifx\fmtname\latexname + 0% + \else + 1% +\fi \fi +%%%% +%%%% definitions for LaTeX +%%%% +\def\AfterIncludedComment + {\immediate\closeout\CommentStream + \input{\CommentCutFile}\relax + }% +\def\TossComment{\immediate\closeout\CommentStream} +\def\WriteCommentLine#1{\immediate\write\CommentStream{#1}} +\def\BeforeIncludedComment + {\immediate\openout\CommentStream=\CommentCutFile + \let\ThisComment\WriteCommentLine} +\def\includecomment + #1{\message{Include comment '#1'}% + \csarg\let{After#1Comment}\AfterIncludedComment + \csarg\def{#1}{\BeforeIncludedComment + \ProcessComment{#1}}% + \CommentEndDef{#1}} +\long\def\specialcomment + #1#2#3{\message{Special comment '#1'}% + % note: \AfterIncludedComment does \input, so #2 goes here! + \csarg\def{After#1Comment}{#2\AfterIncludedComment#3}% + \csarg\def{#1}{\BeforeIncludedComment\relax + \ProcessComment{#1}}% + \CommentEndDef{#1}} +\long\def\processcomment + #1#2#3#4{\message{Lines-Processing comment '#1'}% + \csarg\def{After#1Comment}{#3\AfterIncludedComment#4}% + \csarg\def{#1}{\BeforeIncludedComment#2\relax + \ProcessComment{#1}}% + \CommentEndDef{#1}} +\def\leveledcomment + #1#2{\message{Include comment '#1' up to level '#2'}% + %\csarg\newif{if#1IsStreamingComment} + %\csarg\newif{if#1IsLeveledComment} + %\csname #1IsLeveledCommenttrue\endcsname + \csarg\let{After#1Comment}\AfterIncludedComment + \csarg\def{#1}{\BeforeIncludedComment + \ProcessCommentWithArg{#1}}% + \CommentEndDef{#1}} +\else +%%%% +%%%%plain TeX and other formats +%%%% +\def\includecomment + #1{\message{Including comment '#1'}% + \csarg\def{#1}{}% + \csarg\def{end#1}{}} +\long\def\specialcomment + #1#2#3{\message{Special comment '#1'}% + \csarg\newif{if#1IsStreamingComment} + \csarg\def{#1}{\def\ThisComment{}\def\AfterComment{#3}#2% + \ProcessComment{#1}}% + \CommentEndDef{#1}} +\fi + +%%%% +%%%% general definition of skipped comment +%%%% +\def\excludecomment + #1{\message{Excluding comment '#1'}% + \csarg\def{#1}{\let\AfterComment\relax + \def\ThisComment####1{}\ProcessComment{#1}}% + \csarg\let{After#1Comment}\TossComment + \CommentEndDef{#1}} + +\if 0% +\ifx\fmtname\latexename + 0% +\else \ifx\fmtname\latexname + 0% + \else + 1% +\fi \fi +% latex & latex2e: +\def\EndOfComment#1{\endgroup\end{#1}% + \csname After#1Comment\endcsname} +\def\CommentEndDef#1{{\escapechar=-1\relax + \csarg\xdef{End#1Test}{\string\\end\string\{#1\string\}}% + }} +\else +% plain & other +\def\EndOfComment#1{\endgroup\AfterComment} +\def\CommentEndDef#1{{\escapechar=-1\relax + \csarg\xdef{End#1Test}{\string\\end#1}% + }} +\fi + +\excludecomment{comment} + +\endinput diff --git a/macros/latex/contrib/comment/t1test.pdf b/macros/latex/contrib/comment/t1test.pdf new file mode 100644 index 0000000000..ac188a8c11 Binary files /dev/null and b/macros/latex/contrib/comment/t1test.pdf differ diff --git a/macros/latex/contrib/comment/t1test.tex b/macros/latex/contrib/comment/t1test.tex new file mode 100644 index 0000000000..d06cef454a --- /dev/null +++ b/macros/latex/contrib/comment/t1test.tex @@ -0,0 +1,24 @@ +\documentclass{article} + +\usepackage[T1]{fontenc} +\usepackage[utf8]{inputenc} + +\usepackage{comment} +\includecomment{mention} + +%% set-language-environment UTF-8 + +\begin{document} + +Yes: +\begin{mention} +Ð +\end{mention} +. + +No: +\begin{comment} +Ñ +\end{comment} +. +\end{document} diff --git a/macros/latex/contrib/comment/writeup.pdf b/macros/latex/contrib/comment/writeup.pdf new file mode 100644 index 0000000000..17cfd14f75 Binary files /dev/null and b/macros/latex/contrib/comment/writeup.pdf differ diff --git a/macros/latex/contrib/comment/writeup.tex b/macros/latex/contrib/comment/writeup.tex new file mode 100644 index 0000000000..0519d1f439 --- /dev/null +++ b/macros/latex/contrib/comment/writeup.tex @@ -0,0 +1,244 @@ +\documentclass[parskip=false, DIV=8, headings=normal, pagesize=auto]{scrartcl} + +\usepackage{fixltx2e} +\usepackage{etex} +\usepackage{xspace} +\usepackage{lmodern} +\usepackage[T1]{fontenc} +\usepackage{textcomp} +\usepackage{microtype} +\usepackage[unicode=true]{hyperref} + +\newenvironment*{noverb}{% + \flushleft + \vskip\parskip + \parskip=0pt\relax +}{% + \endflushleft +} + +\newcommand*{\mail}[1]{\href{mailto:#1}{\texttt{#1}}} +\newcommand*{\pkg}[1]{\textsf{#1}} +\newcommand*{\cs}[1]{\texttt{\textbackslash#1}} +\makeatletter +\newcommand*{\cmd}[1]{\cs{\expandafter\@gobble\string#1}} +\makeatother +\newcommand*{\env}[1]{\texttt{#1}} +\newcommand*{\meta}[1]{\textlangle\textsl{#1}\textrangle} +\newcommand*{\marg}[1]{\texttt{\{}\meta{#1}\texttt{\}}} + +\addtokomafont{title}{\rmfamily} + +\title{The \pkg{comment} package\thanks{This manual corresponds to + \pkg{comment}~v3.8 of July 2016.}} +% +\author{Victor Eijkhout\\\mail{victor@eijkhout.net}} \date{August 2016} + + +\begin{document} + +\maketitle + +\section{Purpose:} + +Selectively in/exclude pieces of text: the user can define new +comment versions, and each is controlled separately. +Special comments can be defined where the user specifies the +action that is to be taken with each comment line. + +Plain \TeX\ support has been phased out. + +As of 3.8 the package will increasingly use e\TeX\ features, for +instance to solve Unicode support issues. + +\section{Usage:} + +All text included between +% +\begin{verbatim} +\begin{comment} + ... +\end{comment} +\end{verbatim} +% +is discarded. + +The opening and closing commands should appear on a line +of their own. No starting spaces, nothing after it. +This environment should work with arbitrary amounts +of comment, and the comment can be arbitrary text. + +Other `\env{comment}' environments are defined by +and are selected/deselected with +% +\begin{verbatim} +\includecomment{versiona} +\excludecoment{versionb} +\end{verbatim} +% +These environments are used as +% +\begin{verbatim} +\versiona ... \endversiona +\end{verbatim} +% +or +% +\begin{verbatim} +\begin{versiona} ... \end{versiona} +\end{verbatim} +% +with the opening and closing commands again on a line of +their own. + +\pagebreak[1] + +\LaTeX\ users note: for an included comment, the +\cmd{\begin} and \cmd{\end} lines act as if they don't exist. +In particular, they don't imply grouping, so assignments +\&c are not local. + +\pagebreak[2] + +Special comments are defined as +% +\begin{noverb} +\cmd{\specialcomment}\marg{name}\marg{before commands}\marg{after commands} +\end{noverb} +% +where the second and third arguments are executed before +and after each comment block. You can use this for global +formatting commands. +To keep definitions \&c local, you can include \cmd{\begingroup} +in the `\meta{before commands}' and \cmd{\endgroup} in the `\meta{after commands}'. +ex: +% +\begin{verbatim} +\specialcomment{smalltt} + {\begingroup\ttfamily\footnotesize}{\endgroup} +\end{verbatim} +% +You do \emph{not} have to do an additional +% +\begin{verbatim} +\includecomment{smalltt} +\end{verbatim} +% +To remove `\env{smalltt}' blocks, give \verb+\excludecomment{smalltt}+ +after the definition. + +Processing comments can apply processing to each line. +% +\begin{noverb} +\cmd{\processcomment}\marg{name}\marg{each-line commands}\marg{before commands}\marg{after commands} +\end{noverb} +% +By defining a control sequence +% +\begin{verbatim} +\def\Thiscomment##1{...} +\end{verbatim} +% +in the before commands the user can +specify what is to be done with each comment line. +BUG this does not work quite yet BUG + +Trick for short in/exclude macros (such as \verb+\maybe{this snippet}+): +% +\begin{verbatim} +\includecomment{cond} +\newcommand{\maybe}[1]{} +\begin{cond} +\renewcommand{\maybe}[1]{#1} +\end{cond} +\end{verbatim} + + +\section{Basic approach of the implementation:} + +to comment something out, scoop up every line in verbatim mode +as macro argument, then throw it away. +For inclusions, in \LaTeX\ the block is written out to +a file \cmd{\CommentCutFile} (default ``\texttt{comment.cut}''), which is +then included. +In plain \TeX\ (and other formats) both the opening and +closing comands are defined as noop. + + +\section{Changes in version 3.1} + +\begin{itemize} +\item updated author's address +\item cleaned up some code +\item trailing contents on \cmd{\begin}\marg{env} line is always discarded + even if you've done \cmd{\includecomment}\marg{env} +\item comments no longer define grouping!! you can even + % +\begin{verbatim} +\includecomment{env} +\begin{env} +\begin{itemize} +\end{env} +\end{verbatim} + % + Isn't that something\ldots +\item included comments are written to file and input again. +\end{itemize} + + +\section{Changes in 3.2} + +\begin{itemize} +\item \cmd{\specialcomment} brought up to date (thanks to Ivo Welch). +\end{itemize} + + +\section{Changes in 3.3} + +\begin{itemize} +\item updated author's address again +\item parametrised \cmd{\CommentCutFile} +\end{itemize} + + +\section{Changes in 3.4} + +\begin{itemize} +\item added GNU public license +\item added \cmd{\processcomment}, because Ivo's fix (above) brought an + inconsistency to light. +\end{itemize} + + +\section{Changes in 3.5} + +\begin{itemize} +\item corrected typo in header. +\item changed author email +\item corrected \cmd{\specialcomment} yet again. +\item fixed excludecomment of an earlier defined environment. +\end{itemize} + + +\section{Changes in 3.6} + +\begin{itemize} +\item The `cut' file is now written more verbatim, using \cmd{\meaning}; + some people reported having trouble with ISO~latin~1, or \texttt{umlaute.sty}. +\item removed some \cmd{\newif} statements. + Has this suddenly become \cmd{\outer} again? +\end{itemize} + + +\section{Changes in 3.8} + +T1 font encoding is now supported. See t1test.tex. + +%% \section{Known bugs:} + +%% \begin{itemize} +%% \item \texttt{excludecomment} leads to one superfluous space +%% \item \texttt{processcomment} leads to a superfluous line break +%% \end{itemize} + +\end{document} -- cgit v1.2.3