Debian Codegraph @

texmf-dist/source/latex/commedit/commedit.dtx

raw
1 % \iffalse
2 %
3 %% Copyright 2018-2019, Boris Veytsman <[email protected]>
4 %% This work may be distributed and/or modified under the
5 %% conditions of the LaTeX Project Public License, either
6 %% version 1.3 of this license or (at your option) any
7 %% later version.
8 %% The latest version of the license is in
9 %% http://www.latex-project.org/lppl.txt
10 %% and version 1.3 or later is part of all distributions of
11 %% LaTeX version 2003/06/01 or later.
12 %%
13 %% This work has the LPPL maintenance status `maintained'.
14 %%
15 %% The Current Maintainer of this work is Boris Veytsman
16 %%
17 % \begin{macrocode}
18 %<style>\NeedsTeXFormat{LaTeX2e}
19 %<*gobble>
20 \ProvidesFile{commedit.dtx}
21 %</gobble>
22 %<style>\ProvidesPackage{commedit}
23 %<*style>
24 [2019/01/21 v1.02 Commented editions with LaTeX]
25 % \end{macrocode}
26 %</style>
27 %<*gobble>
28 % \fi
29 % \CheckSum{0}
30 %
31 %
32 %% \CharacterTable
33 %% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
34 %% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
35 %% Digits \0\1\2\3\4\5\6\7\8\9
36 %% Exclamation \! Double quote \" Hash (number) \#
37 %% Dollar \$ Percent \% Ampersand \&
38 %% Acute accent \' Left paren \( Right paren \)
39 %% Asterisk \* Plus \+ Comma \,
40 %% Minus \- Point \. Solidus \/
41 %% Colon \: Semicolon \; Less than \<
42 %% Equals \= Greater than \> Question mark \?
43 %% Commercial at \@ Left bracket \[ Backslash \\
44 %% Right bracket \] Circumflex \^ Underscore \_
45 %% Grave accent \` Left brace \{ Vertical bar \|
46 %% Right brace \} Tilde \~}
47 %
48 %\iffalse
49 % \begin{macrocode}
50 \documentclass{ltxdoc}
51 \usepackage{hypdoc}
52 \usepackage{tikz}
53 \PageIndex
54 \CodelineIndex
55 \RecordChanges
56 \EnableCrossrefs
57 \begin{document}
58 \DocInput{commedit.dtx}
59 \end{document}
60 % \end{macrocode}
61 %</gobble>
62 % \fi
63 % \MakeShortVerb{|}
64 % \GetFileInfo{commedit.dtx}
65 %
66 %
67 % \title{Creating commented editions\thanks{\copyright 2018--2019
68 % Boris Veytsman}
69 % \thanks{This package was commissined by Instituto de Matem\'atica
70 % Pura e Aplicada, \url{https://impa.br}}}
71 % \author{Boris Veytsman \thanks{[email protected]}}
72 % \date{\filedate, \fileversion}
73 % \maketitle
74 %
75 % \begin{abstract}
76 % The \textsl{commedit} package is intended to typeset commented editions.
77 % \end{abstract}
78 %
79 % \tableofcontents
80 %
81 % \clearpage
82 %
83 %\section{Introduction}
84 %\label{sec:intro}
85 %
86 % This package is intended for commented editions. An example of
87 % commented edition is a teacher's book based on a student's
88 % textbook. Each page of a teacher's book is a page from the textbook
89 % \emph{and} comments for the teacher.
90 %
91 % \begin{figure}
92 % \centering
93 % \begin{tikzpicture}
94 % \draw (0,0) rectangle node {Comments} (2,8);
95 % \draw (2.2, 2) rectangle node {Base page} (6.4, 8);
96 % \draw (2.2, 0) rectangle node {Comments} (4.2, 1.8);
97 % \draw (4.4, 0) rectangle node {Comments} (6.4, 1.8);
98 % \end{tikzpicture}
99 % \caption{A page of a commented edition. This page has one
100 % ``tall'' and two ``short'' columns.}
101 % \label{fig:commented_edition}
102 % \end{figure}
103 %
104 % The aim is to have a single source for two books: the ``base''
105 % edition and the commented edition, which reproduces the pages from
106 % the base one and adds comments around it (see
107 % Figure~\ref{fig:commented_edition}). In fact, commented edition can
108 % have both base pages with comments, and ``normal'' pages with free
109 % text.
110 %
111 % The implementation of this idea is the following. We insert into
112 % the base file comments in the form
113 % \begin{verbatim}
114 % \begin{commeditComments}
115 % ...
116 % \end{commeditComments}
117 % \end{verbatim}
118 %
119 % Processing the base source gives us the base PDF file \emph{and} the
120 % commented edition \path{.tex} file. Processing the latter gives us
121 % the commented edition.
122 %
123 % During the processing the base PDF file must be present,
124 % since the commented edition uses it to extract the pages to include
125 % into the output. You also need the base AUX file to process the
126 % labels in the base documents.
127 %
128 %
129 %\section{User manual}
130 %\label{sec:user_manual}
131 %
132 %
133 %\subsection{Document structure}
134 %\label{sec:ug_structure}
135 %
136 %
137 %
138 % \begin{figure}
139 % \centering
140 % \begin{verbatim}
141 % \documentclass... % Document class for the main edition
142 % ...
143 % \usepackage{commedit}
144 % \begin{commeditPreamble}{filename}
145 % \documentclass... % Document class for the main edition
146 % \usepackage{commedit}
147 % Preamble for commented edition
148 % \end{commeditPreamble}
149 % ...
150 % \begin{document}
151 %
152 % \begin{commeditText}
153 % Text for the commented edition
154 % \end{commeditText}
155 %
156 % Base text
157 % Base text
158 % ...
159 % \begin{commeditComments}
160 % Comments text
161 % \end{commeditComments}
162 % Base text
163 % ....
164 % \begin{commeditComments}
165 % Comments text
166 % \end{commeditComments}
167 % Base text
168 % ....
169 % \begin{comments}
170 % Comments text
171 % \end{comments}
172 % Base text
173 % ....
174 % \begin{commeditText}
175 % Text for the commented edition
176 % \end{commeditText}
177 % Base test
178 % \end{document}
179 % \end{verbatim}
180 % \caption{Structure of the main source file}
181 % \label{fig:source}
182 % \end{figure}
183 %
184 % The structure of the main source file is shown on
185 % Figure~\ref{fig:source}. It has three kinds of special
186 % environments:
187 % \begin{enumerate}
188 % \item Exactly one \texttt{commeditPreamble}
189 % environment in the preamble.
190 % \item Zero or more \texttt{commeditText} environments anywhere
191 % \emph{after} \texttt{commeditPreamble}.
192 % \item Zero or more \texttt{commeditComments} environments anywhere
193 % \emph{after} \texttt{commeditPreamble}.
194 % \end{enumerate}
195 % Below we discuss there environments in detail.
196 %
197 %
198 %\subsection{Setting up commenting edition}
199 %\label{sec:ug_setup}
200 %
201 %
202 %
203 % \DescribeEnv{commeditPreamble}%
204 % The environment \cs{begin\{commeditPreamble\}}\marg{filename} \ldots
205 % \cs{end\{commeditPreamble\}} must be present in the preamble of the
206 % base document. It has one mandatory argument, the name of the
207 % commented edition file. The contents of the environment are written
208 % as the preamble of the file \path{filename.tex}, so they must start
209 % with \cs{documentclass}, which might be different from the document
210 % class of the base edition. \texttt{commeditPreamble} may add
211 % additional packages. Note that commented edition reads the
212 % \texttt{.aux} file of the base edition. Since packages like
213 % \textsl{babel} or \textsl{hyperref} change the format of this file,
214 % their usage must be the same in the base and commented edition:
215 % either both editions use such package, or both do not use it.
216 %
217 % The following commands are recognized in this environment.
218 %
219 %
220 %
221 % \DescribeMacro{\commentscolskip}%
222 % The length \cs{commentscolskip} is the distance between comment
223 % columns. By default 6\,mm.
224 %
225 % \DescribeMacro{\commentscolwidth}%
226 % The length \cs{commentscolwidth} is the width of the comment
227 % columns. By default 55.5\,mm.
228 %
229 %
230 % \DescribeMacro{\commentscolTheight}%
231 % \DescribeMacro{\commentscolSheight}%
232 % The lengths \cs{commentscolTheight} and \cs{commentscolSheight} are
233 % the heights of ``tall'' and ``short'' comment columns (see
234 % Figre~\ref{fig:commented_edition}. By default 256\,mm and 58\,mm.
235 %
236 % \DescribeMacro{\basepageboxwidth}%
237 % The width of the box with the base page is \cs{basepageboxwidth}.
238 % The height of the box is \cs{commentscolTheight}. The base page is
239 % aligned with the top left point of this box. By default 153\,mm.
240 %
241 % \DescribeMacro{\basepageargs}%
242 % The base pages are included with \cs{includegraphics} command.
243 % \cs{basepageargs} can be used to set up arguments of this command,
244 % for example, if you want to scale the pages,
245 % \begin{verbatim}
246 % \basepageargs{width=153 mm, height=100mm}
247 % \end{verbatim}
248 %
249 %
250 % \DescribeMacro{\commentsOddPageSetup}%
251 % \DescribeMacro{\commentsEvenPageSetup}%
252 % The setup of the pages is set by the macros
253 % \cs{commentsOddPageSetup}\marg{Number of left tall
254 % columns}\marg{Number of short columns}\marg{Number of right tall
255 % columns} and \cs{commentsEvenPageSetup}\marg{Number of left tall
256 % columns}\marg{Number of short columns}\marg{Number of right tall
257 % columns}. The defaults are
258 % \begin{verbatim}
259 % \commentsOddPageSetup{0}{2}{1}
260 % \commentsEvenPageSetup{1}{2}{0}
261 % \end{verbatim}
262 %
263 % \DescribeMacro{\commentsContinuationPageSetup}%
264 % If comments overflow the the base edition pages, they continue on
265 % \emph{continuation pages.} The command
266 % \cs{commentsContinuationPageSetup}\marg{number of columns} sets up
267 % the number of columns for these pages (by default 3).
268 %
269 % \DescribeMacro{\commentsHook}%
270 % A hook executed for all comments pages, for example
271 % \begin{verbatim}
272 % \commentsHook{\small\normalfont}
273 % \end{verbatim}
274 %
275 %
276 % The environemnt must \emph{not} include the \cs{begin{document}}
277 % line since it is added, along with some technical stuff, by the
278 % package itself.
279 %
280 % \DescribeMacro{\commentsraggedbottom}%
281 % \DescribeMacro{\commentsflushbottom}%
282 % The commands \cs{commentsraggedbottom} and \cs{commentsflushbottom}
283 % produce either columns of comments with no stretchability, or with
284 % aligned last lines. The default is \cs{commentsraggedbottom}.
285 %
286 %
287 %\subsection{Commented pages}
288 %\label{sec:ug_commeditComments}
289 %
290 % \DescribeEnv{commeditComments}%
291 % The enivronment \texttt{commeditComments} sets up comments for the
292 % page of the base edition. There could be several such environments
293 % on the given base edition page---actually, since in \TeX\ pagination
294 % is done algorithmically, one cannot determine beforehand how many of
295 % them are there.
296 %
297 %
298 %\subsection{Normal pages}
299 %\label{sec:ug_commeditText}
300 %
301 % \DescribeEnv{commeditText}%
302 % Normal pages in the commented edition are set up with the
303 % environment \texttt{commeditText}. Note that setting up normal
304 % pages can begin only if the comments for the current page are
305 % flushed. Therefore \texttt{commeditText} inserts \cs{clearpage}
306 % into the base edition.
307 %
308 %
309 %
310 %\subsection{Floats and other \TeX nicalities}
311 %\label{sec:floats}
312 %
313 % In the commented edition the normal \LaTeX\ output routine is
314 % changed. This means that a number of familiar \LaTeX\ features do
315 % not work or work differently from the way one used to.
316 %
317 % \DescribeEnv{figure}%
318 % \DescribeEnv{table}%
319 % On the comments pages only one column floats are allowed, and
320 % these actually do not float: they are output where they are
321 % introduced (as if they were using \texttt{h!} specifier).
322 %
323 % \DescribeMacro{\marginpar}%
324 % You cannot use \cs{marginpar} commands for pages with
325 % comments. You still can use them with the ``normal pages'',
326 % however.
327 %
328 % \DescribeMacro{\footnote}
329 % All footnotes for the commented pages are printed at the end of
330 % the commented pages.
331 %
332 % \DescribeMacro{\pagebreak}%
333 % \DescribeMacro{\newpage}%
334 % \DescribeMacro{\clearpage}%
335 % Page breaking commands start new columns instead of new pages.
336 %
337 %
338 %\StopEventually{\clearpage}
339 %
340 % \clearpage
341 %
342 % \section{Implementation}
343 % \label{sec:implementation}
344 % \begin{macrocode}
345 %<*style>
346 % \end{macrocode}
347 %
348 %
349 %\subsection{Base file commands}
350 %\label{sec:base}
351 %
352 % \begin{macro}{\ifCommentedEdition}
353 % Whether this is a base or commented edition.
354 % \begin{macrocode}
355 \newif\ifCommentedEdition
356 \CommentedEditionfalse
357 % \end{macrocode}
358 %
359 % \end{macro}
360 %
361 % \begin{macro}{\@commeditout}
362 % \changes{v1.01}{2019/01/03}{Added last page at the end of document}
363 % The file to write the the data to
364 % \begin{macrocode}
365 \newwrite\@commeditout
366 \AtEndDocument{\ifCommentedEdition\else
367 \cleardoublepage
368 \immediate\write\@commeditout{\string\end{commentsBox}}%
369 \immediate\write\@commeditout{\string\end{document}}%
370 \closeout\@commeditout
371 \fi}
372 % \end{macrocode}
373 % \end{macro}
374 %
375 %
376 %
377 %
378 % \begin{macro}{\@write@comments}
379 % \changes{v1.01}{2019/01/03}{Moved to \cs{protected@write}}
380 % The workhorse. Mainly from Scott Pakin's \texttt{filecontents}
381 % package and \LaTeX\ kernel. The commments are from them.
382 % \begin{macrocode}
383 \begingroup%
384 \@tempcnta=1
385 \loop
386 \catcode\@tempcnta=12 %
387 \advance\@tempcnta\@ne %
388 \ifnum\@tempcnta<32 %
389 \repeat %
390 \catcode`\*=11 %
391 \catcode`\^^M\active%
392 \catcode`\^^L\active\let^^L\relax%
393 \catcode`\^^I\active%
394 \gdef\@write@comments{%
395 \let\do\@makeother\dospecials%
396 % \end{macrocode}
397 % If there are active characters in the upper half (e.g., from
398 % \texttt{inputenc} there would be confusion so we render everything
399 % harmless.
400 % \begin{macrocode}
401 \count@ 128\relax%
402 \loop%
403 \catcode\count@ 11\relax%
404 \advance\count@ \@ne%
405 \ifnum\count@<\@cclvi%
406 \repeat%
407 \edef\E{\@backslashchar end\string{\@currenvir\string}}%
408 \edef\reserved@b{%
409 \def\noexpand\reserved@b%
410 ####1\E####2\E####3\relax}%
411 \reserved@b{%
412 \ifx\relax##3\relax%
413 % \end{macrocode}
414 % There was no |\end{filecontents}|
415 % \begin{macrocode}
416 \write\@commeditout{##1}%
417 \else%
418 % \end{macrocode}
419 % There was a |\end{filecontents}|, so stop this time.
420 % \begin{macrocode}
421 \edef^^M{\noexpand\end{\@currenvir}}%
422 \ifx\relax##1\relax%
423 \else%
424 % \end{macrocode}
425 % Text before the |\end|, write it with a warning.
426 % \begin{macrocode}
427 \@latex@warning{Writing text `##1' before %
428 \string\end{\@currenvir}\MessageBreak as last line of \@currenvir}%
429 \write\@commeditout{##1}%
430 \fi%
431 \ifx\relax##2\relax%
432 \else%
433 % \end{macrocode}
434 % Text after the |\end|, ignore it with a warning.
435 % \begin{macrocode}
436 \@latex@warning{%
437 Ignoring text `##2' after \string\end{\@currenvir}}%
438 \fi%
439 \fi%
440 ^^M}%
441 % \end{macrocode}
442 %
443 % \begin{macrocode}
444 \catcode`\^^L\active%
445 \let\L\@undefined%
446 \def^^L{\@ifundefined L^^J^^J^^J}%
447 \catcode`\^^I\active%
448 \let\I\@undefined%
449 \def^^I{\@ifundefined I\space\space}%
450 \catcode`\^^M\active%
451 \edef^^M##1^^M{%
452 \noexpand\reserved@b##1\E\E\relax}}%
453 \endgroup%
454 % \end{macrocode}
455 %
456 %
457 % \end{macro}
458 %
459 % \begin{macro}{\immediate@write@commments}
460 % \changes{v1.01}{2019/01/03}{Added macro}
461 % The version of \cs{@write@comments}, which does not wait till the
462 % end of page
463 % \begin{macrocode}
464 \begingroup%
465 \@tempcnta=1
466 \loop
467 \catcode\@tempcnta=12 %
468 \advance\@tempcnta\@ne %
469 \ifnum\@tempcnta<32 %
470 \repeat %
471 \catcode`\*=11 %
472 \catcode`\^^M\active%
473 \catcode`\^^L\active\let^^L\relax%
474 \catcode`\^^I\active%
475 \gdef\immediate@write@comments{%
476 \let\do\@makeother\dospecials%
477 % \end{macrocode}
478 % If there are active characters in the upper half (e.g., from
479 % \texttt{inputenc} there would be confusion so we render everything
480 % harmless.
481 % \begin{macrocode}
482 \count@ 128\relax%
483 \loop%
484 \catcode\count@ 11\relax%
485 \advance\count@ \@ne%
486 \ifnum\count@<\@cclvi%
487 \repeat%
488 \edef\E{\@backslashchar end\string{\@currenvir\string}}%
489 \edef\reserved@b{%
490 \def\noexpand\reserved@b%
491 ####1\E####2\E####3\relax}%
492 \reserved@b{%
493 \ifx\relax##3\relax%
494 % \end{macrocode}
495 % There was no |\end{filecontents}|
496 % \begin{macrocode}
497 \immediate\write\@commeditout{##1}%
498 \else%
499 % \end{macrocode}
500 % There was a |\end{filecontents}|, so stop this time.
501 % \begin{macrocode}
502 \edef^^M{\noexpand\end{\@currenvir}}%
503 \ifx\relax##1\relax%
504 \else%
505 % \end{macrocode}
506 % Text before the |\end|, write it with a warning.
507 % \begin{macrocode}
508 \@latex@warning{Writing text `##1' before %
509 \string\end{\@currenvir}\MessageBreak as last line of \@currenvir}%
510 \immediate\write\@commeditout{##1}%
511 \fi%
512 \ifx\relax##2\relax%
513 \else%
514 % \end{macrocode}
515 % Text after the |\end|, ignore it with a warning.
516 % \begin{macrocode}
517 \@latex@warning{%
518 Ignoring text `##2' after \string\end{\@currenvir}}%
519 \fi%
520 \fi%
521 ^^M}%
522 % \end{macrocode}
523 %
524 % \begin{macrocode}
525 \catcode`\^^L\active%
526 \let\L\@undefined%
527 \def^^L{\@ifundefined L^^J^^J^^J}%
528 \catcode`\^^I\active%
529 \let\I\@undefined%
530 \def^^I{\@ifundefined I\space\space}%
531 \catcode`\^^M\active%
532 \edef^^M##1^^M{%
533 \noexpand\reserved@b##1\E\E\relax}}%
534 \endgroup%
535 % \end{macrocode}
536 % \end{macro}
537 %
538 % \begin{macro}{\commeditPreamble}
539 % \changes{v1.01}{2019/01/03}{Moved to \cs{immediate@write@comments}}
540 % Writing the preamble
541 % \begin{macrocode}
542 \def\commeditPreamble#1{\immediate\closeout\@commeditout
543 \immediate\openout\@commeditout=#1
544 \immediate@write@comments}
545 % \end{macrocode}
546 % \end{macro}
547 %
548 % \begin{macro}{\endcommeditPreamble}
549 % Close the preamble
550 % \begin{macrocode}
551 \def\endcommeditPreamble{%
552 \immediate\write\@commeditout{\string\usepackage{commedit}}%
553 \immediate\write\@commeditout{\string\CommentedEditiontrue}%
554 \immediate\write\@commeditout{\string\def\string\BaseEditionName{\jobname}}%
555 \immediate\write\@commeditout{\string\usepackage{graphicx}}%
556 \immediate\write\@commeditout{\string\usepackage[strict]{changepage}}%
557 \immediate\write\@commeditout{\string\begin{document}}%
558 \immediate\write\@commeditout{\string\begin{commentsBox}}}
559 % \end{macrocode}
560 %
561 % \end{macro}
562 %
563 %
564 % \begin{macro}{\commeditComments}
565 % The main environment
566 % \begin{macrocode}
567 \def\commeditComments{\@write@comments}
568 % \end{macrocode}
569 %
570 % \end{macro}
571 %
572 %
573 % \begin{macro}{\endcommeditComments}
574 % We add \cs{par} at the end of each comments
575 % \begin{macrocode}
576 \def\endcommeditComments{%
577 \write\@commeditout{\string\par}}
578 % \end{macrocode}
579 %
580 %
581 % \end{macro}
582 %
583 % \begin{macro}{\commeditText}
584 % Normal pages. We issue \cs{clearpage}, which might close the
585 % current comments and open the new one, close the just opened
586 % comments, typeset the text in the commented edition and reopen the
587 % comments.
588 % \begin{macrocode}
589 \def\commeditText{\clearpage
590 \immediate\write\@commeditout{\string\end{commentsBox}}%
591 \immediate@write@comments}
592 % \end{macrocode}
593 %
594 % \end{macro}
595 %
596 % \begin{macro}{\endcommeditText}
597 % Opening the new comments page
598 % \begin{macrocode}
599 \def\endcommeditText{%
600 \immediate\write\@commeditout{\string\par}%
601 \immediate\write\@commeditout{\string\begin{commentsBox}}}
602 % \end{macrocode}
603 %
604 % \end{macro}
605 %
606 % \begin{macro}{\commedit@base@pageno}
607 % The true page number of the current page
608 % \begin{macrocode}
609 \newcount\@commedit@base@pageno
610 \@commedit@base@pageno=1\relax
611 % \end{macrocode}
612 %
613 % \end{macro}
614 %
615 % We write the commands to every shipout. First, we need a package.
616 % |atbegshi| is more powerful, but for our purpose |everyshi| is fine.
617 % \begin{macrocode}
618 \RequirePackage{everyshi}
619 % \end{macrocode}
620 % We need to patch this package, however, since we want to execute the
621 % hook \emph{after} shipout!
622 %
623 %
624 % \begin{macro}{\@EveryShipoutEnd@Hook}
625 % \changes{v1.01}{2019/01/03}{Added macro}
626 % We define the hook
627 % \begin{macrocode}
628 \newcommand\@EveryShipoutEnd@Hook{\ifCommentedEdition\else
629 \immediate\write\@commeditout{\string\end{commentsBox}}%
630 \immediate\write\@commeditout{\string\typesetComments{\the\@commedit@base@pageno}}%
631 \immediate\write\@commeditout{\string\begin{commentsBox}}%
632 \global\advance\@commedit@base@pageno by 1\relax
633 \fi}
634 % \end{macrocode}
635 % \end{macro}
636 %
637 % \begin{macro}{\@EveryShipout@Output}
638 % \changes{v1.01}{2019/01/03}{Redefined}
639 % And add to the macro
640 % \begin{macrocode}
641 \renewcommand{\@EveryShipout@Output}{%
642 \@EveryShipout@Hook%
643 \@EveryShipout@AtNextHook%
644 \gdef\@EveryShipout@AtNextHook{}%
645 \@EveryShipout@Org@Shipout\box\@cclv\relax
646 \@EveryShipoutEnd@Hook%
647 }
648 % \end{macrocode}
649 %
650 % \end{macro}
651 %
652 %
653 %\subsection{Typesetting commented edition}
654 %\label{sec:commentedEdition}
655 %
656 %
657 %
658 %\subsubsection{Setting things up}
659 %\label{sec:setup_commented_edition}
660 %
661 % We need to read the aux file for the base edition
662 % \begin{macrocode}
663 \RequirePackage{etoolbox}
664 \AtEndPreamble{\ifCommentedEdition
665 \begingroup\@floatplacement\@dblfloatplacement
666 \makeatletter\let\@writefile\@gobbletwo
667 \global \let \@multiplelabels \relax
668 \@input{\BaseEditionName.aux}\endgroup
669 \fi}
670 % \end{macrocode}
671 %
672 %
673 %
674 % \begin{macro}{\commentscolskip}
675 % The distance between columns
676 % \begin{macrocode}
677 \newlength\commentscolskip
678 \setlength\commentscolskip{6mm}
679 % \end{macrocode}
680 %
681 % \end{macro}
682 %
683 % \begin{macro}{\commentscolwidth}
684 % The width of the comments column
685 % \begin{macrocode}
686 \newlength\commentscolwidth
687 \setlength\commentscolwidth{55.5mm}
688 % \end{macrocode}
689 %
690 % \end{macro}
691 %
692 % \begin{macro}{\commentscolTheight}
693 % The height of the ``tall'' columns
694 % \begin{macrocode}
695 \newlength\commentscolTheight
696 \setlength\commentscolTheight{256mm}
697 % \end{macrocode}
698 %
699 % \end{macro}
700 %
701 % \begin{macro}{\commentscolSheight}
702 % The height of the ``short'' columns
703 % \begin{macrocode}
704 \newlength\commentscolSheight
705 \setlength\commentscolSheight{58mm}
706 % \end{macrocode}
707 %
708 % \end{macro}
709 %
710 % \begin{macro}{\basepageboxwidth}
711 % The width of the base page box
712 % \begin{macrocode}
713 \newlength\basepageboxwidth
714 \setlength\basepageboxwidth{153mm}
715 % \end{macrocode}
716 %
717 % \end{macro}
718 %
719 % \begin{macro}{\basepageargs}
720 % Arguments for \cs{includegraphics}
721 % \begin{macrocode}
722 \def\basepageargs#1{\gdef\@basepageargs{#1}}
723 \basepageargs{}
724 % \end{macrocode}
725 %
726 %
727 % \end{macro}
728 %
729 % \begin{macro}{\commentsOddPageSetup}
730 % The odd page structure
731 % \begin{macrocode}
732 \def\commentsOddPageSetup#1#2#3{%
733 \gdef\@commeditOddLeftCols{#1}%
734 \gdef\@commeditOddMiddleCols{#2}%
735 \gdef\@commeditOddRightCols{#3}}
736 \commentsOddPageSetup{0}{2}{1}
737 % \end{macrocode}
738 %
739 % \end{macro}
740 %
741 % \begin{macro}{\commentsEvenPageSetup}
742 % The even page structure
743 % \begin{macrocode}
744 \def\commentsEvenPageSetup#1#2#3{%
745 \gdef\@commeditEvenLeftCols{#1}%
746 \gdef\@commeditEvenMiddleCols{#2}%
747 \gdef\@commeditEvenRightCols{#3}}
748 \commentsEvenPageSetup{1}{2}{0}
749 % \end{macrocode}
750 %
751 % \end{macro}
752 %
753 % \begin{macro}{\commentsContinuationPageSetup}
754 % The number of continuation columns
755 % \begin{macrocode}
756 \def\commentsContinuationPageSetup#1{%
757 \gdef\@commeditContinuationCols{#1}}
758 \commentsContinuationPageSetup{3}
759 % \end{macrocode}
760 %
761 % \end{macro}
762 %
763 % \begin{macro}{\@commentstexttop}
764 % \changes{v1.02}{2019/01/21}{Added macro}
765 % Top of the column
766 % \begin{macrocode}
767 \let\@commentstexttop\relax
768 % \end{macrocode}
769 % \end{macro}
770 %
771 % \begin{macro}{\@commentstextbottom}
772 % \changes{v1.02}{2019/01/21}{Added macro}
773 % Top of the column
774 % \begin{macrocode}
775 \let\@commentstextbottom\relax
776 % \end{macrocode}
777 % \end{macro}
778 %
779 % \begin{macro}{\commentsraggedbottom}
780 % \changes{v1.02}{2019/01/21}{Added macro}
781 % Ragged bottom columns (the default)
782 \def\commentsraggedbottom{%
783 \def\@commentstextbottom{\vskip \z@ \@plus.0001fil}%
784 \let\@commentstexttop\relax}
785 \commentsraggedbottom
786 % \end{macro}
787 %
788 % \begin{macro}{\commentsflushbottom}
789 % \changes{v1.02}{2019/01/21}{Added macro}
790 % Flushed bottom columns
791 \def\commentsflushbottom{%
792 \let\@commentstextbottom\relax
793 \let\@commentstexttop\relax}
794 % \end{macro}
795 %
796 % \begin{macro}{\@tempboxb}
797 % \changes{v1.02}{2019/01/21}{Added macro}
798 % A temp box
799 % \begin{macrocode}
800 \newbox\@tempboxb
801 % \end{macrocode}
802 %
803 % \end{macro}
804 %
805 % \begin{macro}{\commentsHook}
806 % Everything we did not think about\ldots
807 % \begin{macrocode}
808 \def\commentsHook#1{\gdef\@commentsHook{#1}}
809 \commentsHook{}
810 % \end{macrocode}
811 %
812 % \end{macro}
813 %
814 %
815 %
816 %\subsubsection{Gathering comments}
817 %\label{sec:commentsBox}
818 %
819 % \begin{macro}{\@commedit@box}
820 % The box with comments
821 % \begin{macrocode}
822 \newbox\@commedit@box
823 % \end{macrocode}
824 %
825 % \end{macro}
826 %
827 % \begin{macro}{\@commentsfootins}
828 % \changes{v1.02}{2019/01/20}{Added macro}
829 % The box for footnotes in comments
830 % \begin{macrocode}
831 \newbox\@commentsfootins
832 % \end{macrocode}
833 %
834 % \end{macro}
835 %
836 %
837 % \begin{macro}{\@commentsfootnotetext}
838 % \changes{v1.02}{2019/01/20}{Added macro}
839 % The version of \cs{footnotetext} for comments
840 % \begin{macrocode}
841 \long\def\@commentsfootnotetext#1{%
842 \global\setbox\@commentsfootins\vbox{%
843 \unvbox\@commentsfootins
844 \reset@font\footnotesize
845 \hsize\commentscolwidth
846 \@parboxrestore
847 \protected@edef\@currentlabel{%
848 \csname p@footnote\endcsname\@thefnmark
849 }%
850 \color@begingroup
851 \@makefntext{%
852 \rule\z@\footnotesep\ignorespaces#1\@finalstrut\strutbox}%
853 \color@endgroup}}
854 % \end{macrocode}
855 %
856 % \end{macro}
857 %
858 % \begin{macro}{\comments@xfloat}
859 % \changes{v1.02}{2019/01/20}{Added macro}
860 % The version of \cs{@xfloat} inside comments
861 % \begin{macrocode}
862 \def\comments@xfloat#1[#2]{%
863 \@nodocument
864 \def \@captype {#1}%
865 \setbox\@tempboxb
866 \color@vbox
867 \normalcolor
868 \vbox \bgroup
869 \hsize\columnwidth
870 \@parboxrestore
871 \@floatboxreset}
872 % \end{macrocode}
873 %
874 % \end{macro}
875 %
876 % \begin{macro}{\comments@end@float}
877 % \changes{v1.02}{2019/01/20}{Added macro}
878 % We do not move float to the list, but just typeset it in place.
879 % \begin{macrocode}
880 \def\comments@end@float{%
881 \@endfloatbox
882 \vskip \intextsep
883 \box\@tempboxb
884 \penalty\interlinepenalty
885 \vskip\intextsep}
886 % \end{macrocode}
887 %
888 % \end{macro}
889 %
890 % \begin{macro}{\commentsBox}
891 % \changes{v1.02}{2019/01/20}{Added footnotes, floats}
892 % The box of comments
893 % \begin{macrocode}
894 \def\commentsBox{\hsize=\commentscolwidth\global\setbox\@commedit@box=\vbox\bgroup
895 \let\@footnotetext=\@commentsfootnotetext
896 \let\@dblfloat\@float
897 \let\@xfloat=\comments@xfloat
898 \let\end@float\comments@end@float
899 \let\end@dblfloat\comments@end@float
900 \let\columnwidth=\commentscolwidth
901 \normalsize\normalfont
902 \@commentsHook
903 \unvbox\@commedit@box}
904 % \end{macrocode}
905 %
906 % \end{macro}
907 %
908 % \begin{macro}{\endcommentsBox}
909 % Closing the box
910 % \begin{macrocode}
911 \def\endcommentsBox{\egroup}
912 % \end{macrocode}
913 %
914 % \end{macro}
915 %
916 % \begin{macro}{\@commedit@page@box}
917 % The box to hold the page so far with comments
918 % \begin{macrocode}
919 \newbox\@commedit@pagebox
920 % \end{macrocode}
921 %
922 % \end{macro}
923 %
924 %
925 % \begin{macro}{\typesetComments}
926 % \changes{v1.01}{2019/01/03}{Added \cs{vfill} to \cs{@commedit@box}}
927 % \changes{v1.02}{2019/01/20}{Added footnotes to the end of the box}
928 % Typesetting the box of comments
929 % \begin{macrocode}
930 \def\typesetComments#1{\clearpage\bgroup
931 \let\columnwidth=\commentscolwidth
932 \setbox\@commedit@pagebox=\hbox{}\splittopskip=\z@\topskip=\z@
933 \ifvoid\@commentsfootins\else
934 \setbox\@commedit@box=\vbox{\unvbox\@commedit@box
935 \vskip \skip\footins
936 \color@begingroup
937 \normalcolor
938 \footnoterule
939 \unvbox \@commentsfootins
940 \color@endgroup}%
941 \fi
942 \setbox\@commedit@box=\vbox{\unvbox\@commedit@box\vfill}%
943 \checkoddpage\ifoddpage
944 \global\def\@commeditLeftCols{\@commeditOddLeftCols}%
945 \global\def\@commeditMiddleCols{\@commeditOddMiddleCols}%
946 \global\def\@commeditRightCols{\@commeditOddRightCols}%
947 \else
948 \global\def\@commeditLeftCols{\@commeditEvenLeftCols}%
949 \global\def\@commeditMiddleCols{\@commeditEvenMiddleCols}%
950 \global\def\@commeditRightCols{\@commeditEvenRightCols}%
951 \fi
952 \ifnum\@commeditLeftCols>0\relax
953 \@tempcnta=\@commeditLeftCols\relax
954 \loop
955 \setbox\@tempboxb=\vsplit\@commedit@box to
956 \commentscolTheight\relax
957 \setbox\@tempboxb=\vbox to \commentscolTheight{%
958 \@commentstexttop
959 \unvbox\@tempboxb
960 \@commentstextbottom}%
961 \setbox\@commedit@pagebox=\hbox{\noindent\box\@commedit@pagebox
962 \box\@tempboxb
963 \hskip\commentscolskip\relax}%
964 \global\setbox\@commedit@box=\box\@commedit@box
965 \advance\@tempcnta by -1\relax
966 \ifnum\@tempcnta>0\repeat
967 \fi
968 \setbox\@tempboxa=\hbox{}%
969 \ifnum\@commeditMiddleCols>0\relax
970 \@tempcnta=\@commeditMiddleCols\relax
971 \loop
972 \setbox\@tempboxb=\vsplit\@commedit@box to
973 \commentscolSheight\relax
974 \setbox\@tempboxb=\vbox to \commentscolSheight{%
975 \@commentstexttop
976 \unvbox\@tempboxb
977 \@commentstextbottom}%
978 \setbox\@tempboxa=\hbox{\noindent\box\@tempboxa
979 \box\@tempboxb}%
980 \global\setbox\@commedit@box=\box\@commedit@box
981 \advance\@tempcnta by -1\relax
982 \ifnum\@tempcnta>0\relax
983 \setbox\@tempboxa=\hbox{\noindent\box\@tempboxa
984 \hskip\commentscolskip\relax}%
985 \repeat
986 \fi
987 \ifx\@basepageargs\@empty\relax
988 \def\@commedit@args{page=#1}%
989 \else
990 \edef\@commedit@args{page=#1,\@basepageargs}%
991 \fi
992 \hsize=\basepageboxwidth
993 \setbox\@tempboxa=\vbox to \commentscolTheight \bgroup
994 \hbox{\fbox{\noindent\expandafter\includegraphics\expandafter[\@commedit@args]{\BaseEditionName.pdf}}}%
995 \vfill\box\@tempboxa\egroup
996 \setbox\@commedit@pagebox=\hbox{\box\@commedit@pagebox
997 \box\@tempboxa}%
998 \ifnum\@commeditRightCols>0\relax
999 \@tempcnta=\@commeditRightCols\relax
1000 \loop
1001 \setbox\@tempboxb=\vsplit\@commedit@box to
1002 \commentscolTheight\relax
1003 \setbox\@tempboxb=\vbox to \commentscolTheight{%
1004 \@commentstexttop
1005 \unvbox\@tempboxb
1006 \@commentstextbottom}%
1007 \setbox\@commedit@pagebox=\hbox{\noindent\box\@commedit@pagebox
1008 \hskip\commentscolskip\relax
1009 \box\@tempboxb}%
1010 \global\setbox\@commedit@box=\box\@commedit@box
1011 \advance\@tempcnta by -1\relax
1012 \ifnum\@tempcnta>0\repeat
1013 \fi
1014 \noindent\box\@commedit@pagebox\par
1015 \global\setbox\@commedit@box=\box\@commedit@box
1016 \egroup\vfill\clearpage
1017 \ifdim\ht\@commedit@box>\baselineskip
1018 \typesetContinuation\fi}
1019 % \end{macrocode}
1020 %
1021 % \end{macro}
1022 %
1023 % \begin{macro}{\typesetContinuation}
1024 % Continuation boxes
1025 % \begin{macrocode}
1026 \def\typesetContinuation{\clearpage\bgroup
1027 \setbox\@commedit@pagebox=\hbox{}\splittopskip=\z@\relax
1028 \@tempcnta=\@commeditContinuationCols\relax
1029 \loop
1030 \setbox\@tempboxb=\vsplit\@commedit@box to
1031 \commentscolTheight\relax
1032 \setbox\@tempboxb=\vbox to \commentscolTheight{%
1033 \@commentstexttop
1034 \unvbox\@tempboxb
1035 \@commentstextbottom}%
1036 \setbox\@commedit@pagebox=\hbox{\noindent\box\@commedit@pagebox
1037 \box\@tempboxb}%
1038 \global\setbox\@commedit@box=\box\@commedit@box
1039 \advance\@tempcnta by -1\relax
1040 \ifnum\@tempcnta>0\relax
1041 \setbox\@commedit@pagebox=\hbox{\noindent\box\@commedit@pagebox
1042 \hskip\commentscolskip\relax}%
1043 \repeat
1044 \noindent\box\@commedit@pagebox\par
1045 \global\setbox\@commedit@box=\box\@commedit@box
1046 \egroup\vfill\clearpage
1047 \ifdim\ht\@commedit@box>\baselineskip
1048 \typesetContinuation\fi}
1049 % \end{macrocode}
1050 % \end{macro}
1051 %
1052 %
1053 %\subsection{Final incantations}
1054 %\label{sec:final}
1055 %
1056 %
1057 %
1058 % \begin{macrocode}
1059 %</style>
1060 % \end{macrocode}
1061 %\Finale
1062 %\clearpage
1063 %
1064 %\PrintChanges
1065 %\clearpage
1066 %\PrintIndex
1067 %
1068 \endinput