| 1 |
% \iffalse meta-comment |
| 2 |
% |
| 3 |
%% Copyright 1994-2024 (C) Johannes Braams. All rights reserved. |
| 4 |
% |
| 5 |
% This file is part of the changebar package. |
| 6 |
% ------------------------------------------- |
| 7 |
% |
| 8 |
% It may be distributed and/or modified under the |
| 9 |
% conditions of the LaTeX Project Public License, either version 1.3 |
| 10 |
% of this license or (at your option) any later version. |
| 11 |
% The latest version of this license is in |
| 12 |
% http://www.latex-project.org/lppl.txt |
| 13 |
% and version 1.3 or later is part of all distributions of LaTeX |
| 14 |
% version 2003/12/01 or later. |
| 15 |
% |
| 16 |
% This work has the LPPL maintenance status "maintained". |
| 17 |
% |
| 18 |
% The Current Maintainer of this work is Johannes Braams. |
| 19 |
% |
| 20 |
% The list of all files belonging to the changebar package is |
| 21 |
% given in the file `manifest.txt. |
| 22 |
% |
| 23 |
% The list of derived (unpacked) files belonging to the distribution |
| 24 |
% and covered by LPPL is defined by the unpacking scripts (with |
| 25 |
% extension .ins) which are part of the distribution. |
| 26 |
% \fi |
| 27 |
% \CheckSum{2948} |
| 28 |
% |
| 29 |
%\iffalse |
| 30 |
% This file is built for \LaTeXe, so we make sure an error is |
| 31 |
% generated when it is used with another format |
| 32 |
% \begin{macrocode} |
| 33 |
%<+package>\NeedsTeXFormat{LaTeX2e} |
| 34 |
% \end{macrocode} |
| 35 |
% |
| 36 |
% Now announce the package name and its version: |
| 37 |
% \begin{macrocode} |
| 38 |
%<*dtx> |
| 39 |
\ProvidesFile{changebar.dtx} |
| 40 |
%</dtx> |
| 41 |
%<+package>\ProvidesPackage{changebar} |
| 42 |
[2024/07/17 v3.7e Indicate changes with marginal bars] |
| 43 |
% \end{macrocode} |
| 44 |
% |
| 45 |
% \section{A driver for this document} |
| 46 |
% |
| 47 |
% The next bit of code contains the documentation driver file for |
| 48 |
% \TeX{}, i.e., the file that will produce the documentation you |
| 49 |
% are currently reading. It will be extracted from this file by the |
| 50 |
% \textsc{docstrip} program. |
| 51 |
% |
| 52 |
% \begin{macrocode} |
| 53 |
%<*driver> |
| 54 |
\documentclass{ltxdoc} |
| 55 |
\usepackage[pdftex,rightbars,color,traceon,tracestacks]{changebar} |
| 56 |
\cbcolor{red} |
| 57 |
\DoNotIndex{\@@,\@Esphack,\@Mii,\@cons,\@empty,\@gobble} |
| 58 |
\DoNotIndex{\@ifundefined,\@ne,\@spaces,\@whilenum} |
| 59 |
\DoNotIndex{\advance,\begingroup,\bgroup,\egrou,\endgroup} |
| 60 |
\DoNotIndex{\catcode,\chardef,\clearpage,\closein,\closeout} |
| 61 |
\DoNotIndex{\csname,\endcsname,\def,\dimen@,\divide,\do,\dp} |
| 62 |
\DoNotIndex{\edef,\expandafter} |
| 63 |
\DoNotIndex{\gdef,\global} |
| 64 |
\DoNotIndex{\GenericWarning,\hoffset,\ht} |
| 65 |
\DoNotIndex{\ifcase,\or,\fi,\ifdim,\else,\fi,\ifeof,\fi,\ifnum,\fi} |
| 66 |
\DoNotIndex{\ifvmode,\fi,\ifx,\fi,\ignorespaces,\immediate,\InputIfFileExists} |
| 67 |
\DoNotIndex{\jobname,\let,\long,\m@ne,\maxdepth,\MessageBreak} |
| 68 |
\DoNotIndex{\newcommand,\newcount,\newcounter,\newdimen,\newenvironment} |
| 69 |
\DoNotIndex{\newlength,\newread,\newwrite,\next,\noexpand,\normalcolor} |
| 70 |
\DoNotIndex{\openin,\openout,\OptionNotUsed,\p,\PacakgeError} |
| 71 |
\DoNotIndex{\PackageWarning,\point,\ProcessOptions,\read,\relax} |
| 72 |
\DoNotIndex{\RequirePackage,\setbox,\setcounter,\setlength,\space} |
| 73 |
\DoNotIndex{\string,\strutbox,\t,\textwidth,\the,\thr@@,\tw@} |
| 74 |
\DoNotIndex{\unvbox,\uppercase,\vadjust,\vbox,\vskip,\vss,\write,\xdef,\z@} |
| 75 |
% \end{macrocode} |
| 76 |
% We do want an index, using linenumbers |
| 77 |
% \begin{macrocode} |
| 78 |
\EnableCrossrefs |
| 79 |
\CodelineIndex |
| 80 |
% \end{macrocode} |
| 81 |
% This document uses some extra \texttt{doc} style macros. |
| 82 |
% \begin{macrocode} |
| 83 |
\makeatletter |
| 84 |
\def\DescribeVar#1{\leavevmode\@bsphack |
| 85 |
\marginpar{\raggedleft\PrintDescribeEnv{#1}}% |
| 86 |
\SpecialVarUsageIndex{#1}\@esphack\ignorespaces} |
| 87 |
\def\SpecialVarMainIndex#1{\@bsphack |
| 88 |
\index{#1\actualchar\texttt{#1}\encapchar main}% |
| 89 |
\@esphack} |
| 90 |
\def\SpecialVarUsageIndex#1{\@bsphack |
| 91 |
\index{#1\actualchar\texttt{#1}\encapchar usage}% |
| 92 |
\@esphack} |
| 93 |
\let\@SpecialMainIndex\SpecialMainIndex |
| 94 |
\def\Var{\let\SpecialMainIndex\SpecialVarMainIndex\macro} |
| 95 |
\def\endVar{\endmacro\let\SpecialMainIndex\@SpecialMainIndex} |
| 96 |
\makeatother |
| 97 |
% \end{macrocode} |
| 98 |
% Some commonly used abbreviations |
| 99 |
% \begin{macrocode} |
| 100 |
\newcommand{\Lopt}[1]{\textsf {#1}} |
| 101 |
\newcommand{\Lenv}[1]{\textsf {#1}} |
| 102 |
\newcommand{\file}[1]{\texttt {#1}} |
| 103 |
\newcommand{\pkg}[1]{\texttt {#1}} |
| 104 |
\newcommand{\Lcount}[1]{\textsl {\small#1}} |
| 105 |
\newcommand{\pstyle}[1]{\textsl {#1}} |
| 106 |
% \end{macrocode} |
| 107 |
% We also want the full details. |
| 108 |
% \begin{macrocode} |
| 109 |
\begin{document} |
| 110 |
\DocInput{changebar.dtx} |
| 111 |
\end{document} |
| 112 |
%</driver> |
| 113 |
% \end{macrocode} |
| 114 |
%\fi |
| 115 |
% |
| 116 |
% \GetFileInfo{changebar.dtx} |
| 117 |
% |
| 118 |
% \changes{3.1}{1993/07/02}{Removed a number of typos} |
| 119 |
% \changes{3.1a}{1993/08/03}{Uncommented \cs{filedate} and |
| 120 |
% \cs{fileversion}} |
| 121 |
% \changes{3.2}{1994/04/21}{Incorporated Robin Fairbairns suggestions |
| 122 |
% for the upgrade for \LaTeX2e} |
| 123 |
% \changes{3.2a}{1995/03/20}{Fixed bug about cross-page bars} |
| 124 |
% \changes{v3.2b}{1995/06/26}{Removed use of \cs{file...} commands} |
| 125 |
% \changes{v3.2b}{1995/06/26}{Use \LaTeX's Warning mechanisms} |
| 126 |
% \changes{v3.2c}{1996/03/26}{Reinserted \cs{driver} for compatibility |
| 127 |
% reasons} |
| 128 |
% \changes{v3.4e}{2001/09/14}{Store original definitions using the |
| 129 |
% \texttt{ltx} prefix, define own versions with \texttt{cb} prefix, |
| 130 |
% the use \cmd{let} to replace \LaTeX\ macro.} |
| 131 |
% \changes{v3.5a}{2005/05/23}{Piet van Oostrum: Resolved bugs in twocolumn |
| 132 |
% mode, mid-document changes to page number, added pdflatex support.} |
| 133 |
% \changes{v3.6a}{2011/04/30}{Added support for XeTeX provided by |
| 134 |
% Apostolos Syropoulos} |
| 135 |
% \changes{v3.6b}{2018/02/03}{Added a macro for pdf scaling for |
| 136 |
% Xe\TeX} |
| 137 |
% \changes{v3.6e}{2023/08/13}{Added supprt for luaTeX} |
| 138 |
% \changes{v3.7b}{2023/12/28}{Added a few lines that were inadvertantly removed} |
| 139 |
% \changes{v3.7b}{2023/12/30}{the cb2-file use delimiting chars may |
| 140 |
% change meaning when they end up in the wrong situation} |
| 141 |
% \changes{v3.7e}{2024/07/17}{The us of the character `;´ as a string |
| 142 |
% separator clashes with it's active variant when babel/french has |
| 143 |
% been loaded} |
| 144 |
% |
| 145 |
% \title{The Changebar package |
| 146 |
% \thanks{This file has version number \fileversion, |
| 147 |
% last revised \filedate.}} |
| 148 |
% |
| 149 |
% \author{Michael Fine\\Distributed Systems Architecture \and |
| 150 |
% Johannes Braams\\ |
| 151 |
% \texttt{johannes.braams at texniek.nl}} |
| 152 |
% |
| 153 |
% \date{Printed \today} |
| 154 |
% |
| 155 |
% \maketitle |
| 156 |
% |
| 157 |
% \begin{multicols}{2} |
| 158 |
% \tableofcontents |
| 159 |
% \end{multicols} |
| 160 |
% |
| 161 |
% \begin{abstract} |
| 162 |
% This package implements a way to indicate |
| 163 |
% modifications in a \LaTeX-document by putting bars in the |
| 164 |
% margin. It realizes this by making use of the |\special| |
| 165 |
% commands supported by `dvi drivers'. Currently six different |
| 166 |
% \changes{v3.5a}{2005/05/23}{PDF\TeX{} support added} |
| 167 |
% \changes{v3.6a}{2011/04/30}{Xe\TeX{} support added} |
| 168 |
% drivers are supported, plus pdftex, Xe\TeX\ and lua\TeX\ |
| 169 |
% support. More can easily be added. |
| 170 |
% \end{abstract} |
| 171 |
% |
| 172 |
% \section{Introduction} |
| 173 |
% |
| 174 |
% \textbf{Important note} Just as with cross references and labels, |
| 175 |
% you usually need to process the document twice (and sometimes |
| 176 |
% three times) to ensure that the changebars come out |
| 177 |
% correctly. However, a warning will be given if another pass is |
| 178 |
% required. |
| 179 |
% |
| 180 |
% \textbf{Features} |
| 181 |
% \begin{itemize} |
| 182 |
% \item Changebars may be nested within each other. Each level of |
| 183 |
% nesting can be given a different thickness bar. |
| 184 |
% |
| 185 |
% \item Changebars may be nested in other environments including |
| 186 |
% floats and footnotes. |
| 187 |
% |
| 188 |
% \item Changebars are applied to all the material within the |
| 189 |
% ``barred'' environment, including floating bodies regardless of |
| 190 |
% where the floats float to. An exception to this is margin |
| 191 |
% floats. |
| 192 |
% |
| 193 |
% \item Changebars may cross page boundaries. |
| 194 |
% |
| 195 |
% \item Changebars can appear on the \emph{outside} of the columns |
| 196 |
% of \Lopt{twocolumn} text. |
| 197 |
% |
| 198 |
% \item The colour of the changebars can be changed. This has sofar |
| 199 |
% \changes{v3.5a}{2005/05/23}{Pdftex support added} |
| 200 |
% \changes{v3.6a}{2011/05/02}{xetex support added} |
| 201 |
% been tested with the \Lopt{dvips}, \Lopt{pdftex}, |
| 202 |
% \Lopt{vtex} and\Lopt{xetex} drivers, |
| 203 |
% but it may also work with other PostScript based drivers. It will |
| 204 |
% \emph{not} work for the \texttt{DVItoLN03} and em\TeX\ drivers. |
| 205 |
% For colored changebars to work, make sure that you specify the |
| 206 |
% \changes{v3.5a}{2005/05/23}{Option xcolor mentioned} |
| 207 |
% option \Lopt{color} or \Lopt{xcolor}. |
| 208 |
% \end{itemize} |
| 209 |
% |
| 210 |
% \section{The user interface} |
| 211 |
% |
| 212 |
% This package has options to specify some details of its |
| 213 |
% operation, and also defines several macros. |
| 214 |
% |
| 215 |
% \subsection{The package options} |
| 216 |
% \subsubsection{Specifying the printer driver} |
| 217 |
% |
| 218 |
% One set of package options\footnote{For older documents the |
| 219 |
% command \cs{driver} is available in the preamble of the document. |
| 220 |
% It takes the options as defined for \LaTeXe\ as argument.} |
| 221 |
% specify the driver that will be used to print the document can be |
| 222 |
% indicated. The driver may be one of: |
| 223 |
% \begin{itemize} |
| 224 |
% \item DVItoLN03 |
| 225 |
% \item DVItoPS |
| 226 |
% \item DVIps |
| 227 |
% \item em\TeX |
| 228 |
% \item \TeX tures |
| 229 |
% \item V\TeX |
| 230 |
% \changes{v3.5a}{2005/05/23}{Pdftex support added} |
| 231 |
% \item PDF\TeX |
| 232 |
% \changes{v3.6a}{2011/04/30}{XeTeX added} |
| 233 |
% \item Xe\TeX |
| 234 |
% \changes{3.6e}{2023/08/13}{luaTeX added} |
| 235 |
% \item lua\TeX |
| 236 |
% \end{itemize} |
| 237 |
% The drivers are represented in the normal typewriter method of |
| 238 |
% typing these names, or by the same entirely in lower case. |
| 239 |
% Since version 3.4d the driver can be specified in a configuration |
| 240 |
% file, not surprisingly called \file{changebar.cfg}. If it |
| 241 |
% contains the command |\ExecuteOption{textures}| the |
| 242 |
% \Lopt{textures} option will be used for all documents that are |
| 243 |
% processed while the configuration file is in \TeX's search path. |
| 244 |
% |
| 245 |
% \subsubsection{Specifying the bar position} |
| 246 |
% The position of the bars may either be on the inner edge of the |
| 247 |
% page (the left column on a recto or single-sided page, the right |
| 248 |
% column of a verso page) by use of the \Lopt{innerbars} package |
| 249 |
% option (the default), or on the outer edge of the page by use of |
| 250 |
% the \Lopt{outerbars} package option. |
| 251 |
% |
| 252 |
% Another set of options gives the user the possibility of |
| 253 |
% specifying that the bars should \emph{always} come out on the |
| 254 |
% left side of the text (\Lopt{leftbars}) or on the right side of |
| 255 |
% the text (\Lopt{rightbars}). |
| 256 |
% |
| 257 |
% \emph{Note} that these options only work for \emph{onecolumn} |
| 258 |
% documents and will be ignored for a twocolumn document. |
| 259 |
% |
| 260 |
% \subsubsection{Color} |
| 261 |
% For people who want their changebars to be colourfull the options |
| 262 |
% \Lopt{color} and \Lopt{xcolor} are available. They define the |
| 263 |
% user command |\cbcolor| and load either the \pkg{color} or the |
| 264 |
% \pkg{xcolor} package. |
| 265 |
% |
| 266 |
% If a configuration file specifies the \Lopt{color} option and you |
| 267 |
% want to override it for a certain document you can use the |
| 268 |
% \Lopt{grey} option. |
| 269 |
% |
| 270 |
% \subsubsection{Tracing} |
| 271 |
% The package also implements tracing for its own debugging. The |
| 272 |
% package options \Lopt{traceon} and \Lopt{traceoff} control |
| 273 |
% tracing. An additional option \Lopt{tracestacks} is available for |
| 274 |
% the die hard who wants to know what goes on in the internal stacks |
| 275 |
% maintained by this package. |
| 276 |
% |
| 277 |
% \subsection{Macros defined by the package} |
| 278 |
% |
| 279 |
% \DescribeMacro{\cbstart} |
| 280 |
% \DescribeMacro{\cbend} |
| 281 |
% All material between the macros |\cbstart| and |\cbend| is |
| 282 |
% barred. The nesting of multiple changebars is allowed. The |
| 283 |
% macro |\cbstart| has an optional parameter that specifies the |
| 284 |
% width of the bar. The syntax is |\cbstart[|\meta{dimension}|]|. |
| 285 |
% If no width is specified, the current value of the parameter |
| 286 |
% |\changebarwidth| is used. Note that |\cbstart| and |\cbend| can |
| 287 |
% be used anywhere but must be correctly nested with floats and |
| 288 |
% footnotes. That is, one cannot have one end of the bar inside a |
| 289 |
% floating insertion and the other outside, but that would be a |
| 290 |
% meaningless thing to do anyhow. |
| 291 |
% |
| 292 |
% \DescribeEnv{changebar} |
| 293 |
% Apart from the macros |\cbstart| and |\cbend| a proper \LaTeX\ |
| 294 |
% environment is defined. The advantage of using the environment |
| 295 |
% whenever possible is that \LaTeX\ will do all the work of |
| 296 |
% checking the correct nesting of different environments. |
| 297 |
% |
| 298 |
% \DescribeMacro{\cbdelete} |
| 299 |
% The macro |\cbdelete| puts a square bar in the margin to indicate |
| 300 |
% that some text was removed from the document. The macro has an |
| 301 |
% optional argument to specify the width of the bar. When no |
| 302 |
% argument is specified the current value of the parameter |
| 303 |
% |\deletebarwidth| will be used. |
| 304 |
% |
| 305 |
% \DescribeMacro{\nochangebars} |
| 306 |
% The macro |\nochangebars| disables the changebar commands. |
| 307 |
% |
| 308 |
% \DescribeMacro{\cbcolor} |
| 309 |
% This macro is defined when the \Lopt{color} option is |
| 310 |
% selected. It's syntax is the same as the |\color| command from |
| 311 |
% the \pkg{color} package. |
| 312 |
% |
| 313 |
% \subsection{Changebar parameters} |
| 314 |
% |
| 315 |
% \DescribeMacro{\changebarwidth} |
| 316 |
% The width of the changebars is controlled with the \LaTeX\ length |
| 317 |
% parameter |\changebarwidth|. |
| 318 |
% Its value can be changed with the |\setlength| command. |
| 319 |
% Changing the value of |\changebarwidth| affects all subsequent |
| 320 |
% changebars subject to the scoping rules of |\setlength|. |
| 321 |
% |
| 322 |
% \DescribeMacro{\deletebarwidth} |
| 323 |
% The width of the deletebars is controlled with the \LaTeX\ length |
| 324 |
% parameter |\deletebarwidth|. |
| 325 |
% Its value can be changed with the |\setlength| command. |
| 326 |
% Changing the value of |\deletebarwidth| affects all subsequent |
| 327 |
% deletebars subject to the scoping rules of |\setlength|. |
| 328 |
% |
| 329 |
% \DescribeMacro{\changebarsep} |
| 330 |
% The separation between the text and the changebars is determined |
| 331 |
% by the value of the \LaTeX\ length parameter |\changebarsep|. |
| 332 |
% |
| 333 |
% \DescribeVar{changebargrey} |
| 334 |
% When one of the supported dvi to PostScript translators is used |
| 335 |
% the `blackness' of the bars can be controlled. The \LaTeX\ |
| 336 |
% counter \texttt{changebargrey} is used for this purpose. Its |
| 337 |
% value can be changed with a command like: |
| 338 |
% \begin{verbatim} |
| 339 |
% \setcounter{changebargrey}{85} |
| 340 |
% \end{verbatim} |
| 341 |
% The value of the counter is a percentage, where the value 0 yields |
| 342 |
% black bars, the value 100 yields white bars. |
| 343 |
% |
| 344 |
% \DescribeVar{outerbars} |
| 345 |
% The changebars will be printed in the `inside' margin of your |
| 346 |
% document. This means they appear on the left side of the |
| 347 |
% page. When \Lopt{twoside} is in effect the bars will be printed |
| 348 |
% on the right side of even pages. |
| 349 |
% |
| 350 |
% |
| 351 |
% \section{Deficiencies and bugs} |
| 352 |
% |
| 353 |
% \begin{itemize} |
| 354 |
% \item The macros blindly use special points |\cb@minpoint| through |
| 355 |
% |\cb@maxpoint|. If this conflicts with another set of macros, the |
| 356 |
% results will be unpredictable. (What is really needed is a |
| 357 |
% |\newspecialpoint|, analogous to |\newcount| etc.~--- it's not |
| 358 |
% provided because the use of the points is rather rare.) |
| 359 |
% |
| 360 |
% \item There is a limit of |
| 361 |
% $(\mbox{\texttt{\bslash cb@maxpoint}}- |
| 362 |
% \mbox{\texttt{\bslash cb@minpoint}}+1)/4$ bars per page |
| 363 |
% (four special points per bar). Using more than this number yields |
| 364 |
% unpredictable results (but that could be called a feature for a |
| 365 |
% page with so many bars). This limitation could be increased if |
| 366 |
% desired. |
| 367 |
% \changes{v3.5a}{2005/05/23}{Pdftex support added} |
| 368 |
% \changes{v3.6a}{2011/04/30}{XeTeX suport added} |
| 369 |
% There is no such limit with PDF\TeX or Xe\TeX. |
| 370 |
% |
| 371 |
% \item Internal macro names are all of the form |\cb@xxxx|. No |
| 372 |
% checking for conflicts with other macros is done. |
| 373 |
% |
| 374 |
% \item This implementation does not work with the |
| 375 |
% \texttt{multicolumn} package. |
| 376 |
% |
| 377 |
% \item The algorithms may fail if a floating insertion is split over |
| 378 |
% multiple pages. In \LaTeX\ floats are not split but footnotes |
| 379 |
% may be. The simplest fix to this is to prevent footnotes from |
| 380 |
% being split but this may make \TeX\ very unhappy. |
| 381 |
% |
| 382 |
% \item The |\cbend| normally gets ``attached'' to the token after it |
| 383 |
% rather than the one before it. This may lead to a longer bar |
| 384 |
% than intended. For example, consider the sequence `word1 |
| 385 |
% |\cbend| word2'. If there is a line break between `word1' and |
| 386 |
% `word2' the bar will incorrectly be extended an extra line. This |
| 387 |
% particular case can be fixed with the incantation |
| 388 |
% `word1|\cbend{}| word2'. |
| 389 |
% |
| 390 |
% \item The colour support has only been tested with the \Lopt{dvips} |
| 391 |
% \changes{v3.5a}{2005/05/23}{Pdftex support added} |
| 392 |
% and \Lopt{pdftex} drivers. |
| 393 |
% \end{itemize} |
| 394 |
% |
| 395 |
% \section{The basic algorithm} |
| 396 |
% |
| 397 |
% The changebars are implemented using the |\specials| of various |
| 398 |
% \texttt{dvi} interpreting programs like \texttt{DVItoLN03} or |
| 399 |
% \texttt{DVIps}. In essence, the start of a changebar defines two |
| 400 |
% |\special| points in the margins at the current vertical position |
| 401 |
% on the page. The end of a changebar defines another set of two |
| 402 |
% points and then joins (using the ``connect'' |\special|) either |
| 403 |
% the two points to the left or the two points to the right of the |
| 404 |
% text, depending on the setting of \Lopt{innerbars}, |
| 405 |
% \Lopt{outerbars}, \Lopt{leftbars}, \Lopt{rightbars} and/or |
| 406 |
% \Lopt{twoside}. |
| 407 |
% |
| 408 |
% This works fine as long as the two points being connected lie on |
| 409 |
% the same page. However, if they don't, the bar must be |
| 410 |
% artificially terminated at the page break and restarted at the |
| 411 |
% top of the next page. The only way to do this (that I can think |
| 412 |
% of) is to modify the output routine so that it checks if any bar |
| 413 |
% is in progress when it ships out a page and, if so, adds the |
| 414 |
% necessary artificial end and begin. |
| 415 |
% |
| 416 |
% The obvious way to indicate to the output routine that a bar is |
| 417 |
% in progress is to set a flag when the bar is begun and to unset |
| 418 |
% this flag when the bar is ended. This works most of the time |
| 419 |
% but, because of the asynchronous behavior of the output routine, |
| 420 |
% errors occur if the bar begins or ends near a page break. To |
| 421 |
% illustrate, consider the following scenario. |
| 422 |
% |
| 423 |
% \begin{verbatim} |
| 424 |
% blah blah blah % page n |
| 425 |
% blah blah blah |
| 426 |
% \cbstart % this does its thing and set the flag |
| 427 |
% more blah |
| 428 |
% <-------------- pagebreak occurs here |
| 429 |
% more blah |
| 430 |
% \cbend % does its thing and unsets flag |
| 431 |
% blah blah |
| 432 |
% \end{verbatim} |
| 433 |
% |
| 434 |
% Since \TeX\ processes ahead of the page break before invoking the |
| 435 |
% output routine, it is possible that the |\cbend| is |
| 436 |
% processed, and the flag unset, before the output routine is |
| 437 |
% called. If this happens, special action is required to generate |
| 438 |
% an artificial end and begin to be added to page $n$ and $n+1$ |
| 439 |
% respectively, as it is not possible to use a flag to signal |
| 440 |
% the output routine that a bar crosses a page break. |
| 441 |
% |
| 442 |
% The method used by these macros is to create a stack of the |
| 443 |
% beginning and end points of each bar in the document together |
| 444 |
% with the page number corresponding to each point. Then, as a |
| 445 |
% page is completed, a modified output routine checks the stack to |
| 446 |
% determine if any bars begun on or before the current page are |
| 447 |
% terminated on subsequent pages, and handles those bars |
| 448 |
% appropriately. To build the stack, information about each |
| 449 |
% changebar is written to the \file{.aux} file as bars are processed. |
| 450 |
% This information is re-read when the document is next processed. |
| 451 |
% Thus, to ensure that changebars are correct, the document must |
| 452 |
% be processed twice. Luckily, this is generally required for |
| 453 |
% \LaTeX\ anyway. |
| 454 |
% With PDF\LaTeX{} generally three (or even more) runs |
| 455 |
% are necessary. |
| 456 |
% |
| 457 |
% This approach is sufficiently general to allow nested bars, bars |
| 458 |
% in floating insertions, and bars around floating insertions. |
| 459 |
% Bars inside floats and footnotes are handled in the same way as |
| 460 |
% bars in regular text. Bars that encompass floats or footnotes |
| 461 |
% are handled by creating an additional bar that floats with the |
| 462 |
% floating material. Modifications to the appropriate \LaTeX\ |
| 463 |
% macros check for this condition and add the extra bar. |
| 464 |
% |
| 465 |
%\StopEventually{ |
| 466 |
% \IndexPrologue{\section*{Index}% |
| 467 |
% \markboth{Index}{Index}% |
| 468 |
% Numbers in \emph{italics} indicate the page where the |
| 469 |
% macro is described, the underlined numbers indicate |
| 470 |
% the number of the line of code where the macro is defined, |
| 471 |
% all other numbers indicate where a macro is used.} |
| 472 |
% |
| 473 |
% \GlossaryPrologue{\section*{History of changes}% |
| 474 |
% \markboth{History of changes}{History of changes}% |
| 475 |
% The numbers behind the changes indicate the page where |
| 476 |
% the macrocode is described.\hfil\null} |
| 477 |
% |
| 478 |
% \PrintIndex |
| 479 |
%^^AA \PrintChanges |
| 480 |
% } |
| 481 |
% \section{The implementation} |
| 482 |
% |
| 483 |
% \subsection{Declarations And Initializations} |
| 484 |
% |
| 485 |
% \begin{macro}{\cb@maxpoint} |
| 486 |
% The original version of \texttt{changebar.sty} only supported the |
| 487 |
% \texttt{DVItoLN03} specials. The \texttt{LN03} printer has a |
| 488 |
% maximum number of points that can be defined on a page. Also for |
| 489 |
% some PostScript printers the number of points that can be defined |
| 490 |
% can be limited by the amount of memory used. Therefore, the |
| 491 |
% consecutive numbering of points has to be reset when the maximum |
| 492 |
% is reached. This maximum can be adapted to the printers needs. |
| 493 |
% \begin{macrocode} |
| 494 |
%<*package> |
| 495 |
\def\cb@maxpoint{80} |
| 496 |
% \end{macrocode} |
| 497 |
% \end{macro} |
| 498 |
% |
| 499 |
% \begin{macro}{\cb@minpoint} |
| 500 |
% When resetting the point number we need to know what to reset it |
| 501 |
% to, this is minimum number is stored in |\cb@minpoint|. |
| 502 |
% \textbf{This number has to be \emph{odd}} because the algorithm |
| 503 |
% that decides whether a bar has to be continued on the next page |
| 504 |
% depends on this. |
| 505 |
% \begin{macrocode} |
| 506 |
\def\cb@minpoint{1} |
| 507 |
% \end{macrocode} |
| 508 |
% \end{macro} |
| 509 |
% |
| 510 |
% \begin{macro}{\cb@nil} |
| 511 |
% Sometimes a void value for a point has to be returned by one |
| 512 |
% of the macros. For this purpose |\cb@nil| is used. |
| 513 |
% \begin{macrocode} |
| 514 |
\def\cb@nil{0} |
| 515 |
% \end{macrocode} |
| 516 |
% \end{macro} |
| 517 |
% |
| 518 |
% \begin{macro}{\cb@nextpoint} |
| 519 |
% The number of the next special point is stored in the count |
| 520 |
% register |\cb@nextpoint| and initially equal to |
| 521 |
% |\cb@minpoint|. |
| 522 |
% \begin{macrocode} |
| 523 |
\newcount\cb@nextpoint |
| 524 |
\cb@nextpoint=\cb@minpoint |
| 525 |
% \end{macrocode} |
| 526 |
% \end{macro} |
| 527 |
% |
| 528 |
% \begin{macro}{\cb@topleft} |
| 529 |
% \changes{v3.3a}{1997/09/26}{Renamed \cs{cb@currentpoint} to |
| 530 |
% \cs{cb@topleft}} |
| 531 |
% \begin{macro}{\cb@topright} |
| 532 |
% \changes{v3.3a}{1997/09/26}{New counter} |
| 533 |
% \begin{macro}{\cb@botleft} |
| 534 |
% \changes{v3.3a}{1997/09/26}{New counter} |
| 535 |
% \begin{macro}{\cb@botright} |
| 536 |
% \changes{v3.3a}{1997/09/26}{New counter} |
| 537 |
% These four counters are used to identify the four special points |
| 538 |
% that specify a changebar. The point defined by |\cb@topleft| is |
| 539 |
% the one used to identify the changebar; the values of the other |
| 540 |
% points are derived from it. |
| 541 |
% \begin{macrocode} |
| 542 |
\newcount\cb@topleft |
| 543 |
\newcount\cb@topright |
| 544 |
\newcount\cb@botleft |
| 545 |
\newcount\cb@botright |
| 546 |
% \end{macrocode} |
| 547 |
% \end{macro} |
| 548 |
% \end{macro} |
| 549 |
% \end{macro} |
| 550 |
% \end{macro} |
| 551 |
% |
| 552 |
% \begin{macro}{\cb@cnta} |
| 553 |
% \changes{v3.4f}{2003/10/18}{New temporary storage counter, replaces |
| 554 |
% the use of \cs{@tempcnta}} |
| 555 |
% \begin{macro}{\cb@cntb} |
| 556 |
% \changes{v3.4f}{2003/10/18}{New temporary storage counter, replaces |
| 557 |
% the use of \cs{@tempcntb}} |
| 558 |
% \begin{macro}{\cb@dima} |
| 559 |
% \changes{v3.4f}{2003/10/18}{New temporary storage dimension} |
| 560 |
% Sometimes we need temporarily store a value. For this purpose two |
| 561 |
% count registers and a dimension register are allocated. |
| 562 |
% \begin{macrocode} |
| 563 |
\newcount\cb@cnta |
| 564 |
\newcount\cb@cntb |
| 565 |
\newdimen\cb@dima |
| 566 |
% \end{macrocode} |
| 567 |
% \end{macro} |
| 568 |
% \end{macro} |
| 569 |
% \end{macro} |
| 570 |
% |
| 571 |
% \begin{macro}{\cb@curbarwd} |
| 572 |
% \changes{v3.3a}{1997/09/26}{Introduced \cs{curbarwd} to eliminate |
| 573 |
% the use of \cs{@tempdima}} |
| 574 |
% The dimension register |\cb@curbarwd| is used to store the width of |
| 575 |
% the current bar. |
| 576 |
% \begin{macrocode} |
| 577 |
\newdimen\cb@curbarwd |
| 578 |
% \end{macrocode} |
| 579 |
% \end{macro} |
| 580 |
% |
| 581 |
% \begin{macro}{\cb@page} |
| 582 |
% \begin{macro}{\cb@pagecount} |
| 583 |
% \changes{v3.5a}{2005/05/23}{Twocolumn support changes} |
| 584 |
% The macros need to keep track of the number of pages/columns |
| 585 |
% output so far. To this end the counter |\cb@pagecount| is used. |
| 586 |
% When a pagenumber is read from the history stack, it is stored in |
| 587 |
% the counter |\cb@page|. The counter |\cb@pagecount| is initially |
| 588 |
% $0$; it gets incremented during the call to |\@makebox| (see |
| 589 |
% section~\ref{pagebreak}). |
| 590 |
% \begin{macrocode} |
| 591 |
\newcount\cb@page |
| 592 |
\newcount\cb@pagecount |
| 593 |
\cb@pagecount=0 |
| 594 |
% \end{macrocode} |
| 595 |
% \end{macro} |
| 596 |
% \end{macro} |
| 597 |
% |
| 598 |
% \begin{macro}{\cb@barsplace} |
| 599 |
% \changes{v3.5a}{2005/05/23}{Changes for better twocolumn support} |
| 600 |
% A switch is provided to control where the changebars will be |
| 601 |
% printed. |
| 602 |
% The value depends on the options given: |
| 603 |
% \begin{itemize} |
| 604 |
% \item[0] for innerbars (default), |
| 605 |
% \item[1] for outerbars, |
| 606 |
% \item[2] gives leftbars, |
| 607 |
% \item[3] gives rightbars. |
| 608 |
% \end{itemize} |
| 609 |
% \begin{macrocode} |
| 610 |
\def\cb@barsplace{0} |
| 611 |
% \end{macrocode} |
| 612 |
% \end{macro} |
| 613 |
% |
| 614 |
% \begin{Var}{@cb@trace} |
| 615 |
% A switch to enable tracing of the actions of this package. |
| 616 |
% \begin{macrocode} |
| 617 |
\newif\if@cb@trace |
| 618 |
% \end{macrocode} |
| 619 |
% \end{Var} |
| 620 |
% |
| 621 |
% \begin{Var}{@cb@firstcolumn} |
| 622 |
% \changes{v3.5a}{2005/05/23}{Changes for better twocolumn support} |
| 623 |
% A switch to find out if a point is in the left column of a |
| 624 |
% twocolumn page. |
| 625 |
% \begin{macrocode} |
| 626 |
\newif\if@cb@firstcolumn |
| 627 |
% \end{macrocode} |
| 628 |
% \end{Var} |
| 629 |
% |
| 630 |
% \begin{macro}{\cb@pdfxy} |
| 631 |
% \changes{v3.5a}{2005/05/23}{Pdftex support added} |
| 632 |
% The macro |\cb@pdfxy| populates the pdf x,y coordinates file. |
| 633 |
% In \Lopt{pdftex} and \Lopt{xetex} mode it writes one line to |
| 634 |
% \file{.cb2} file which is equivalent to one bar point. The |
| 635 |
% default implementation is a noop. |
| 636 |
% If the \Lopt{pdftex} or \Lopt{xetex} option is given it is |
| 637 |
% redefined. |
| 638 |
% \begin{macrocode} |
| 639 |
\def\cb@pdfxy#1#2#3#4#5{} |
| 640 |
% \end{macrocode} |
| 641 |
% \end{macro} |
| 642 |
% |
| 643 |
% \begin{macro}{\cb@positions} |
| 644 |
% |
| 645 |
% This macro calculates the (horizontal) positions of the |
| 646 |
% changebars. |
| 647 |
% |
| 648 |
% \begin{macro}{\cb@odd@left} |
| 649 |
% \changes{v3.3a}{1997/09/26}{Renamed from \cs{b@odd}} |
| 650 |
% \begin{macro}{\cb@odd@right} |
| 651 |
% \changes{v3.3a}{1997/09/26}{New dimension register} |
| 652 |
% \begin{macro}{\cb@even@left} |
| 653 |
% \changes{v3.3a}{1997/09/26}{Renamed from \cs{b@even}} |
| 654 |
% \begin{macro}{\cb@even@right} |
| 655 |
% \changes{v3.3a}{1997/09/26}{New dimension register} |
| 656 |
% Because the margins can differ for even and odd pages and because |
| 657 |
% changebars are sometimes on different sides of the paper we need |
| 658 |
% four dimensions to store the result. |
| 659 |
% |
| 660 |
% \begin{macrocode} |
| 661 |
\newdimen\cb@odd@left |
| 662 |
\newdimen\cb@odd@right |
| 663 |
\newdimen\cb@even@left |
| 664 |
\newdimen\cb@even@right |
| 665 |
% \end{macrocode} |
| 666 |
% \end{macro} |
| 667 |
% \end{macro} |
| 668 |
% \end{macro} |
| 669 |
% \end{macro} |
| 670 |
% |
| 671 |
% Since the changebars are drawn with the \textsc{PostScript} |
| 672 |
% command \texttt{lineto} and not as \TeX{}-like rules the |
| 673 |
% reference points lie on the center of the changebar, therefore |
| 674 |
% the calculation has to add or subtract half of the width of the |
| 675 |
% bar to keep |\changebarsep| whitespace between the bar and the |
| 676 |
% body text. |
| 677 |
% |
| 678 |
% First the position for odd pages is calculated. |
| 679 |
% \changes{v3.1}{1993/07/02}{Corrected positioning of PostScript bars} |
| 680 |
% \changes{v3.3a}{1997/09/26}{calculate horizontal positions |
| 681 |
% independent of options used} |
| 682 |
% \changes{v3.3d}{1997/10/28}{Removed bogus offset} |
| 683 |
% \changes{v3.3g}{1999/06/11}{Don't use \cs{evensidemargin} when |
| 684 |
% \Lopt{twoside} is \emph{not} in effect} |
| 685 |
% \begin{macrocode} |
| 686 |
\def\cb@positions{% |
| 687 |
\global\cb@odd@left=\hoffset |
| 688 |
\global\cb@even@left\cb@odd@left |
| 689 |
\global\advance\cb@odd@left by \oddsidemargin |
| 690 |
\global\cb@odd@right\cb@odd@left |
| 691 |
\global\advance\cb@odd@right by \textwidth |
| 692 |
\global\advance\cb@odd@right by \changebarsep |
| 693 |
\global\advance\cb@odd@right by 0.5\changebarwidth |
| 694 |
\global\advance\cb@odd@left by -\changebarsep |
| 695 |
\global\advance\cb@odd@left by -0.5\changebarwidth |
| 696 |
% \end{macrocode} |
| 697 |
% On even sided pages we need to use |\evensidemargin| in the |
| 698 |
% calculations when \Lopt{twoside} is in effect. |
| 699 |
% \begin{macrocode} |
| 700 |
\if@twoside |
| 701 |
\global\advance\cb@even@left by \evensidemargin |
| 702 |
\global\cb@even@right\cb@even@left |
| 703 |
\global\advance\cb@even@left by -\changebarsep |
| 704 |
\global\advance\cb@even@left by -0.5\changebarwidth |
| 705 |
\global\advance\cb@even@right by \textwidth |
| 706 |
\global\advance\cb@even@right by \changebarsep |
| 707 |
\global\advance\cb@even@right by 0.5\changebarwidth |
| 708 |
\else |
| 709 |
% \end{macrocode} |
| 710 |
% Otherwise just copy the result for odd pages. |
| 711 |
% \begin{macrocode} |
| 712 |
\global\let\cb@even@left\cb@odd@left |
| 713 |
\global\let\cb@even@right\cb@odd@right |
| 714 |
\fi |
| 715 |
} |
| 716 |
% \end{macrocode} |
| 717 |
% \end{macro} |
| 718 |
% |
| 719 |
% \begin{macro}{\cb@removedim} |
| 720 |
% In PostScript code, length specifications are without dimensions. |
| 721 |
% Therefore we need a way to remove the letters `pt' from the |
| 722 |
% result of the operation |\the\|\meta{dimen}. |
| 723 |
% This can be done by defining a command that has a delimited |
| 724 |
% argument like: |
| 725 |
% \begin{verbatim} |
| 726 |
% \def\cb@removedim#1pt{#1} |
| 727 |
% \end{verbatim} |
| 728 |
% We encounter one problem though, the category code of the letters |
| 729 |
% `pt' is 12 when produced as the output from |\the\|\meta{dimen}. |
| 730 |
% Thus the characters that delimit the argument of |\cb@removedim| |
| 731 |
% also have to have category code 12. To keep the changes local |
| 732 |
% the macro |\cb@removedim| is defined in a group. |
| 733 |
% \begin{macrocode} |
| 734 |
{\catcode`\p=12\catcode`\t=12 \gdef\cb@removedim#1pt{#1}} |
| 735 |
% \end{macrocode} |
| 736 |
% \end{macro} |
| 737 |
% |
| 738 |
% \subsection{Option Processing} |
| 739 |
% |
| 740 |
% The user should select the specials that should be used by |
| 741 |
% specifying the driver name as an option to the |
| 742 |
% |\usepackage| call. |
| 743 |
% \changes{v3.5a}{2005/05/23}{Added the option \Lopt{PDFTeX}} |
| 744 |
% \changes{v3.6a}{2011/04/30}{Added the option \Lopt{XeTeX}} |
| 745 |
% \changes{v3.6e}{2023/08/13}{Added the option \Lopt{luaTeX}} |
| 746 |
% Possible choices are: |
| 747 |
% \begin{itemize} |
| 748 |
% \item DVItoLN03 |
| 749 |
% \item DVItoPS |
| 750 |
% \item DVIps |
| 751 |
% \item em\TeX |
| 752 |
% \item Textures |
| 753 |
% \item V\TeX |
| 754 |
% \item PDF\TeX |
| 755 |
% \item Xe\TeX |
| 756 |
% \item luaTeX |
| 757 |
% \end{itemize} |
| 758 |
% |
| 759 |
% The intent is that the driver names should be case-insensitive, |
| 760 |
% but the following code doesn't achieve this: it only permits the |
| 761 |
% forms given above and their lower-case equivalents. |
| 762 |
% \changes{v3.3e}{1998/02/24}{Added the option \Lopt{textures}} |
| 763 |
% \changes{v3.4a}{2001/04/18}{Added the option \Lopt{VTeX}} |
| 764 |
% \changes{v3.5a}{2005/05/23}{Added the option \Lopt{PDFTeX}} |
| 765 |
% \changes{v3.6a}{2011/04/30}{Added the option \Lopt{XeTeX}} |
| 766 |
% \begin{macrocode} |
| 767 |
\DeclareOption{DVItoLN03}{\global\chardef\cb@driver@setup=0\relax} |
| 768 |
\DeclareOption{dvitoln03}{\global\chardef\cb@driver@setup=0\relax} |
| 769 |
\DeclareOption{DVItoPS}{\global\chardef\cb@driver@setup=1\relax} |
| 770 |
\DeclareOption{dvitops}{\global\chardef\cb@driver@setup=1\relax} |
| 771 |
\DeclareOption{DVIps}{\global\chardef\cb@driver@setup=2\relax} |
| 772 |
\DeclareOption{dvips}{\global\chardef\cb@driver@setup=2\relax} |
| 773 |
\DeclareOption{emTeX}{\global\chardef\cb@driver@setup=3\relax} |
| 774 |
\DeclareOption{emtex}{\global\chardef\cb@driver@setup=3\relax} |
| 775 |
\DeclareOption{textures}{\global\chardef\cb@driver@setup=4\relax} |
| 776 |
\DeclareOption{Textures}{\global\chardef\cb@driver@setup=4\relax} |
| 777 |
\DeclareOption{VTeX}{\global\chardef\cb@driver@setup=5\relax} |
| 778 |
\DeclareOption{vtex}{\global\chardef\cb@driver@setup=5\relax} |
| 779 |
% \end{macrocode} |
| 780 |
% \begin{macrocode} |
| 781 |
\DeclareOption{PDFTeX}{\cb@pdftexcheck} |
| 782 |
\DeclareOption{pdftex}{\cb@pdftexcheck} |
| 783 |
% \end{macrocode} |
| 784 |
% \changes{v3.5a}{2005/05/23}{PDFTeX support added} |
| 785 |
% For the \Lopt{pdftex} option we have to check that the current |
| 786 |
% \LaTeX{} run is using PDF\TeX{} and that PDF output is selected. |
| 787 |
% If it is, we initialize the option and open an additional output file. |
| 788 |
% If not, we ignore the option and issue a warning. |
| 789 |
% \begin{macrocode} |
| 790 |
\def\cb@pdftexcheck{% |
| 791 |
\ifx\pdfsavepos\@undefined\cb@pdftexerror |
| 792 |
\else\ifx\pdfoutput\@undefined\cb@pdftexerror |
| 793 |
\else\ifnum\pdfoutput>0 |
| 794 |
\global\chardef\cb@driver@setup=6\relax |
| 795 |
\ifx\cb@writexy\@undefined |
| 796 |
\newwrite\cb@writexy |
| 797 |
\newread\cb@readxy |
| 798 |
\immediate\openout\cb@writexy=\jobname.cb2\relax |
| 799 |
\fi |
| 800 |
% \end{macrocode} |
| 801 |
% Redefine the |\cb@pdfxy| macro to write point coordinates to the |
| 802 |
% \file{.cb2} file. |
| 803 |
% \changes{v3.7b}{2023/12/30}{use ";" instead of "," as delimiter} |
| 804 |
% \changes{v3.7e}{2024/07/17}{Use "/" instead of ";" as delimiter} |
| 805 |
% \begin{macrocode} |
| 806 |
\gdef\cb@pdfxy##1##2##3##4##5{% |
| 807 |
% \end{macrocode} |
| 808 |
% \begin{changebar} |
| 809 |
% \begin{macrocode} |
| 810 |
\immediate\write\cb@writexy{##1.##2p##3/##4/##5}% |
| 811 |
% \end{macrocode} |
| 812 |
% \end{changebar} |
| 813 |
% \begin{macrocode} |
| 814 |
\expandafter\gdef\csname cb@##1.##2\endcsname{##3,##4,##5}} |
| 815 |
\else\cb@pdftexerror\fi\fi\fi} |
| 816 |
% \end{macrocode} |
| 817 |
% Give a warning if we cannot support the \Lopt{pdftex} option. |
| 818 |
% \begin{macrocode} |
| 819 |
\def\cb@pdftexerror{\PackageError |
| 820 |
{changebar}% |
| 821 |
{PDFTeX option cannot be used}% |
| 822 |
{You are using a LaTeX run which does not generate PDF\MessageBreak |
| 823 |
or you are using a very old version of PDFTeX}} |
| 824 |
% \end{macrocode} |
| 825 |
% |
| 826 |
% \begin{macrocode} |
| 827 |
\DeclareOption{XeTeX}{\cb@xetexcheck} |
| 828 |
\DeclareOption{xetex}{\cb@xetexcheck} |
| 829 |
% \end{macrocode} |
| 830 |
% \changes{v3.6a}{2005/05/23}{XeTeX support added} |
| 831 |
% For the \Lopt{xetex} option we have to check that the current |
| 832 |
% \LaTeX{} run is using Xe\TeX{}. |
| 833 |
% If it is, we initialize the option and open an additional output file. |
| 834 |
% If not, we ignore the option and issue a warning.. |
| 835 |
% \begin{macrocode} |
| 836 |
\def\cb@xetexcheck{% |
| 837 |
\expandafter\ifx\csname XeTeXrevision\endcsname\@undefined \cb@xetexerror |
| 838 |
\else |
| 839 |
\global\chardef\cb@driver@setup=7\relax |
| 840 |
\ifx\cb@writexy\@undefined |
| 841 |
\newwrite\cb@writexy |
| 842 |
\newread\cb@readxy |
| 843 |
\immediate\openout\cb@writexy=\jobname.cb2\relax |
| 844 |
\fi |
| 845 |
% \end{macrocode} |
| 846 |
% Redefine the |\cb@pdfxy| macro to write point coordinates to the |
| 847 |
% \file{.cb2} file. |
| 848 |
% \changes{v3.7b}{2023/12/30}{use ";" instead of "," as delimiter} |
| 849 |
% \changes{v3.7e}{2024/07/17}{Use "/" instead of ";" as delimiter} |
| 850 |
% \begin{macrocode} |
| 851 |
\gdef\cb@pdfxy##1##2##3##4##5{% |
| 852 |
% \end{macrocode} |
| 853 |
% \begin{changebar} |
| 854 |
% \begin{macrocode} |
| 855 |
\immediate\write\cb@writexy{##1.##2p##3/##4/##5}% |
| 856 |
% \end{macrocode} |
| 857 |
% \end{changebar} |
| 858 |
% \begin{macrocode} |
| 859 |
\expandafter\gdef\csname cb@##1.##2\endcsname{##3,##4,##5}} |
| 860 |
\gdef\sec@nd@ftw@##1 ##2{##2} |
| 861 |
\fi} |
| 862 |
% \end{macrocode} |
| 863 |
% |
| 864 |
% Give a warning if we cannot support the \Lopt{xetex} option. |
| 865 |
% \begin{macrocode} |
| 866 |
\def\cb@xetexerror{\PackageError |
| 867 |
{changebar}% |
| 868 |
{XeTeX option cannot be used}% |
| 869 |
{You are not using XeLaTeX}} |
| 870 |
% \end{macrocode} |
| 871 |
% |
| 872 |
% \begin{macrocode} |
| 873 |
\DeclareOption{luaTeX}{\cb@luatexcheck} |
| 874 |
\DeclareOption{luatex}{\cb@luatexcheck} |
| 875 |
% \end{macrocode} |
| 876 |
% \changes{v3.6e}{2023/08/13}{luaTeX support added} |
| 877 |
% For the \Lopt{luatex} option we have to check that the current |
| 878 |
% \LaTeX{} run is using lua\TeX{}. |
| 879 |
% If it is, we initialize the option and open an additional output file. |
| 880 |
% If not, we ignore the option and issue a warning.. |
| 881 |
% \begin{macrocode} |
| 882 |
\def\cb@luatexcheck{% |
| 883 |
\ifx\directlua\@undefined \cb@luatexerror |
| 884 |
\else |
| 885 |
\global\chardef\cb@driver@setup=8\relax |
| 886 |
\ifx\cb@writexy\@undefined |
| 887 |
\newwrite\cb@writexy |
| 888 |
\newread\cb@readxy |
| 889 |
\immediate\openout\cb@writexy=\jobname.cb2\relax |
| 890 |
\fi |
| 891 |
% \end{macrocode} |
| 892 |
% Redefine the |\cb@pdfxy| macro to write point coordinates to the |
| 893 |
% \file{.cb2} file. |
| 894 |
% \changes{v3.7b}{2023/12/30}{use ";" instead of ",¨ as delimiter} |
| 895 |
% \changes{v3.7e}{2024/07/17}{Use "/" instead of ";" as delimiter} |
| 896 |
% \begin{macrocode} |
| 897 |
\gdef\cb@pdfxy##1##2##3##4##5{% |
| 898 |
% \end{macrocode} |
| 899 |
% \begin{changebar} |
| 900 |
% \begin{macrocode} |
| 901 |
\immediate\write\cb@writexy{##1.##2p##3/##4/##5}% |
| 902 |
% \end{macrocode} |
| 903 |
% \end{changebar} |
| 904 |
% \begin{macrocode} |
| 905 |
\expandafter\gdef\csname cb@##1.##2\endcsname{##3,##4,##5}} |
| 906 |
\fi} |
| 907 |
% \end{macrocode} |
| 908 |
% |
| 909 |
% Give a warning if we cannot support the \Lopt{luatex} option. |
| 910 |
% \begin{macrocode} |
| 911 |
\def\cb@luatexerror{\PackageError |
| 912 |
{changebar}% |
| 913 |
{luaTeX option cannot be used}% |
| 914 |
{You are not using luaLaTeX}} |
| 915 |
% \end{macrocode} |
| 916 |
% |
| 917 |
% The new features of \LaTeXe\ make it possible to implement the |
| 918 |
% \Lopt{outerbars} option. |
| 919 |
% \changes{v3.5a}{2005/05/23}{Changes for better twocolumn support} |
| 920 |
% \begin{macrocode} |
| 921 |
\DeclareOption{outerbars}{\def\cb@barsplace{1}} |
| 922 |
\DeclareOption{innerbars}{\def\cb@barsplace{0}} |
| 923 |
% \end{macrocode} |
| 924 |
% |
| 925 |
% It is also possible to specify that the change bars should |
| 926 |
% \emph{always} be printed on either the left or the right side of |
| 927 |
% the text. For this we have the options \Lopt{leftbars} and |
| 928 |
% \Lopt{rightbars}. Specifying \emph{either} of these options will |
| 929 |
% overrule a possible \Lopt{twoside} option at the document level. |
| 930 |
% \changes{v3.2b}{1995/06/27}{Added the options\Lopt{leftbars} and |
| 931 |
% \Lopt{rightbars}} |
| 932 |
% \changes{v3.3d}{1997/10/28}{Removed bogus offset} |
| 933 |
% \changes{v3.3g}{1999/06/11}{take the setting of \Lopt{twoside} into |
| 934 |
% account} |
| 935 |
% \changes{v3.5a}{2005/05/23}{Changes for better twocolumn support} |
| 936 |
% \begin{macrocode} |
| 937 |
\DeclareOption{leftbars}{\def\cb@barsplace{2}} |
| 938 |
\DeclareOption{rightbars}{\def\cb@barsplace{3}} |
| 939 |
% \end{macrocode} |
| 940 |
% \changes{v3.3j}{2000/09/26}{\cs{cb@even@right} erroneously wasn't |
| 941 |
% set in the oneside mode with option rightbars} |
| 942 |
% A set of options to control tracing. |
| 943 |
% \changes{v3.4b}{2001/08/27}{Added tracing of push and pop |
| 944 |
% operations} |
| 945 |
% \begin{macrocode} |
| 946 |
\DeclareOption{traceon}{\@cb@tracetrue} |
| 947 |
\DeclareOption{traceoff}{\@cb@tracefalse} |
| 948 |
\DeclareOption{tracestacks}{% |
| 949 |
\let\cb@trace@stack\cb@@show@stack |
| 950 |
\def\cb@trace@push#1{\cb@trace{% |
| 951 |
Pushed point \the\cb@topleft\space on \noexpand#1: #1}}% |
| 952 |
\def\cb@trace@pop#1{\cb@trace{% |
| 953 |
Popped point \the\cb@topleft\space from \noexpand#1: #1}}% |
| 954 |
} |
| 955 |
% \end{macrocode} |
| 956 |
% Three options are introduced for colour support. The first one, |
| 957 |
% \Lopt{grey}, is activated by default. |
| 958 |
% \changes{v3.4b}{2001/08/28}{Added options \Lopt{grey} and |
| 959 |
% \Lopt{color}} |
| 960 |
% \begin{macrocode} |
| 961 |
\DeclareOption{grey}{% |
| 962 |
\def\cb@ps@color{\thechangebargrey\space 100 div setgray}} |
| 963 |
% \end{macrocode} |
| 964 |
% The second option activates support for the \pkg{color} package. |
| 965 |
% \begin{macrocode} |
| 966 |
\DeclareOption{color}{% |
| 967 |
\def\cb@ps@color{\expandafter\c@lor@to@ps\cb@current@color\@@}% |
| 968 |
\def\cb@color@pkg{color}} |
| 969 |
% \end{macrocode} |
| 970 |
% The third option adds support for the \pkg{xcolor} package. |
| 971 |
% \changes{v3.4h}{2004/08/26}{Added option \Lopt{xcolor} to support |
| 972 |
% the \pkg{xcolor} package} |
| 973 |
% \begin{macrocode} |
| 974 |
\DeclareOption{xcolor}{% |
| 975 |
\def\cb@ps@color{\expandafter\c@lor@to@ps\cb@current@color\@@}% |
| 976 |
\def\cb@color@pkg{xcolor}} |
| 977 |
% \end{macrocode} |
| 978 |
% |
| 979 |
% Signal an error if an unknown option was specified. |
| 980 |
% \changes{v3.5a}{2005/05/23}{Added 'pdftex' to the option list} |
| 981 |
% \changes{v3.6a}{2011/04/30}{Added 'xetex' to the option list} |
| 982 |
% \begin{macrocode} |
| 983 |
\DeclareOption*{\OptionNotUsed\PackageError |
| 984 |
{changebar}% |
| 985 |
{Unrecognised option `\CurrentOption'\MessageBreak |
| 986 |
known options are dvitoln03, dvitops, dvips,\MessageBreak |
| 987 |
emtex, textures, pdftex, vtex and xetex, |
| 988 |
grey, color, xcolor,\MessageBreak |
| 989 |
outerbars, innerbars, leftbars and rightbars}} |
| 990 |
% \end{macrocode} |
| 991 |
% |
| 992 |
% The default is to have grey change bars on the left side of the |
| 993 |
% text on odd pages. When V\TeX\ is used the option \Lopt{dvips} is |
| 994 |
% not the right one, so in that case we have \Lopt{vtex} as the |
| 995 |
% default driver. |
| 996 |
% When PDF\TeX{} is producing PDF output, the \Lopt{pdftex} option is |
| 997 |
% selected. |
| 998 |
% \changes{v3.2c}{1996/03/26}{Added `dvips' to the list of default |
| 999 |
% options} |
| 1000 |
% \changes{v3.4b}{2001/08/28}{Added `grey' to the list of default |
| 1001 |
% options} |
| 1002 |
% \changes{v3.4d}{2001/09/04}{Added detection of V\TeX} |
| 1003 |
% \changes{v3.5a}{2005/05/23}{Added detection of PDF\TeX} |
| 1004 |
% \changes{v3.6a}{2011/04/30}{Added detection of Xe\TeX} |
| 1005 |
% \begin{macrocode} |
| 1006 |
\ifx\VTeXversion\@undefined |
| 1007 |
\expandafter\ifx\csname XeTeXrevision\endcsname\@undefined |
| 1008 |
\ifx\pdfoutput\@undefined |
| 1009 |
\ExecuteOptions{innerbars,traceoff,dvips,grey} |
| 1010 |
\else |
| 1011 |
\ifnum\pdfoutput>0 |
| 1012 |
\ExecuteOptions{innerbars,traceoff,pdftex,grey} |
| 1013 |
\else |
| 1014 |
\ExecuteOptions{innerbars,traceoff,dvips,grey} |
| 1015 |
\fi |
| 1016 |
\fi |
| 1017 |
\else |
| 1018 |
\ExecuteOptions{innerbars,traceoff,xetex,grey} |
| 1019 |
\fi |
| 1020 |
\else |
| 1021 |
\ExecuteOptions{innerbars,traceoff,vtex,grey} |
| 1022 |
\fi |
| 1023 |
% \end{macrocode} |
| 1024 |
% |
| 1025 |
% A local configuration file may be used to define a site wide |
| 1026 |
% default for the driver, by calling |\ExecuteOptions| with the |
| 1027 |
% appropriate option. This will override the default specified |
| 1028 |
% above. |
| 1029 |
% \changes{v3.4d}{2001/09/04}{Added the possibility of loading a |
| 1030 |
% configuration file} |
| 1031 |
% \begin{macrocode} |
| 1032 |
\InputIfFileExists{changebar.cfg}{}{} |
| 1033 |
% \end{macrocode} |
| 1034 |
% |
| 1035 |
% \begin{macro}{\cb@@show@stack} |
| 1036 |
% \changes{v3.3g}{1999/06/11}{Macro added} |
| 1037 |
% When the stack tracing facility is turned on this command is |
| 1038 |
% executed. It needs to be defined \emph{before} we call |
| 1039 |
% |\ProcessOptions|. This command shows the contents of the stack |
| 1040 |
% with currently `open' bars, the stack with pending ends and the |
| 1041 |
% history stack. It does \emph{not} show the temporary stack. |
| 1042 |
% \changes{v3.3h}{1999/06/15}{Added the historystack to the stack |
| 1043 |
% tracing} |
| 1044 |
% \begin{macrocode} |
| 1045 |
\def\cb@@show@stack#1{% |
| 1046 |
\cb@trace{% |
| 1047 |
stack status at #1:\MessageBreak |
| 1048 |
current stack: \cb@currentstack\MessageBreak |
| 1049 |
\@spaces end stack: \cb@endstack\MessageBreak |
| 1050 |
\space\space begin stack: \cb@beginstack\MessageBreak |
| 1051 |
history stack: \cb@historystack |
| 1052 |
}} |
| 1053 |
% \end{macrocode} |
| 1054 |
% The default is to \emph{not} trace the stacks. This is achieved by |
| 1055 |
% |\let|ting |\cb@trace@stack| to |\@gobble|. |
| 1056 |
% \begin{macrocode} |
| 1057 |
\let\cb@trace@stack\@gobble |
| 1058 |
% \end{macrocode} |
| 1059 |
% \end{macro} |
| 1060 |
% |
| 1061 |
% \begin{macro}{\cb@trace@push} |
| 1062 |
% \begin{macro}{\cb@trace@pop} |
| 1063 |
% \changes{v3.4b}{2001/08/27}{Added macros for tracing stack push and |
| 1064 |
% pop operations} |
| 1065 |
% When stack tracing is turned on, these macros are used to display |
| 1066 |
% the push and pop operations that go on. They are defined when the |
| 1067 |
% package option \Lopt{tracestacks} is selected. |
| 1068 |
% |
| 1069 |
% The default is to \emph{not} trace the stacks. |
| 1070 |
% \begin{macrocode} |
| 1071 |
\let\cb@trace@push\@gobble |
| 1072 |
\let\cb@trace@pop\@gobble |
| 1073 |
% \end{macrocode} |
| 1074 |
% \end{macro} |
| 1075 |
% \end{macro} |
| 1076 |
% |
| 1077 |
% Now make all the selected options active, but... |
| 1078 |
% \begin{macrocode} |
| 1079 |
\ProcessOptions\relax |
| 1080 |
% \end{macrocode} |
| 1081 |
% |
| 1082 |
% We have to make sure that when the document is being processed by |
| 1083 |
% pdf\LaTeX, while also creating pdf as output, the driver to be |
| 1084 |
% used is the pdf driver. Therefore we add an extra check, possibly |
| 1085 |
% overriding a \Lopt{dvips} option that might still have been in |
| 1086 |
% the doucment. |
| 1087 |
% \changes{v3.5b}{2005/05/31}{Added an extra check for pdftex in pdf |
| 1088 |
% mode} |
| 1089 |
% \begin{macrocode} |
| 1090 |
\ifx\pdfsavepos\@undefined |
| 1091 |
\else |
| 1092 |
\ifx\pdfoutput\@undefined |
| 1093 |
\else |
| 1094 |
\ifnum\pdfoutput>0 |
| 1095 |
\global\chardef\cb@driver@setup=6\relax |
| 1096 |
\fi |
| 1097 |
\fi |
| 1098 |
\fi |
| 1099 |
% \end{macrocode} |
| 1100 |
% |
| 1101 |
% \begin{macro}{\cb@trace} |
| 1102 |
% A macro that formats the tracing messages. |
| 1103 |
% \changes{v3.3g}{1999/06/11}{removed line number from tracing |
| 1104 |
% messages} |
| 1105 |
% \begin{macrocode} |
| 1106 |
\newcommand{\cb@trace}[1]{% |
| 1107 |
\if@cb@trace |
| 1108 |
\GenericWarning |
| 1109 |
{(changebar)\@spaces\@spaces}% |
| 1110 |
{Package changebar: #1\@gobble}% |
| 1111 |
\fi |
| 1112 |
} |
| 1113 |
% \end{macrocode} |
| 1114 |
% \end{macro} |
| 1115 |
% |
| 1116 |
% \subsection{User Level Commands And Parameters} |
| 1117 |
% |
| 1118 |
% \begin{macro}{\driver} |
| 1119 |
% The user can select the specials that should be used by calling |
| 1120 |
% the command |\driver{|\meta{drivername}|}|. |
| 1121 |
% \changes{v3.5a}{2005/05/23}{Added 'PDFtex' option} |
| 1122 |
% Possible choices are: |
| 1123 |
% \begin{itemize} |
| 1124 |
% \item DVItoLN03 |
| 1125 |
% \item DVItoPS |
| 1126 |
% \item DVIps |
| 1127 |
% \item em\TeX |
| 1128 |
% \item \TeX tures |
| 1129 |
% \item V\TeX |
| 1130 |
% \item PDF\TeX |
| 1131 |
% \item Xe\TeX |
| 1132 |
% \end{itemize} |
| 1133 |
% This command can only be used in the preamble of the document. |
| 1134 |
% |
| 1135 |
% The argument should be case-insensitive, so it is turned into |
| 1136 |
% a string containing all uppercase characters. To keep some definitions |
| 1137 |
% local, everything is done within a group. |
| 1138 |
% \changes{v3.1}{1993/07/02}{Removed some spurious spaces} |
| 1139 |
% \changes{v3.2c}{1996/03/26}{Reintroduced \cs{driver} in |
| 1140 |
% compatibility mode} |
| 1141 |
% \changes{v3.3e}{1998/02/24}{Added \cs{Textures}} |
| 1142 |
% \changes{v3.5a}{2005/05/23}{Added 'PDFtex' option} |
| 1143 |
% \changes{v3.6a}{2011/04/30}{Added 'XeTeX' option} |
| 1144 |
% \changes{v3.6e}{2023/08/13}{Added 'luaTeX' option} |
| 1145 |
% \begin{macrocode} |
| 1146 |
\if@compatibility |
| 1147 |
\def\driver#1{% |
| 1148 |
\bgroup\edef\next{\def\noexpand\tempa{#1}}% |
| 1149 |
\uppercase\expandafter{\next}% |
| 1150 |
\def\LN{DVITOLN03}% |
| 1151 |
\def\DVItoPS{DVITOPS}% |
| 1152 |
\def\DVIPS{DVIPS}% |
| 1153 |
\def\emTeX{EMTEX}% |
| 1154 |
\def\Textures{TEXTURES}% |
| 1155 |
\def\VTeX{VTEX}% |
| 1156 |
\def\pdfTeX{PDFTEX}% |
| 1157 |
\def\xeTeX{XETEX} |
| 1158 |
\def\luaTeX{LUATEX} |
| 1159 |
% \end{macrocode} |
| 1160 |
% |
| 1161 |
% The choice has to be communicated to the macro |
| 1162 |
% \verb=\cb@setup@specials= that will be called from within |
| 1163 |
% \verb=\document=. For this purpose the control sequence |
| 1164 |
% \verb=\cb@driver@setup= is used. It receives a numeric value |
| 1165 |
% using \verb=\chardef=. |
| 1166 |
% \changes{v3.6a}{2011/04/30}{Added 'XeTeX' option} |
| 1167 |
% \changes{v3.6e}{2023/08/13}{Added 'luaTeX' option} |
| 1168 |
% \begin{macrocode} |
| 1169 |
\global\chardef\cb@driver@setup=0\relax |
| 1170 |
\ifx\tempa\LN \global\chardef\cb@driver@setup=0\fi |
| 1171 |
\ifx\tempa\DVItoPS \global\chardef\cb@driver@setup=1\fi |
| 1172 |
\ifx\tempa\DVIPS \global\chardef\cb@driver@setup=2\fi |
| 1173 |
\ifx\tempa\emTeX \global\chardef\cb@driver@setup=3\fi |
| 1174 |
\ifx\tempa\Textures \global\chardef\cb@driver@setup=4\fi |
| 1175 |
\ifx\tempa\VTeX \global\chardef\cb@driver@setup=5\fi |
| 1176 |
\ifx\tempa\pdfTeX \cb@pdftexcheck\fi |
| 1177 |
\ifx\tempa\xeTeX \cb@xetexcheck\fi |
| 1178 |
\ifx\tempa\luaTeX \cb@luatexcheck\fi |
| 1179 |
\egroup} |
| 1180 |
% \end{macrocode} |
| 1181 |
% We add \verb+\driver+ to \verb+\@preamblecmds+, which is a |
| 1182 |
% list of commands to be used only in the preamble of a document. |
| 1183 |
% \begin{macrocode} |
| 1184 |
{\def\do{\noexpand\do\noexpand} |
| 1185 |
\xdef\@preamblecmds{\@preamblecmds \do\driver} |
| 1186 |
} |
| 1187 |
\fi |
| 1188 |
% \end{macrocode} |
| 1189 |
% \end{macro} |
| 1190 |
% |
| 1191 |
% \begin{macro}{\cb@setup@specials} |
| 1192 |
% The macro |\cb@setup@specials| defines macros containing the |
| 1193 |
% driver specific |\special| macros. It will be called from |
| 1194 |
% within the |\begin{document}| command. |
| 1195 |
% |
| 1196 |
% \begin{macro}{\cb@trace@defpoint} |
| 1197 |
% When tracing is on, write information about the point being defined |
| 1198 |
% to the log file. |
| 1199 |
% \changes{v3.3a}{1997/09/26}{use \cs{cb@trace} instead of \cs{wlog}} |
| 1200 |
% \begin{macrocode} |
| 1201 |
\def\cb@trace@defpoint#1#2{% |
| 1202 |
\cb@trace{% |
| 1203 |
defining point \the#1 at position \the#2 |
| 1204 |
\MessageBreak |
| 1205 |
cb@pagecount: \the\cb@pagecount; page \thepage}} |
| 1206 |
% \end{macrocode} |
| 1207 |
% \end{macro} |
| 1208 |
% |
| 1209 |
% |
| 1210 |
% \begin{macro}{\cb@trace@connect} |
| 1211 |
% When tracing is on, write information about the points being |
| 1212 |
% connected to the log file. |
| 1213 |
% \changes{v3.3a}{1997/09/26}{use \cs{cb@trace} instead of \cs{wlog}} |
| 1214 |
% \begin{macrocode} |
| 1215 |
\def\cb@trace@connect#1#2#3{% |
| 1216 |
\cb@trace{% |
| 1217 |
connecting points \the#1 and \the#2; barwidth: \the#3 |
| 1218 |
\MessageBreak |
| 1219 |
cb@pagecount: \the\cb@pagecount; page \thepage}} |
| 1220 |
% \end{macrocode} |
| 1221 |
% \end{macro} |
| 1222 |
% |
| 1223 |
% \begin{macro}{\cb@defpoint} |
| 1224 |
% The macro |\cb@defpoint| is used to define one of the two |
| 1225 |
% points of a bar. It has two arguments, the number of the point |
| 1226 |
% and the distance from the left side of the paper. Its syntax |
| 1227 |
% is: |
| 1228 |
% |\cb@defpoint{|\meta{number}|}{|\meta{length}|}|. |
| 1229 |
% \begin{macro}{\cb@resetpoints} |
| 1230 |
% The macro |\cb@resetpoints| can be used to instruct the printer |
| 1231 |
% driver that it should send a corresponding instruction to the |
| 1232 |
% printer. This is really only used for the \textsf{LN03} printer. |
| 1233 |
% |
| 1234 |
% \begin{macro}{\cb@connect} |
| 1235 |
% The macro |\cb@connect| is used to instruct the printer driver |
| 1236 |
% to connect two points with a bar. The syntax is |
| 1237 |
% |\cb@connect{|\meta{number}|}{|\meta{number}|}{|\meta{length}|}| |
| 1238 |
% The two \meta{number}s indicate the two points to be connected; |
| 1239 |
% the \meta{length} is the width of the bar. |
| 1240 |
% |
| 1241 |
% \begin{macrocode} |
| 1242 |
\def\cb@setup@specials{% |
| 1243 |
% \end{macrocode} |
| 1244 |
% The control sequence |\cb@driver@setup| expands to a number which |
| 1245 |
% indicates the driver that will be used. The original |
| 1246 |
% \file{changebar.sty} was written with only the |\special| |
| 1247 |
% syntax of the program \texttt{DVItoLN03} (actually one of its |
| 1248 |
% predecessors, \texttt{ln03dvi}). Therefore this syntax is defined |
| 1249 |
% first. |
| 1250 |
% \begin{macrocode} |
| 1251 |
\ifcase\cb@driver@setup |
| 1252 |
\def\cb@defpoint##1##2{% |
| 1253 |
\special{ln03:defpoint \the##1(\the##2,)}% |
| 1254 |
\cb@trace@defpoint##1##2} |
| 1255 |
\def\cb@connect##1##2##3{% |
| 1256 |
\special{ln03:connect \the##1\space\space \the##2\space \the##3}% |
| 1257 |
\cb@trace@connect##1##2##3} |
| 1258 |
\def\cb@resetpoints{% |
| 1259 |
\special{ln03:resetpoints \cb@minpoint \space\cb@maxpoint}} |
| 1260 |
% \end{macrocode} |
| 1261 |
% The first extension to the \textsf{changebar} package was for the |
| 1262 |
% |\special| syntax of the program \texttt{DVItoPS} by James Clark. |
| 1263 |
% \begin{macrocode} |
| 1264 |
\or |
| 1265 |
\def\cb@defpoint##1##2{% |
| 1266 |
\special{dvitops: inline |
| 1267 |
\expandafter\cb@removedim\the##2\space 6.5536 mul\space |
| 1268 |
/CBarX\the##1\space exch def currentpoint exch pop |
| 1269 |
/CBarY\the##1\space exch def}% |
| 1270 |
\cb@trace@defpoint##1##2} |
| 1271 |
% \end{macrocode} |
| 1272 |
% \changes{v3.4b}{2001/08/29}{now use \cs{cb@ps@color} instead of |
| 1273 |
% setting the greyness directly} |
| 1274 |
% \begin{macrocode} |
| 1275 |
\def\cb@connect##1##2##3{% |
| 1276 |
\special{dvitops: inline |
| 1277 |
gsave \cb@ps@color\space |
| 1278 |
\expandafter\cb@removedim\the##3\space 6.5536 mul\space |
| 1279 |
CBarX\the##1\space\space CBarY\the##1\space\space moveto |
| 1280 |
CBarX\the##2\space\space CBarY\the##2\space\space lineto |
| 1281 |
stroke grestore}% |
| 1282 |
\cb@trace@connect##1##2##3} |
| 1283 |
\let\cb@resetpoints\relax |
| 1284 |
% \end{macrocode} |
| 1285 |
% The program \texttt{DVIps} by Thomas Rokicki is also |
| 1286 |
% supported. The PostScript code is nearly the same as for |
| 1287 |
% \texttt{DVItoPS}, but the coordinate space has a different |
| 1288 |
% dimension. Also this code has been made resolution independent, |
| 1289 |
% whereas the code for \texttt{DVItoPS} might still be resolution |
| 1290 |
% dependent. |
| 1291 |
% |
| 1292 |
% So far all the positions have been calculated in \texttt{pt} |
| 1293 |
% units. DVIps uses pixels internally, so we have to convert |
| 1294 |
% \texttt{pt}s into pixels which of course is done by dividing by |
| 1295 |
% 72.27 (\texttt{pt}s per inch) and multiplying by |
| 1296 |
% \texttt{Resolution} giving the resolution of the |
| 1297 |
% \textsc{PostScript} device in use as a \textsc{PostScript} |
| 1298 |
% variable. |
| 1299 |
% \begin{macrocode} |
| 1300 |
\or |
| 1301 |
\def\cb@defpoint##1##2{% |
| 1302 |
\special{ps: |
| 1303 |
\expandafter\cb@removedim\the##2\space |
| 1304 |
Resolution\space mul\space 72.27\space div\space |
| 1305 |
/CBarX\the##1\space exch def currentpoint exch pop |
| 1306 |
/CBarY\the##1\space exch def}% |
| 1307 |
\cb@trace@defpoint##1##2} |
| 1308 |
% \end{macrocode} |
| 1309 |
% \changes{v3.4b}{2001/08/29}{now use \cs{cb@ps@color} instead of |
| 1310 |
% setting the greyness directly} |
| 1311 |
% \begin{macrocode} |
| 1312 |
\def\cb@connect##1##2##3{% |
| 1313 |
\special{ps: |
| 1314 |
gsave \cb@ps@color\space |
| 1315 |
\expandafter\cb@removedim\the##3\space |
| 1316 |
Resolution\space mul\space 72.27\space div\space |
| 1317 |
setlinewidth |
| 1318 |
CBarX\the##1\space\space CBarY\the##1\space\space moveto |
| 1319 |
CBarX\the##2\space\space CBarY\the##2\space\space lineto |
| 1320 |
stroke grestore}% |
| 1321 |
\cb@trace@connect##1##2##3} |
| 1322 |
\let\cb@resetpoints\relax |
| 1323 |
% \end{macrocode} |
| 1324 |
% The following addition is for the drivers written by Eberhard |
| 1325 |
% Mattes. The |\special| syntax used here is supported since |
| 1326 |
% version 1.5 of his driver programs. |
| 1327 |
% \changes{v3.3a}{1997/09/24}{Removed warning about emTeX support from |
| 1328 |
% dvidrv 1.5 upwards} |
| 1329 |
% \changes{v3.3b}{1997/10/01}{em\TeX{} drivers have their origin in a |
| 1330 |
% different position then dvips} |
| 1331 |
% \changes{v3.3d}{1997/10/28}{Removed bogus offset} |
| 1332 |
% \begin{macrocode} |
| 1333 |
\or |
| 1334 |
\def\cb@defpoint##1##2{% |
| 1335 |
\special{em:point \the##1,\the##2}% |
| 1336 |
\cb@trace@defpoint##1##2} |
| 1337 |
\def\cb@connect##1##2##3{% |
| 1338 |
\special{em:line \the##1,\the##2,\the##3}% |
| 1339 |
\cb@trace@connect##1##2##3} |
| 1340 |
\let\cb@resetpoints\relax |
| 1341 |
% \end{macrocode} |
| 1342 |
% |
| 1343 |
% The following definitions are validated with \TeX tures |
| 1344 |
% version~1.7.7, but will very likely also work with later |
| 1345 |
% releases of \TeX tures. |
| 1346 |
% |
| 1347 |
% The \cs{cbdelete} command seemed to create degenerate lines |
| 1348 |
% (i.e., lines of 0 length). PostScript will not render such lines |
| 1349 |
% unless the linecap is set to 1, (semicircular ends) in which case |
| 1350 |
% a filled circle is shown for such lines. |
| 1351 |
% \changes{v3.3e}{1998/02/24}{Added the definitions for textures |
| 1352 |
% support} |
| 1353 |
% \changes{v3.5c}{2005/09/18}{A small change was submitted by Gordon |
| 1354 |
% Lee from Blue Sky Systems} |
| 1355 |
% \begin{macrocode} |
| 1356 |
\or |
| 1357 |
\def\cb@defpoint##1##2{% |
| 1358 |
\special{postscript 0 0 transform}% leave [x,y] on the stack |
| 1359 |
\special{rawpostscript |
| 1360 |
\expandafter\cb@removedim\the##2\space |
| 1361 |
/CBarX\the##1\space exch def |
| 1362 |
itransform exch pop |
| 1363 |
/CBarY\the##1\space exch def}% |
| 1364 |
\if@cb@trace\cb@trace@defpoint##1##2\fi} |
| 1365 |
% \end{macrocode} |
| 1366 |
% \changes{v3.4b}{2001/08/29}{now use \cs{cb@ps@color} instead of |
| 1367 |
% setting the greyness directly} |
| 1368 |
% \begin{macrocode} |
| 1369 |
\def\cb@connect##1##2##3{% |
| 1370 |
\special{rawpostscript |
| 1371 |
gsave 1 setlinecap \cb@ps@color\space |
| 1372 |
\expandafter\cb@removedim\the##3\space |
| 1373 |
setlinewidth |
| 1374 |
CBarX\the##1\space\space CBarY\the##1\space\space moveto |
| 1375 |
CBarX\the##2\space\space CBarY\the##2\space\space lineto |
| 1376 |
stroke grestore}% |
| 1377 |
\if@cb@trace\cb@trace@connect##1##2##3\fi} |
| 1378 |
\let\cb@resetpoints\relax |
| 1379 |
% \end{macrocode} |
| 1380 |
% The following definitions were kindly provided by Michael Vulis. |
| 1381 |
% \changes{v3.4a}{2001/04/18}{Added the definitions for V\TeX\ |
| 1382 |
% support} |
| 1383 |
% \begin{macrocode} |
| 1384 |
\or |
| 1385 |
\def\cb@defpoint##1##2{% |
| 1386 |
\special{pS: |
| 1387 |
\expandafter\cb@removedim\the##2\space |
| 1388 |
Resolution\space mul\space 72.27\space div\space |
| 1389 |
/CBarX\the##1\space exch def currentpoint exch pop |
| 1390 |
/CBarY\the##1\space exch def}% |
| 1391 |
\cb@trace@defpoint##1##2} |
| 1392 |
% \end{macrocode} |
| 1393 |
% \changes{v3.4b}{2001/08/29}{now use \cs{cb@ps@color} instead of |
| 1394 |
% setting the greyness directly} |
| 1395 |
% \begin{macrocode} |
| 1396 |
\def\cb@connect##1##2##3{% |
| 1397 |
\special{pS: |
| 1398 |
gsave \cb@ps@color\space |
| 1399 |
\expandafter\cb@removedim\the##3\space |
| 1400 |
Resolution\space mul\space 72.27\space div\space |
| 1401 |
setlinewidth |
| 1402 |
CBarX\the##1\space\space CBarY\the##1\space\space moveto |
| 1403 |
CBarX\the##2\space\space CBarY\the##2\space\space lineto |
| 1404 |
stroke grestore}% |
| 1405 |
\cb@trace@connect##1##2##3} |
| 1406 |
\let\cb@resetpoints\relax |
| 1407 |
% \end{macrocode} |
| 1408 |
% \changes{v3.5a}{2005/05/23}{PDF\TeX{} support added} |
| 1409 |
% The code for PDF\TeX{} is more elaborate as the calculations have to |
| 1410 |
% be done in \TeX. |\cb@defpoint| will write information about the |
| 1411 |
% coordinates of the point to the \file{.aux} file, from where it will |
| 1412 |
% be picked up in the next run. Then we will construct the PDF |
| 1413 |
% code necessary to draw the changebars. |
| 1414 |
% \begin{macrocode} |
| 1415 |
\or |
| 1416 |
\immediate\closeout\cb@writexy |
| 1417 |
\immediate\openin\cb@readxy=\jobname.cb2\relax |
| 1418 |
% \end{macrocode} |
| 1419 |
% |
| 1420 |
% \begin{macro}{\cb@pdfpoints} |
| 1421 |
% \begin{macro}{\cb@pdfpagenr} |
| 1422 |
% The |\cb@pdfpoints| macro contains the list of coordinates of points |
| 1423 |
% that have been read in memory from the \file{.cb2} file. The |
| 1424 |
% |\cb@pdfpagenr| macro contains the next pagecount to be read in. |
| 1425 |
% \begin{macrocode} |
| 1426 |
\def\cb@pdfpoints{} |
| 1427 |
\def\cb@pdfpagenr{0} |
| 1428 |
% \end{macrocode} |
| 1429 |
% \end{macro} |
| 1430 |
% \end{macro} |
| 1431 |
% \begin{macro}{\cb@findpdfpoint} |
| 1432 |
% The |\cb@findpdfpoint| macro finds the coordinates of point \#1 on |
| 1433 |
% pagecount \#2. First we expand the arguments to get the real values. |
| 1434 |
% \begin{macrocode} |
| 1435 |
\def\cb@findpdfpoint##1##2{% |
| 1436 |
\edef\cb@temp |
| 1437 |
{\noexpand\cb@@findpdfpoint{\the##1}{\the##2}}% |
| 1438 |
\cb@temp |
| 1439 |
} |
| 1440 |
% \end{macrocode} |
| 1441 |
% \end{macro} |
| 1442 |
% |
| 1443 |
% \begin{macro}{\cb@@findpdfpoint} |
| 1444 |
% The |\cb@@findpdfpoint| macro finds the coordinates of point \#1 on |
| 1445 |
% pagecount \#2. If the information is not yet in memory is it read from |
| 1446 |
% the \file{.cb2} file. The coordinates of the current point in the text |
| 1447 |
% will be delivered in |\cb@pdfx| and |\cb@pdfy|, and |\cb@pdfz| will get |
| 1448 |
% the x coordinate of the changebar. If the point is unknown, |\cb@pdfx| |
| 1449 |
% will be set to |\relax|. |
| 1450 |
% \begin{macrocode} |
| 1451 |
\def\cb@@findpdfpoint##1##2{% |
| 1452 |
\ifnum##2<\cb@pdfpagenr\relax\else |
| 1453 |
\cb@pdfreadxy{##2}% |
| 1454 |
\fi |
| 1455 |
\let\cb@pdfx\relax |
| 1456 |
\ifx\cb@pdfpoints\@empty\else |
| 1457 |
\ifnum##2<0\relax |
| 1458 |
\else |
| 1459 |
\edef\cb@temp{\noexpand\cb@pdffind{##1}{##2}\cb@pdfpoints\relax{}}% |
| 1460 |
\cb@temp |
| 1461 |
\fi |
| 1462 |
\fi |
| 1463 |
} |
| 1464 |
% \end{macrocode} |
| 1465 |
% \end{macro} |
| 1466 |
% |
| 1467 |
% \begin{macro}{\cb@pdffind} |
| 1468 |
% The |\cb@pdffind| recursively searches through |\cb@pdfpoints| to find |
| 1469 |
% point \#1 on pagecount \#2. |\cb@pdfpoints| contains entries of the |
| 1470 |
% form\\ |
| 1471 |
% \meta{pointnr}.\meta{pagecount}p\meta{x},\meta{y},\meta{z}pt. |
| 1472 |
% When the point is found it is removed from |\cb@pdfpoints|. \#9 |
| 1473 |
% contains the cumulative head of the list to construct the new list |
| 1474 |
% with the entry removed. \#3--\#8 are for pattern matching. |
| 1475 |
% \changes{v3.7b}{2023/12/30}{use ";" instead of "," as delimiter} |
| 1476 |
% \changes{v3.7e}{2024/07/17}{Use "/" instead of ";" as delimiter} |
| 1477 |
% \begin{changebar} |
| 1478 |
% \begin{macrocode} |
| 1479 |
\def\cb@pdffind##1##2##3.##4p##5/##6/##7pt##8\relax##9{% |
| 1480 |
% \end{macrocode} |
| 1481 |
% \end{changebar} |
| 1482 |
% \begin{macrocode} |
| 1483 |
\def\cb@next{% |
| 1484 |
% \end{macrocode} |
| 1485 |
% \begin{changebar} |
| 1486 |
% \begin{macrocode} |
| 1487 |
\cb@pdffind{##1}{##2}##8\relax{##9##3.##4p##5/##6/##7pt}}% |
| 1488 |
% \end{macrocode} |
| 1489 |
% \end{changebar} |
| 1490 |
% \begin{macrocode} |
| 1491 |
\ifnum ##1=##3 |
| 1492 |
\ifnum ##2=##4 |
| 1493 |
\def\cb@pdfx{##5sp}% |
| 1494 |
\def\cb@pdfy{##6sp}% |
| 1495 |
\def\cb@pdfz{##7pt}% |
| 1496 |
\let\cb@next\relax |
| 1497 |
\gdef\cb@pdfpoints{##9##8}% |
| 1498 |
\fi |
| 1499 |
\fi |
| 1500 |
\ifx\relax##8\relax |
| 1501 |
\let\cb@next\relax |
| 1502 |
\fi |
| 1503 |
\cb@next |
| 1504 |
}% |
| 1505 |
% \end{macrocode} |
| 1506 |
% \end{macro} |
| 1507 |
% |
| 1508 |
% \begin{macro}{\cb@pdfreadxy} |
| 1509 |
% The |\cb@pdfreadxy| macro reads lines from the \file{.cb2} file in |
| 1510 |
% |\cb@pdfpoints| until the pagecount is greater than \#1 or the end of |
| 1511 |
% the file is reached. This ensures that all entries belonging to the |
| 1512 |
% current column are in memory. |
| 1513 |
% \begin{macrocode} |
| 1514 |
\def\cb@pdfreadxy##1{% |
| 1515 |
\let\cb@next\relax |
| 1516 |
\ifeof\cb@readxy |
| 1517 |
\global\let\cb@pdfpagenr\cb@maxpoint |
| 1518 |
\else |
| 1519 |
{\endlinechar=-1\read\cb@readxy to\cb@temp |
| 1520 |
\ifx\cb@temp\@empty\else |
| 1521 |
\expandafter\cb@pdfparsexy\cb@temp |
| 1522 |
\ifnum\cb@pdfpg<0\else |
| 1523 |
\xdef\cb@pdfpoints{\cb@pdfpoints\cb@temp}% |
| 1524 |
\cb@trace{PDFpoints=\cb@pdfpoints}% |
| 1525 |
\global\let\cb@pdfpagenr\cb@pdfpg |
| 1526 |
\fi |
| 1527 |
\ifnum\cb@pdfpg>##1\else |
| 1528 |
\global\def\cb@next{\cb@pdfreadxy{##1}}% |
| 1529 |
\fi |
| 1530 |
\fi |
| 1531 |
}% |
| 1532 |
\fi |
| 1533 |
\cb@next |
| 1534 |
}% |
| 1535 |
% \end{macrocode} |
| 1536 |
% \end{macro} |
| 1537 |
% |
| 1538 |
% \begin{macro}{\cb@pdfparsexy} |
| 1539 |
% The |\cb@pdfparsexy| macro extracts the pagecount from an entry read in |
| 1540 |
% from the \file{.cb2} file. |
| 1541 |
% \changes{v3.7e}{2024/07/17}{Use "/" instead of ";" as delimiter} |
| 1542 |
% \begin{changebar} |
| 1543 |
% \begin{macrocode} |
| 1544 |
\def\cb@pdfparsexy##1.##2p##3/##4/##5pt{% |
| 1545 |
% \end{macrocode} |
| 1546 |
% \end{changebar} |
| 1547 |
% \begin{macrocode} |
| 1548 |
\def\cb@pdfpg{##2}}% |
| 1549 |
% \end{macrocode} |
| 1550 |
% \end{macro} |
| 1551 |
% |
| 1552 |
% As PDF is not a programming language it does not have any variables to |
| 1553 |
% remember the coordinates of the current point. Therefore we write the |
| 1554 |
% information to the \file{.aux} file and read it in in the next run. We |
| 1555 |
% write the x,y coordinates of the current point in the text and the x |
| 1556 |
% coordinate of the change bar. |
| 1557 |
% We also need the value of |\cb@pagecount| here, not during the write. |
| 1558 |
% \begin{macrocode} |
| 1559 |
\def\cb@defpoint##1##2{% |
| 1560 |
\if@filesw |
| 1561 |
\begingroup |
| 1562 |
\edef\point{{\the##1}{\the\cb@pagecount}}% |
| 1563 |
\let\the=\z@ |
| 1564 |
\pdfsavepos |
| 1565 |
\edef\cb@temp{\write\@auxout |
| 1566 |
{\string\cb@pdfxy\point |
| 1567 |
{\the\pdflastxpos}{\the\pdflastypos}{\the##2}}}% |
| 1568 |
\cb@temp |
| 1569 |
\endgroup |
| 1570 |
\fi |
| 1571 |
\cb@trace@defpoint##1##2% |
| 1572 |
}% |
| 1573 |
% \end{macrocode} |
| 1574 |
% |
| 1575 |
% \begin{macro}{\cb@cvtpct} |
| 1576 |
% The macro |\cb@cvtpct| converts a percentage between 0 and 100 to a |
| 1577 |
% decimal fraction. |
| 1578 |
% \begin{macrocode} |
| 1579 |
\def\cb@cvtpct##1{% |
| 1580 |
\ifnum##1<0 0\else |
| 1581 |
\ifnum##1>99 1\else |
| 1582 |
\ifnum##1<10 0.0\the##1\else |
| 1583 |
0.\the##1\fi\fi\fi} |
| 1584 |
% \end{macrocode} |
| 1585 |
% \end{macro} |
| 1586 |
% |
| 1587 |
% \begin{macro}{\cb@pdf@scale} |
| 1588 |
% \changes{v3.6a}{2018/02/03}{Added macro for scale factor} |
| 1589 |
% In order to get things in the right spot we need a little scaling |
| 1590 |
% factor. We define it here. |
| 1591 |
% \begin{macrocode} |
| 1592 |
\def\cb@pdf@scale{0.996264009963} |
| 1593 |
% \end{macrocode} |
| 1594 |
% \end{macro} |
| 1595 |
% |
| 1596 |
% The |\cb@connect| finds the coordinates of the begin and end points, |
| 1597 |
% converts them to PDF units and draws the bar with |\pdfliteral|. It |
| 1598 |
% also sets the color or gray level, if necessary. When any of the |
| 1599 |
% points is unknown the bar is skipped and a rerun is signalled. |
| 1600 |
% \begin{macrocode} |
| 1601 |
\def\cb@connect##1##2##3{% |
| 1602 |
\cb@findpdfpoint{##1}\cb@pagecount |
| 1603 |
\ifx\cb@pdfx\relax\cb@rerun |
| 1604 |
\else |
| 1605 |
\let\cb@pdftopy\cb@pdfy |
| 1606 |
\cb@findpdfpoint{##2}\cb@pagecount |
| 1607 |
\ifx\cb@pdfx\relax\cb@rerun |
| 1608 |
\else |
| 1609 |
% \end{macrocode} |
| 1610 |
% We do everything in a group, so that we can freely use all kinds of |
| 1611 |
% registers. |
| 1612 |
% \begin{macrocode} |
| 1613 |
\begingroup |
| 1614 |
\cb@dima=\cb@pdfz |
| 1615 |
\advance\cb@dima by-\cb@pdfx |
| 1616 |
\advance\cb@dima by1in% |
| 1617 |
\cb@dima=\cb@pdf@scale\cb@dima\relax |
| 1618 |
% \end{macrocode} |
| 1619 |
% First we let PDF save the graphics state. Then we generate the color |
| 1620 |
% selection code followed by the code to draw the changebar. Finally the |
| 1621 |
% graphics state is restored. We cannot use the color commands from the |
| 1622 |
% color package here, as the generated PDF code may be moved to the next |
| 1623 |
% line. |
| 1624 |
% \begin{macrocode} |
| 1625 |
\ifx\cb@current@color\@undefined |
| 1626 |
\def\cb@temp{\cb@cvtpct\c@changebargrey}% |
| 1627 |
\pdfliteral{q \cb@temp\space g \cb@temp\space G}% |
| 1628 |
\else |
| 1629 |
\pdfliteral{q \cb@current@color}% |
| 1630 |
\fi |
| 1631 |
\edef\cb@temp{\expandafter\cb@removedim\the\cb@dima\space}% |
| 1632 |
\cb@dima=\cb@pdftopy |
| 1633 |
\advance\cb@dima-\cb@pdfy\relax |
| 1634 |
\cb@dima=\cb@pdf@scale\cb@dima\relax |
| 1635 |
##3=\cb@pdf@scale##3\relax |
| 1636 |
\pdfliteral direct{\expandafter\cb@removedim\the##3 w |
| 1637 |
\cb@temp 0 m |
| 1638 |
\cb@temp \expandafter\cb@removedim\the\cb@dima\space l S Q}% |
| 1639 |
\endgroup |
| 1640 |
% \end{macrocode} |
| 1641 |
% We look up the two unused points to get them removed from |\cb@pdfpoints|. |
| 1642 |
% \begin{macrocode} |
| 1643 |
\cb@cntb=##1\relax |
| 1644 |
\ifodd\cb@cntb\advance\cb@cntb 1\else\advance\cb@cntb -1\fi |
| 1645 |
\cb@findpdfpoint\cb@cntb\cb@pagecount |
| 1646 |
\cb@cntb=##2\relax |
| 1647 |
\ifodd\cb@cntb\advance\cb@cntb 1\else\advance\cb@cntb -1\fi |
| 1648 |
\cb@findpdfpoint\cb@cntb\cb@pagecount |
| 1649 |
\fi |
| 1650 |
\fi |
| 1651 |
\cb@trace@connect##1##2##3% |
| 1652 |
}% |
| 1653 |
% \end{macrocode} |
| 1654 |
% |
| 1655 |
% \begin{macro}{\cb@checkPdfxy} |
| 1656 |
% The macro |\cb@checkPdfxy| checks if the coordinates of a point have |
| 1657 |
% changed during the current run. If so, we need to rerun \LaTeX. |
| 1658 |
% \changes{v3.6c}{2018/03/09}{Use \cs{ifdim} instead of \cs{ifnum} as |
| 1659 |
% \cs{cb@pdfx} is defined as a dimension} |
| 1660 |
% \begin{macrocode} |
| 1661 |
\gdef\cb@checkPdfxy##1##2##3##4##5{% |
| 1662 |
\cb@@findpdfpoint{##1}{##2}% |
| 1663 |
% \end{macrocode} |
| 1664 |
% \begin{macrocode} |
| 1665 |
\ifdim##3sp=\cb@pdfx\relax |
| 1666 |
\ifdim##4sp=\cb@pdfy\relax |
| 1667 |
% \end{macrocode} |
| 1668 |
% \begin{macrocode} |
| 1669 |
\ifdim##5=\cb@pdfz\relax |
| 1670 |
\else |
| 1671 |
\cb@error |
| 1672 |
\fi |
| 1673 |
\else |
| 1674 |
\cb@error |
| 1675 |
\fi |
| 1676 |
\else |
| 1677 |
\cb@error |
| 1678 |
\fi |
| 1679 |
} |
| 1680 |
% \end{macrocode} |
| 1681 |
% \end{macro} |
| 1682 |
% |
| 1683 |
% For PDF\TeX{} we don't need a limit on the number of bar points. |
| 1684 |
% \begin{macrocode} |
| 1685 |
\def\cb@maxpoint{9999999} |
| 1686 |
\let\cb@resetpoints\relax |
| 1687 |
\or |
| 1688 |
% \end{macrocode} |
| 1689 |
% |
| 1690 |
% \changes{v3.6a}{2011/04/30}{Xe\TeX{} support added} |
| 1691 |
% The code for Xe\TeX{} is, like for PDF\TeX{}, more elaborate as |
| 1692 |
% the calculations have to |
| 1693 |
% be done in \TeX. |\cb@defpoint| will write information about the |
| 1694 |
% coordinates of the point to the \file{.aux} file, from where it will |
| 1695 |
% be picked up in the next run. Then we will construct the PDF |
| 1696 |
% code necessary to draw the changebars. |
| 1697 |
% \begin{macrocode} |
| 1698 |
\immediate\closeout\cb@writexy |
| 1699 |
\immediate\openin\cb@readxy=\jobname.cb2\relax |
| 1700 |
% \end{macrocode} |
| 1701 |
% |
| 1702 |
% \begin{macro}{\cb@pdfpoints} |
| 1703 |
% \begin{macro}{\cb@pdfpagenr} |
| 1704 |
% The |\cb@pdfpoints| macro contains the list of coordinates of points |
| 1705 |
% that have been read in memory from the \file{.cb2} file. The |
| 1706 |
% |\cb@pdfpagenr| macro contains the next pagecount to be read in. |
| 1707 |
% \begin{macrocode} |
| 1708 |
\def\cb@pdfpoints{} |
| 1709 |
\def\cb@pdfpagenr{0} |
| 1710 |
% \end{macrocode} |
| 1711 |
% \end{macro} |
| 1712 |
% \end{macro} |
| 1713 |
% |
| 1714 |
% \begin{macro}{\cb@findpdfpoint} |
| 1715 |
% The |\cb@findpdfpoint| macro finds the coordinates of point \#1 on |
| 1716 |
% pagecount \#2. First we expand the arguments to get the real values. |
| 1717 |
% \begin{macrocode} |
| 1718 |
\def\cb@findpdfpoint##1##2{% |
| 1719 |
\edef\cb@temp |
| 1720 |
{\noexpand\cb@@findpdfpoint{\the##1}{\the##2}}% |
| 1721 |
\cb@temp |
| 1722 |
} |
| 1723 |
% \end{macrocode} |
| 1724 |
% \end{macro} |
| 1725 |
% |
| 1726 |
% \begin{macro}{\pdfliteral} |
| 1727 |
% For Xe\TeX{} we mimick PDF\TeX's command |\pdfliteral|. |
| 1728 |
% \begin{macrocode} |
| 1729 |
\def\pdfliteral##1{\special{pdf:literal ##1}} |
| 1730 |
% \end{macrocode} |
| 1731 |
% \end{macro} |
| 1732 |
% |
| 1733 |
% \begin{macro}{\cb@@findpdfpoint} |
| 1734 |
% The |\cb@@findpdfpoint| macro finds the coordinates of point \#1 on |
| 1735 |
% pagecount \#2. If the information is not yet in memory is it read from |
| 1736 |
% the \file{.cb2} file. The coordinates of the current point in the text |
| 1737 |
% will be delivered in |\cb@pdfx| and |\cb@pdfy|, and |\cb@pdfz| will get |
| 1738 |
% the x coordinate of the changebar. If the point is unknown, |\cb@pdfx| |
| 1739 |
% will be set to |\relax|. |
| 1740 |
% \begin{macrocode} |
| 1741 |
\def\cb@@findpdfpoint##1##2{% |
| 1742 |
\ifnum##2<\cb@pdfpagenr\relax\else |
| 1743 |
\cb@pdfreadxy{##2}% |
| 1744 |
\fi |
| 1745 |
\let\cb@pdfx\relax |
| 1746 |
\ifx\cb@pdfpoints\@empty\else |
| 1747 |
\ifnum##2<0\relax |
| 1748 |
\else |
| 1749 |
\edef\cb@temp{% |
| 1750 |
\noexpand\cb@pdffind{##1}{##2}\cb@pdfpoints\relax{}}% |
| 1751 |
\cb@temp |
| 1752 |
\fi |
| 1753 |
\fi |
| 1754 |
} |
| 1755 |
% \end{macrocode} |
| 1756 |
% \end{macro} |
| 1757 |
% |
| 1758 |
% \begin{macro}{\cb@pdffind} |
| 1759 |
% The |\cb@pdffind| recursively searches through |\cb@pdfpoints| to find |
| 1760 |
% point \#1 on pagecount \#2. |\cb@pdfpoints| contains entries of the |
| 1761 |
% form\\ |
| 1762 |
% \meta{pointnr}.\meta{pagecount}p\meta{x},\meta{y},\meta{z}pt. |
| 1763 |
% When the point is found it is removed from |\cb@pdfpoints|. \#9 |
| 1764 |
% contains the cumulative head of the list to construct the new list |
| 1765 |
% with the entry removed. \#3--\#8 are for pattern matching. |
| 1766 |
% \changes{v3.7b}{2023/12/30}{use ";" instead of "," as delimiter} |
| 1767 |
% \changes{v3.7e}{2024/07/17}{Use "/" instead of ";" as delimiter} |
| 1768 |
% \begin{changebar} |
| 1769 |
% \begin{macrocode} |
| 1770 |
\def\cb@pdffind##1##2##3.##4p##5/##6/##7pt##8\relax##9{% |
| 1771 |
% \end{macrocode} |
| 1772 |
% \end{changebar} |
| 1773 |
% \begin{macrocode} |
| 1774 |
\def\cb@next{% |
| 1775 |
% \end{macrocode} |
| 1776 |
% \begin{changebar} |
| 1777 |
% \begin{macrocode} |
| 1778 |
\cb@pdffind{##1}{##2}##8\relax{##9##3.##4p##5/##6/##7pt}}% |
| 1779 |
% \end{macrocode} |
| 1780 |
% \end{changebar} |
| 1781 |
% \begin{macrocode} |
| 1782 |
\ifnum ##1=##3 |
| 1783 |
\ifnum ##2=##4 |
| 1784 |
\def\cb@pdfx{##5sp}% |
| 1785 |
\def\cb@pdfy{##6sp}% |
| 1786 |
\def\cb@pdfz{##7pt}% |
| 1787 |
\let\cb@next\relax |
| 1788 |
\gdef\cb@pdfpoints{##9##8}% |
| 1789 |
\fi |
| 1790 |
\fi |
| 1791 |
\ifx\relax##8\relax |
| 1792 |
\let\cb@next\relax |
| 1793 |
\fi |
| 1794 |
\cb@next |
| 1795 |
}% |
| 1796 |
% \end{macrocode} |
| 1797 |
% \end{macro} |
| 1798 |
% |
| 1799 |
% \begin{macro}{\cb@pdfreadxy} |
| 1800 |
% The |\cb@pdfreadxy| macro reads lines from the \file{.cb2} file in |
| 1801 |
% |\cb@pdfpoints| until the pagecount is greater than \#1 or the end of |
| 1802 |
% the file is reached. This ensures that all entries belonging to the |
| 1803 |
% current column are in memory. |
| 1804 |
% \begin{macrocode} |
| 1805 |
\def\cb@pdfreadxy##1{% |
| 1806 |
\let\cb@next\relax |
| 1807 |
\ifeof\cb@readxy |
| 1808 |
\global\let\cb@pdfpagenr\cb@maxpoint |
| 1809 |
\else |
| 1810 |
{\endlinechar=-1\read\cb@readxy to\cb@temp |
| 1811 |
\ifx\cb@temp\@empty\else |
| 1812 |
\expandafter\cb@pdfparsexy\cb@temp |
| 1813 |
\ifnum\cb@pdfpg<0\else |
| 1814 |
\xdef\cb@pdfpoints{\cb@pdfpoints\cb@temp}% |
| 1815 |
\cb@trace{PDFpoints=\cb@pdfpoints}% |
| 1816 |
\global\let\cb@pdfpagenr\cb@pdfpg |
| 1817 |
\fi |
| 1818 |
\ifnum\cb@pdfpg>##1\else |
| 1819 |
\global\def\cb@next{\cb@pdfreadxy{##1}}% |
| 1820 |
\fi |
| 1821 |
\fi |
| 1822 |
}% |
| 1823 |
\fi |
| 1824 |
\cb@next |
| 1825 |
}% |
| 1826 |
% \end{macrocode} |
| 1827 |
% \end{macro} |
| 1828 |
% |
| 1829 |
% \begin{macro}{\cb@pdfparsexy} |
| 1830 |
% The |\cb@pdfparsexy| macro extracts the pagecount from an entry read in |
| 1831 |
% from the \file{.cb2} file. |
| 1832 |
% \changes{v3.7e}{2024/07/17}{Use "/" instead of ";" as delimiter} |
| 1833 |
% \begin{changebar} |
| 1834 |
% \begin{macrocode} |
| 1835 |
\def\cb@pdfparsexy##1.##2p##3/##4/##5pt{% |
| 1836 |
% \end{macrocode} |
| 1837 |
% \end{changebar} |
| 1838 |
% \begin{macrocode} |
| 1839 |
\def\cb@pdfpg{##2}}% |
| 1840 |
% \end{macrocode} |
| 1841 |
% \end{macro} |
| 1842 |
% |
| 1843 |
% As \textsc{pdf} is not a programming language it does not have |
| 1844 |
% any variables to remember the coordinates of the current |
| 1845 |
% point. Therefore we write the information to the \file{.aux} file |
| 1846 |
% and read it in in the next run. We write the x,y coordinates of |
| 1847 |
% the current point in the text and the x coordinate of the change bar. |
| 1848 |
% We also need the value of |\cb@pagecount| here, not during the write. |
| 1849 |
% \begin{macrocode} |
| 1850 |
\def\cb@defpoint##1##2{% |
| 1851 |
\if@filesw |
| 1852 |
\begingroup |
| 1853 |
\edef\point{{\the##1}{\the\cb@pagecount}}% |
| 1854 |
\let\the=\z@ |
| 1855 |
\pdfsavepos |
| 1856 |
\edef\cb@temp{\write\@auxout |
| 1857 |
{\string\cb@pdfxy\point |
| 1858 |
{\the\pdflastxpos}{\the\pdflastypos}{\the##2}}}% |
| 1859 |
\cb@temp |
| 1860 |
\endgroup |
| 1861 |
\fi |
| 1862 |
\cb@trace@defpoint##1##2% |
| 1863 |
}% |
| 1864 |
% \end{macrocode} |
| 1865 |
% |
| 1866 |
% \begin{macro}{\cb@cvtpct} |
| 1867 |
% The macro |\cb@cvtpct| converts a percentage between 0 and 100 to a |
| 1868 |
% decimal fraction. |
| 1869 |
% \begin{macrocode} |
| 1870 |
\def\cb@cvtpct##1{% |
| 1871 |
\ifnum##1<0 0\else |
| 1872 |
\ifnum##1>99 1\else |
| 1873 |
\ifnum##1<10 0.0\the##1\else |
| 1874 |
0.\the##1\fi\fi\fi} |
| 1875 |
% \end{macrocode} |
| 1876 |
% \end{macro} |
| 1877 |
% |
| 1878 |
% \begin{macro}{\cb@pdf@scale} |
| 1879 |
% \changes{v3.6a}{2018/02/03}{Added macro for scale factor} |
| 1880 |
% In order to get things in the right spot we need a little scaling |
| 1881 |
% factor. We define it here. |
| 1882 |
% \begin{macrocode} |
| 1883 |
\def\cb@pdf@scale{0.996264009963} |
| 1884 |
% \end{macrocode} |
| 1885 |
% \end{macro} |
| 1886 |
% |
| 1887 |
% The |\cb@connect| finds the coordinates of the begin and end points, |
| 1888 |
% converts them to PDF units and draws the bar with |\pdfliteral|. It |
| 1889 |
% also sets the color or gray level, if necessary. When any of the |
| 1890 |
% points is unknown the bar is skipped and a rerun is signalled. |
| 1891 |
% \begin{macrocode} |
| 1892 |
\def\cb@connect##1##2##3{% |
| 1893 |
\cb@findpdfpoint{##1}\cb@pagecount |
| 1894 |
\ifx\cb@pdfx\relax\cb@rerun |
| 1895 |
\else |
| 1896 |
\let\cb@pdftopy\cb@pdfy |
| 1897 |
\cb@findpdfpoint{##2}\cb@pagecount |
| 1898 |
\ifx\cb@pdfx\relax\cb@rerun |
| 1899 |
\else |
| 1900 |
% \end{macrocode} |
| 1901 |
% We do everything in a group, so that we can freely use all kinds of |
| 1902 |
% registers. |
| 1903 |
% \begin{macrocode} |
| 1904 |
\begingroup |
| 1905 |
\cb@dima=\cb@pdfz |
| 1906 |
\advance\cb@dima by-\cb@pdfx |
| 1907 |
\advance\cb@dima by1in% |
| 1908 |
\cb@dima=\cb@pdf@scale\cb@dima\relax |
| 1909 |
% \end{macrocode} |
| 1910 |
% First we let PDF save the graphics state. Then we generate the color |
| 1911 |
% selection code followed by the code to draw the changebar. Finally the |
| 1912 |
% graphics state is restored. We cannot use the color commands from the |
| 1913 |
% color package here, as the generated PDF code may be moved to the next |
| 1914 |
% line. |
| 1915 |
% \begin{macrocode} |
| 1916 |
\ifx\cb@current@color\@undefined |
| 1917 |
\def\cb@temp{\cb@cvtpct\c@changebargrey}% |
| 1918 |
\pdfliteral{q \cb@temp\space g \cb@temp\space G}% |
| 1919 |
\else |
| 1920 |
\pdfliteral{q \expandafter\sec@nd@ftw@\cb@current@color\space RG |
| 1921 |
\expandafter\sec@nd@ftw@\cb@current@color\space rg}% |
| 1922 |
\fi |
| 1923 |
\edef\cb@temp{\expandafter\cb@removedim\the\cb@dima\space}% |
| 1924 |
\cb@dima=\cb@pdftopy |
| 1925 |
\advance\cb@dima-\cb@pdfy\relax |
| 1926 |
\cb@dima=\cb@pdf@scale\cb@dima\relax |
| 1927 |
##3=\cb@pdf@scale##3\relax |
| 1928 |
\pdfliteral{\expandafter\cb@removedim\the##3 w |
| 1929 |
\cb@temp 0 m |
| 1930 |
\cb@temp \expandafter\cb@removedim\the\cb@dima\space l S Q}% |
| 1931 |
\endgroup |
| 1932 |
% \end{macrocode} |
| 1933 |
% We look up the two unused points to get them removed from |\cb@pdfpoints|. |
| 1934 |
% \begin{macrocode} |
| 1935 |
\cb@cntb=##1\relax |
| 1936 |
\ifodd\cb@cntb\advance\cb@cntb 1\else\advance\cb@cntb -1\fi |
| 1937 |
\cb@findpdfpoint\cb@cntb\cb@pagecount |
| 1938 |
\cb@cntb=##2\relax |
| 1939 |
\ifodd\cb@cntb\advance\cb@cntb 1\else\advance\cb@cntb -1\fi |
| 1940 |
\cb@findpdfpoint\cb@cntb\cb@pagecount |
| 1941 |
\fi |
| 1942 |
\fi |
| 1943 |
\cb@trace@connect##1##2##3% |
| 1944 |
}% |
| 1945 |
% \end{macrocode} |
| 1946 |
% |
| 1947 |
% \begin{macro}{\cb@checkPdfxy} |
| 1948 |
% The macro |\cb@checkPdfxy| checks if the coordinates of a point have |
| 1949 |
% changed during the current run. If so, we need to rerun \LaTeX. |
| 1950 |
% \begin{macrocode} |
| 1951 |
\gdef\cb@checkPdfxy##1##2##3##4##5{% |
| 1952 |
\cb@@findpdfpoint{##1}{##2}% |
| 1953 |
\ifdim##3sp=\cb@pdfx\relax |
| 1954 |
\ifdim##4sp=\cb@pdfy\relax |
| 1955 |
\ifdim##5=\cb@pdfz\relax |
| 1956 |
\else |
| 1957 |
\cb@error |
| 1958 |
\fi |
| 1959 |
\else |
| 1960 |
\cb@error |
| 1961 |
\fi |
| 1962 |
\else |
| 1963 |
\cb@error |
| 1964 |
\fi |
| 1965 |
} |
| 1966 |
% \end{macrocode} |
| 1967 |
% \end{macro} |
| 1968 |
% |
| 1969 |
% For Xe\TeX{} we don't need a limit on the number of bar points. |
| 1970 |
% \begin{macrocode} |
| 1971 |
\def\cb@maxpoint{9999999} |
| 1972 |
\let\cb@resetpoints\relax |
| 1973 |
% \end{macrocode} |
| 1974 |
% |
| 1975 |
% \changes{v3.6e}{2023/08/13}{lua\TeX{} support added} |
| 1976 |
% The code for lua\TeX{}, like for pdf\TeX\ and Xe\TeX, |
| 1977 |
% is more elaborate as the calculations have to |
| 1978 |
% be done in \TeX. |\cb@defpoint| will write information about the |
| 1979 |
% coordinates of the point to the \file{.aux} file, from where it will |
| 1980 |
% be picked up in the next run. Then we will construct the PDF |
| 1981 |
% code necessary to draw the changebars. |
| 1982 |
% \begin{macrocode} |
| 1983 |
\or |
| 1984 |
\immediate\closeout\cb@writexy |
| 1985 |
\immediate\openin\cb@readxy=\jobname.cb2\relax |
| 1986 |
% \end{macrocode} |
| 1987 |
% |
| 1988 |
% \begin{macro}{\cb@pdfpoints} |
| 1989 |
% \begin{macro}{\cb@pdfpagenr} |
| 1990 |
% The |\cb@pdfpoints| macro contains the list of coordinates of points |
| 1991 |
% that have been read in memory from the \file{.cb2} file. The |
| 1992 |
% |\cb@pdfpagenr| macro contains the next pagecount to be read in. |
| 1993 |
% \begin{macrocode} |
| 1994 |
\def\cb@pdfpoints{} |
| 1995 |
\def\cb@pdfpagenr{0} |
| 1996 |
% \end{macrocode} |
| 1997 |
% \end{macro} |
| 1998 |
% \end{macro} |
| 1999 |
% |
| 2000 |
% \begin{macro}{\cb@findpdfpoint} |
| 2001 |
% The |\cb@findpdfpoint| macro finds the coordinates of point \#1 on |
| 2002 |
% pagecount \#2. First we expand the arguments to get the real values. |
| 2003 |
% \begin{macrocode} |
| 2004 |
\def\cb@findpdfpoint##1##2{% |
| 2005 |
\edef\cb@temp |
| 2006 |
{\noexpand\cb@@findpdfpoint{\the##1}{\the##2}}% |
| 2007 |
\cb@temp |
| 2008 |
} |
| 2009 |
% \end{macrocode} |
| 2010 |
% \end{macro} |
| 2011 |
% |
| 2012 |
% \begin{macro}{\pdfliteral} |
| 2013 |
% For lua\TeX{} we also mimick PDF\TeX's command |\pdfliteral|. |
| 2014 |
% \begin{macrocode} |
| 2015 |
\def\pdfliteral##1{\pdfextension literal {##1}} |
| 2016 |
% \end{macrocode} |
| 2017 |
% \end{macro} |
| 2018 |
% |
| 2019 |
% \begin{macro}{\cb@@findpdfpoint} |
| 2020 |
% The |\cb@@findpdfpoint| macro finds the coordinates of point \#1 on |
| 2021 |
% pagecount \#2. If the information is not yet in memory is it read from |
| 2022 |
% the \file{.cb2} file. The coordinates of the current point in the text |
| 2023 |
% will be delivered in |\cb@pdfx| and |\cb@pdfy|, and |\cb@pdfz| will get |
| 2024 |
% the x coordinate of the changebar. If the point is unknown, |\cb@pdfx| |
| 2025 |
% will be set to |\relax|. |
| 2026 |
% \begin{macrocode} |
| 2027 |
\def\cb@@findpdfpoint##1##2{% |
| 2028 |
\ifnum##2<\cb@pdfpagenr\relax\else |
| 2029 |
\cb@pdfreadxy{##2}% |
| 2030 |
\fi |
| 2031 |
\let\cb@pdfx\relax |
| 2032 |
\ifx\cb@pdfpoints\@empty\else |
| 2033 |
\ifnum##2<0\relax |
| 2034 |
\else |
| 2035 |
\edef\cb@temp{% |
| 2036 |
\noexpand\cb@pdffind{##1}{##2}\cb@pdfpoints\relax{}}% |
| 2037 |
\cb@temp |
| 2038 |
\fi |
| 2039 |
\fi |
| 2040 |
} |
| 2041 |
% \end{macrocode} |
| 2042 |
% \end{macro} |
| 2043 |
% |
| 2044 |
% \begin{macro}{\cb@pdffind} |
| 2045 |
% The |\cb@pdffind| recursively searches through |\cb@pdfpoints| to find |
| 2046 |
% point \#1 on pagecount \#2. |\cb@pdfpoints| contains entries of the |
| 2047 |
% form\\ |
| 2048 |
% \meta{pointnr}.\meta{pagecount}p\meta{x},\meta{y},\meta{z}pt. |
| 2049 |
% When the point is found it is removed from |\cb@pdfpoints|. \#9 |
| 2050 |
% contains the cumulative head of the list to construct the new list |
| 2051 |
% with the entry removed. \#3--\#8 are for pattern matching. |
| 2052 |
% \changes{v3.7b}{2023/12/30}{use ";" instead of "," as delimiter} |
| 2053 |
% \changes{v3.7e}{2024/07/17}{Use "/" instead of ";" as delimiter} |
| 2054 |
% \begin{changebar} |
| 2055 |
% \begin{macrocode} |
| 2056 |
\def\cb@pdffind##1##2##3.##4p##5/##6/##7pt##8\relax##9{% |
| 2057 |
% \end{macrocode} |
| 2058 |
% \end{changebar} |
| 2059 |
% \begin{macrocode} |
| 2060 |
\def\cb@next{% |
| 2061 |
% \end{macrocode} |
| 2062 |
% \begin{changebar} |
| 2063 |
% \begin{macrocode} |
| 2064 |
\cb@pdffind{##1}{##2}##8\relax{##9##3.##4p##5/##6/##7pt}}% |
| 2065 |
% \end{macrocode} |
| 2066 |
% \end{changebar} |
| 2067 |
% \begin{macrocode} |
| 2068 |
\ifnum ##1=##3 |
| 2069 |
\ifnum ##2=##4 |
| 2070 |
\def\cb@pdfx{##5sp}% |
| 2071 |
\def\cb@pdfy{##6sp}% |
| 2072 |
\def\cb@pdfz{##7pt}% |
| 2073 |
\let\cb@next\relax |
| 2074 |
\gdef\cb@pdfpoints{##9##8}% |
| 2075 |
\fi |
| 2076 |
\fi |
| 2077 |
\ifx\relax##8\relax |
| 2078 |
\let\cb@next\relax |
| 2079 |
\fi |
| 2080 |
\cb@next |
| 2081 |
}% |
| 2082 |
% \end{macrocode} |
| 2083 |
% \end{macro} |
| 2084 |
% |
| 2085 |
% \begin{macro}{\cb@pdfreadxy} |
| 2086 |
% The |\cb@pdfreadxy| macro reads lines from the \file{.cb2} file in |
| 2087 |
% |\cb@pdfpoints| until the pagecount is greater than \#1 or the end of |
| 2088 |
% the file is reached. This ensures that all entries belonging to the |
| 2089 |
% current column are in memory. |
| 2090 |
% \begin{macrocode} |
| 2091 |
\def\cb@pdfreadxy##1{% |
| 2092 |
\let\cb@next\relax |
| 2093 |
\ifeof\cb@readxy |
| 2094 |
\global\let\cb@pdfpagenr\cb@maxpoint |
| 2095 |
\else |
| 2096 |
{\endlinechar=-1\read\cb@readxy to\cb@temp |
| 2097 |
\ifx\cb@temp\@empty\else |
| 2098 |
\expandafter\cb@pdfparsexy\cb@temp |
| 2099 |
\ifnum\cb@pdfpg<0\else |
| 2100 |
\xdef\cb@pdfpoints{\cb@pdfpoints\cb@temp}% |
| 2101 |
\cb@trace{PDFpoints=\cb@pdfpoints}% |
| 2102 |
\global\let\cb@pdfpagenr\cb@pdfpg |
| 2103 |
\fi |
| 2104 |
\ifnum\cb@pdfpg>##1\else |
| 2105 |
\global\def\cb@next{\cb@pdfreadxy{##1}}% |
| 2106 |
\fi |
| 2107 |
\fi |
| 2108 |
}% |
| 2109 |
\fi |
| 2110 |
\cb@next |
| 2111 |
}% |
| 2112 |
% \end{macrocode} |
| 2113 |
% \end{macro} |
| 2114 |
% |
| 2115 |
% \begin{macro}{\cb@pdfparsexy} |
| 2116 |
% The |\cb@pdfparsexy| macro extracts the pagecount from an entry read in |
| 2117 |
% from the \file{.cb2} file. |
| 2118 |
% \changes{v3.7e}{2024/07/17}{Use "/" instead of ";" as delimiter} |
| 2119 |
% \begin{changebar} |
| 2120 |
% \begin{macrocode} |
| 2121 |
\def\cb@pdfparsexy##1.##2p##3/##4/##5pt{% |
| 2122 |
% \end{macrocode} |
| 2123 |
% \end{changebar} |
| 2124 |
% \begin{macrocode} |
| 2125 |
\def\cb@pdfpg{##2}}% |
| 2126 |
% \end{macrocode} |
| 2127 |
% \end{macro} |
| 2128 |
% |
| 2129 |
% As PDF is not a programming language it does not have any variables to |
| 2130 |
% remember the coordinates of the current point. Therefore we write the |
| 2131 |
% information to the \file{.aux} file and read it in in the next run. We |
| 2132 |
% write the x,y coordinates of the current point in the text and the x |
| 2133 |
% coordinate of the change bar. |
| 2134 |
% We also need the value of |\cb@pagecount| here, not during the write. |
| 2135 |
% \begin{macrocode} |
| 2136 |
\def\cb@defpoint##1##2{% |
| 2137 |
\if@filesw |
| 2138 |
\begingroup |
| 2139 |
\edef\point{{\the##1}{\the\cb@pagecount}}% |
| 2140 |
\let\the=\z@ |
| 2141 |
\savepos |
| 2142 |
\edef\cb@temp{\write\@auxout |
| 2143 |
{\string\cb@pdfxy\point |
| 2144 |
{\the\lastxpos}{\the\lastypos}{\the##2}}}% |
| 2145 |
\cb@temp |
| 2146 |
\endgroup |
| 2147 |
\fi |
| 2148 |
\cb@trace@defpoint##1##2% |
| 2149 |
}% |
| 2150 |
% \end{macrocode} |
| 2151 |
% |
| 2152 |
% \begin{macro}{\cb@cvtpct} |
| 2153 |
% The macro |\cb@cvtpct| converts a percentage between 0 and 100 to a |
| 2154 |
% decimal fraction. |
| 2155 |
% \begin{macrocode} |
| 2156 |
\def\cb@cvtpct##1{% |
| 2157 |
\ifnum##1<0 0\else |
| 2158 |
\ifnum##1>99 1\else |
| 2159 |
\ifnum##1<10 0.0\the##1\else |
| 2160 |
0.\the##1\fi\fi\fi} |
| 2161 |
% \end{macrocode} |
| 2162 |
% \end{macro} |
| 2163 |
% |
| 2164 |
% \begin{macro}{\cb@pdf@scale} |
| 2165 |
% \changes{v3.6a}{2018/02/03}{Added macro for scale factor} |
| 2166 |
% In order to get things in the right spot we need a little scaling |
| 2167 |
% factor. We define it here. |
| 2168 |
% \begin{macrocode} |
| 2169 |
\def\cb@pdf@scale{0.996264009963} |
| 2170 |
% \end{macrocode} |
| 2171 |
% \end{macro} |
| 2172 |
% |
| 2173 |
% The |\cb@connect| finds the coordinates of the begin and end points, |
| 2174 |
% converts them to PDF units and draws the bar with |\pdfliteral|. It |
| 2175 |
% also sets the color or gray level, if necessary. When any of the |
| 2176 |
% points is unknown the bar is skipped and a rerun is signalled. |
| 2177 |
% \begin{macrocode} |
| 2178 |
\def\cb@connect##1##2##3{% |
| 2179 |
\cb@findpdfpoint{##1}\cb@pagecount |
| 2180 |
\ifx\cb@pdfx\relax\cb@rerun |
| 2181 |
\else |
| 2182 |
\let\cb@pdftopy\cb@pdfy |
| 2183 |
\cb@findpdfpoint{##2}\cb@pagecount |
| 2184 |
\ifx\cb@pdfx\relax\cb@rerun |
| 2185 |
\else |
| 2186 |
% \end{macrocode} |
| 2187 |
% We do everything in a group, so that we can freely use all kinds of |
| 2188 |
% registers. |
| 2189 |
% \begin{macrocode} |
| 2190 |
\begingroup |
| 2191 |
\cb@dima=\cb@pdfz |
| 2192 |
\advance\cb@dima by-\cb@pdfx |
| 2193 |
\advance\cb@dima by1in% |
| 2194 |
\cb@dima=\cb@pdf@scale\cb@dima\relax |
| 2195 |
% \end{macrocode} |
| 2196 |
% First we let PDF save the graphics state. Then we generate the color |
| 2197 |
% selection code followed by the code to draw the changebar. Finally the |
| 2198 |
% graphics state is restored. We cannot use the color commands from the |
| 2199 |
% color package here, as the generated PDF code may be moved to the next |
| 2200 |
% line. |
| 2201 |
% \begin{macrocode} |
| 2202 |
\ifx\cb@current@color\@undefined |
| 2203 |
\def\cb@temp{\cb@cvtpct\c@changebargrey}% |
| 2204 |
\pdfliteral{q \cb@temp\space g \cb@temp\space G}% |
| 2205 |
\else |
| 2206 |
\pdfliteral{q \cb@current@color}% |
| 2207 |
\fi |
| 2208 |
\edef\cb@temp{\expandafter\cb@removedim\the\cb@dima\space}% |
| 2209 |
\cb@dima=\cb@pdftopy |
| 2210 |
\advance\cb@dima-\cb@pdfy\relax |
| 2211 |
\cb@dima=\cb@pdf@scale\cb@dima\relax |
| 2212 |
##3=\cb@pdf@scale##3\relax |
| 2213 |
\pdfliteral{\expandafter\cb@removedim\the##3 w |
| 2214 |
\cb@temp 0 m |
| 2215 |
\cb@temp \expandafter\cb@removedim\the\cb@dima\space l S Q}% |
| 2216 |
\endgroup |
| 2217 |
% \end{macrocode} |
| 2218 |
% We look up the two unused points to get them removed from |\cb@pdfpoints|. |
| 2219 |
% \begin{macrocode} |
| 2220 |
\cb@cntb=##1\relax |
| 2221 |
\ifodd\cb@cntb\advance\cb@cntb 1\else\advance\cb@cntb -1\fi |
| 2222 |
\cb@findpdfpoint\cb@cntb\cb@pagecount |
| 2223 |
\cb@cntb=##2\relax |
| 2224 |
\ifodd\cb@cntb\advance\cb@cntb 1\else\advance\cb@cntb -1\fi |
| 2225 |
\cb@findpdfpoint\cb@cntb\cb@pagecount |
| 2226 |
\fi |
| 2227 |
\fi |
| 2228 |
\cb@trace@connect##1##2##3% |
| 2229 |
}% |
| 2230 |
% \end{macrocode} |
| 2231 |
% |
| 2232 |
% \begin{macro}{\cb@checkPdfxy} |
| 2233 |
% The macro |\cb@checkPdfxy| checks if the coordinates of a point have |
| 2234 |
% changed during the current run. If so, we need to rerun \LaTeX. |
| 2235 |
% \begin{macrocode} |
| 2236 |
\gdef\cb@checkPdfxy##1##2##3##4##5{% |
| 2237 |
\cb@@findpdfpoint{##1}{##2}% |
| 2238 |
\ifdim##3sp=\cb@pdfx\relax |
| 2239 |
\ifdim##4sp=\cb@pdfy\relax |
| 2240 |
\ifdim##5=\cb@pdfz\relax |
| 2241 |
\else |
| 2242 |
\cb@error |
| 2243 |
\fi |
| 2244 |
\else |
| 2245 |
\cb@error |
| 2246 |
\fi |
| 2247 |
\else |
| 2248 |
\cb@error |
| 2249 |
\fi |
| 2250 |
} |
| 2251 |
% \end{macrocode} |
| 2252 |
% \end{macro} |
| 2253 |
% |
| 2254 |
% For lua\TeX{} we don't need a limit on the number of bar points. |
| 2255 |
% \begin{macrocode} |
| 2256 |
\def\cb@maxpoint{9999999} |
| 2257 |
\let\cb@resetpoints\relax |
| 2258 |
% \end{macrocode} |
| 2259 |
% |
| 2260 |
% When code for other drivers should be added it can be inserted |
| 2261 |
% here. When someone makes a mistake and somehow selects an |
| 2262 |
% unknown driver a warning is issued and the macros are defined to |
| 2263 |
% be no-ops. |
| 2264 |
% \begin{macrocode} |
| 2265 |
\else |
| 2266 |
\PackageWarning{Changebar}{changebars not supported in unknown setup} |
| 2267 |
\def\cb@defpoint##1##2{\cb@trace@defpoint##1##2} |
| 2268 |
\def\cb@connect##1##2##3{\cb@trace@connect##1##2##3} |
| 2269 |
\let\cb@resetpoints\relax |
| 2270 |
\fi |
| 2271 |
% \end{macrocode} |
| 2272 |
% \end{macro} |
| 2273 |
% \end{macro} |
| 2274 |
% \end{macro} |
| 2275 |
% |
| 2276 |
% The last thing to do is to forget about |\cb@setup@specials|. |
| 2277 |
% \begin{macrocode} |
| 2278 |
\global\let\cb@setup@specials\relax} |
| 2279 |
% \end{macrocode} |
| 2280 |
% \end{macro} |
| 2281 |
% |
| 2282 |
% \begin{macro}{\cbstart} |
| 2283 |
% The macro |\cbstart| starts a new changebar. It has an (optional) |
| 2284 |
% argument that will be used to determine the width of the bar. |
| 2285 |
% The default width is |\changebarwidth|. |
| 2286 |
% \changes{v3.3i}{1999/06/19}{Use \LaTeX's own mechanism to detect |
| 2287 |
% grouping errors.} |
| 2288 |
% \changes{v3.4e}{2002/10/28}{Reverted the change from version 3.3i} |
| 2289 |
% \begin{macrocode} |
| 2290 |
\newcommand*{\cbstart}{\@ifnextchar[%] |
| 2291 |
{\cb@start}% |
| 2292 |
{\cb@start[\changebarwidth]}} |
| 2293 |
% \end{macrocode} |
| 2294 |
% \end{macro} |
| 2295 |
% |
| 2296 |
% \begin{macro}{\cbend} |
| 2297 |
% The macro |\cbend| (surprisingly) ends a changebar. The macros |
| 2298 |
% |\cbstart| and |\cbend| can be used when the use of a |
| 2299 |
% proper \LaTeX\ environment is not possible. |
| 2300 |
% \begin{macrocode} |
| 2301 |
\newcommand*{\cbend}{\cb@end} |
| 2302 |
% \end{macrocode} |
| 2303 |
% \end{macro} |
| 2304 |
% |
| 2305 |
% \begin{macro}{\cbdelete} |
| 2306 |
% The macro |\cbdelete| inserts a `deletebar' in the margin. |
| 2307 |
% It too has an optional argument to determine the width of the bar. |
| 2308 |
% The default width (and length) of it are stored in |
| 2309 |
% |\deletebarwidth|. |
| 2310 |
% \begin{macrocode} |
| 2311 |
\newcommand*{\cbdelete}{\@ifnextchar[%] |
| 2312 |
{\cb@delete}% |
| 2313 |
{\cb@delete[\deletebarwidth]}} |
| 2314 |
% \end{macrocode} |
| 2315 |
% |
| 2316 |
% \begin{macro}{\cb@delete} |
| 2317 |
% Deletebars are implemented as a special `change bar'. The bar |
| 2318 |
% is started and immediately ended. It is as long as it is wide. |
| 2319 |
% \begin{macrocode} |
| 2320 |
\def\cb@delete[#1]{\vbox to \z@{\vss\cb@start[#1]\vskip #1\cb@end}} |
| 2321 |
% \end{macrocode} |
| 2322 |
% \end{macro} |
| 2323 |
% \end{macro} |
| 2324 |
% |
| 2325 |
% \begin{macro}{\changebar} |
| 2326 |
% \begin{macro}{\endchangebar} |
| 2327 |
% The macros |\changebar| and |\endchangebar| have the same |
| 2328 |
% function as |\cbstart| and |\cbend| but they can be used as a |
| 2329 |
% \LaTeX\ environment to enforce correct nesting. They can |
| 2330 |
% \emph{not} be used in the \textsf{tabular} and \textsf{tabbing} |
| 2331 |
% environments. |
| 2332 |
% \begin{macrocode} |
| 2333 |
\newenvironment{changebar}% |
| 2334 |
{\@ifnextchar[{\cb@start}%] |
| 2335 |
{\cb@start[\changebarwidth]}}% |
| 2336 |
{\cb@end} |
| 2337 |
% \end{macrocode} |
| 2338 |
% \end{macro} |
| 2339 |
% \end{macro} |
| 2340 |
% |
| 2341 |
% \begin{macro}{\nochangebars} |
| 2342 |
% To disable changebars altogether without having to remove them |
| 2343 |
% from the document the macro |\nochangebars| is provided. It makes |
| 2344 |
% no-ops of three internal macros. |
| 2345 |
% \changes{v3.7d}{2024/01/09}{Make sure spaces are ignored (cf. change |
| 2346 |
% 3.7c)} |
| 2347 |
% \begin{macrocode} |
| 2348 |
\newcommand*{\nochangebars}{% |
| 2349 |
\def\cb@start[##1]{\ignorespaces}% |
| 2350 |
\def\cb@delete[##1]{}% |
| 2351 |
\def\cb@end{\ignorespacesafterend}% |
| 2352 |
} |
| 2353 |
% \end{macrocode} |
| 2354 |
% \end{macro} |
| 2355 |
% |
| 2356 |
% \begin{macro}{\changebarwidth} |
| 2357 |
% The default width of the changebars is stored in the dimension |
| 2358 |
% register |\changebarwidth|. |
| 2359 |
% \begin{macrocode} |
| 2360 |
\newlength{\changebarwidth} |
| 2361 |
\setlength{\changebarwidth}{2pt} |
| 2362 |
% \end{macrocode} |
| 2363 |
% \end{macro} |
| 2364 |
% |
| 2365 |
% \begin{macro}{\deletebarwidth} |
| 2366 |
% The default width of the deletebars is stored in the dimension |
| 2367 |
% register |\deletebarwidth|. |
| 2368 |
% \begin{macrocode} |
| 2369 |
\newlength{\deletebarwidth} |
| 2370 |
\setlength{\deletebarwidth}{4pt} |
| 2371 |
% \end{macrocode} |
| 2372 |
% \end{macro} |
| 2373 |
% |
| 2374 |
% \begin{macro}{\changebarsep} |
| 2375 |
% The default separation between all bars and the text is stored in |
| 2376 |
% the dimen register |\changebarsep|. |
| 2377 |
% \changes{v3.6b}{2018/02/04}{set the default separtion between text |
| 2378 |
% and changebars to half the separation between text and marginal |
| 2379 |
% paragraphs} |
| 2380 |
% \begin{macrocode} |
| 2381 |
\newlength{\changebarsep} |
| 2382 |
\setlength{\changebarsep}{0.5\marginparsep} |
| 2383 |
% \end{macrocode} |
| 2384 |
% \end{macro} |
| 2385 |
% |
| 2386 |
% \begin{Var}{changebargrey} |
| 2387 |
% When the document is printed using one of the PostScript drivers |
| 2388 |
% the bars do not need to be black; with PostScript it is possible |
| 2389 |
% to have grey, and colored, bars. The percentage of greyness of the |
| 2390 |
% bar is stored in the count register |\changebargrey|. It can |
| 2391 |
% have values between $0$ (meaning white) and $100$ (meaning |
| 2392 |
% black). |
| 2393 |
% |
| 2394 |
% \begin{macrocode} |
| 2395 |
\newcounter{changebargrey} |
| 2396 |
\setcounter{changebargrey}{65} |
| 2397 |
% \end{macrocode} |
| 2398 |
% \end{Var} |
| 2399 |
% |
| 2400 |
% When one of the options \Lopt{color} or \Lopt{xcolor} was |
| 2401 |
% selected we need to load the appropriate package. When we're run |
| 2402 |
% by pdf\LaTeX\ we need to pass that information on to that package. |
| 2403 |
% \changes{v3.4e}{2001/09/14}{Detect pdf mode} |
| 2404 |
% \changes{v3.5a}{2005/05/23}{The option \Lopt{pdftex} will be supplied |
| 2405 |
% automatically with the current color packages. Leave out |
| 2406 |
% \Lopt{dvipsnames} as it is usually automatically loaded and may clash |
| 2407 |
% if the color or xcolor package has already been loaded. Also |
| 2408 |
% \cs{cb@color@pkg} is undefined when no color option has been given.} |
| 2409 |
% \begin{macrocode} |
| 2410 |
\@ifpackagewith{changebar}{\csname cb@color@pkg\endcsname}{% |
| 2411 |
\RequirePackage{\cb@color@pkg}% |
| 2412 |
% \end{macrocode} |
| 2413 |
% Then we need to define the command |\cbcolor| which is a slightly |
| 2414 |
% modified copy of the command |\color| from the \pkg{color} |
| 2415 |
% package. |
| 2416 |
% |
| 2417 |
% \begin{macro}{\cbcolor} |
| 2418 |
% |\cbcolor{|\emph{declared-colour}|}| switches the colour of the |
| 2419 |
% changebars to \emph{declared-colour}, which must previously have |
| 2420 |
% been defined using |\definecolor|. This colour will stay in |
| 2421 |
% effect until the end of the current \TeX\ group. |
| 2422 |
% |
| 2423 |
% |\cbcolor[|\emph{model}|]{|\emph{colour-specification}|}| is |
| 2424 |
% similar to the above, but uses a colour not declared by |
| 2425 |
% |\definecolor|. The allowed \emph{model}'s vary depending on the |
| 2426 |
% driver. The syntax of the \emph{colour-specification} argument |
| 2427 |
% depends on the model. |
| 2428 |
% \begin{macrocode} |
| 2429 |
\DeclareRobustCommand\cbcolor{% |
| 2430 |
\@ifnextchar[%] |
| 2431 |
\@undeclaredcbcolor\@declaredcbcolor} |
| 2432 |
% \end{macrocode} |
| 2433 |
% \end{macro} |
| 2434 |
% |
| 2435 |
% \begin{macro}{\@undeclaredcbcolor} |
| 2436 |
% Call the driver-dependent command |\color@|\meta{model} to define |
| 2437 |
% |\cb@current@color|. |
| 2438 |
% \changes{v3.5c}{2005/09/18}{Use the higher level interface throug |
| 2439 |
% \cs{color} to prevent problemns with \texttt{color.sty} or |
| 2440 |
% \texttt{xcolor.sty}} |
| 2441 |
% \begin{macrocode} |
| 2442 |
\def\@undeclaredcbcolor[#1]#2{% |
| 2443 |
\begingroup |
| 2444 |
\color[#1]{#2}% |
| 2445 |
\global\let\cb@current@color\current@color |
| 2446 |
\endgroup |
| 2447 |
\ignorespaces |
| 2448 |
} |
| 2449 |
% \end{macrocode} |
| 2450 |
% \end{macro} |
| 2451 |
% |
| 2452 |
% \begin{macro}{\@declaredcbcolor} |
| 2453 |
% \changes{v3.5c}{2005/09/18}{Use the higher level interface throug |
| 2454 |
% \cs{color} to prevent problemns with \texttt{color.sty} or |
| 2455 |
% \texttt{xcolor.sty}} |
| 2456 |
% \begin{macrocode} |
| 2457 |
\def\@declaredcbcolor#1{% |
| 2458 |
\begingroup |
| 2459 |
\color{#1}% |
| 2460 |
\global\let\cb@current@color\current@color |
| 2461 |
\endgroup |
| 2462 |
\ignorespaces}% |
| 2463 |
}{% |
| 2464 |
% \end{macrocode} |
| 2465 |
% When the \Lopt{color} option wasn't specified the usage of the |
| 2466 |
% |\cbcolor| command results in a warning message. |
| 2467 |
% \changes{v3.4d}{2001/09/04}{Isue an error when \cmd{cbcolor} is |
| 2468 |
% used without specifying the \Lopt{color} option} |
| 2469 |
% \changes{v3.4e}{2001/09/07}{Made the error message a warning message} |
| 2470 |
% \begin{macrocode} |
| 2471 |
\def\cbcolor{\@ifnextchar[%] |
| 2472 |
\@@cbcolor\@cbcolor}% |
| 2473 |
\def\@@cbcolor[#1]#2{\cb@colwarn\def\@@cbcolor[##1]##2{}}% |
| 2474 |
\def\@cbcolor#1{\cb@colwarn\def\@cbcolor##1{}}% |
| 2475 |
\def\cb@colwarn{\PackageWarning{Changebar}% |
| 2476 |
{You didn't specify the option `color';\MessageBreak |
| 2477 |
your command \string\cbcolor\space will be ignored}}% |
| 2478 |
} |
| 2479 |
% \end{macrocode} |
| 2480 |
% \end{macro} |
| 2481 |
% |
| 2482 |
% \subsection{Macros for beginning and ending bars} |
| 2483 |
% |
| 2484 |
% \begin{macro}{\cb@start} |
| 2485 |
% This macro starts a change bar. It assigns a new value to the |
| 2486 |
% current point and advances the counter for the next point to be |
| 2487 |
% assigned. It pushes this info onto |\cb@currentstack| and then |
| 2488 |
% sets the point by calling |\cb@setBeginPoints| with the point |
| 2489 |
% number. Finally, it writes the \file{.aux} file. |
| 2490 |
% \changes{v3.3h}{1999/06/15}{Added \cs{cb@checkpage} to find final |
| 2491 |
% page from history} |
| 2492 |
% \begin{macrocode} |
| 2493 |
\def\cb@start[#1]{% |
| 2494 |
\cb@topleft=\cb@nextpoint |
| 2495 |
% \end{macrocode} |
| 2496 |
% Store the width of the< current bar in |\cb@curbarwd|. |
| 2497 |
% \begin{macrocode} |
| 2498 |
\cb@curbarwd#1\relax |
| 2499 |
\cb@push\cb@currentstack |
| 2500 |
% \end{macrocode} |
| 2501 |
% Now find out on which page the start of this bar finaly ends up; |
| 2502 |
% due to the asynchronous nature of the output routine it might be |
| 2503 |
% a different page. The macro |\cb@checkpage| finds the page number |
| 2504 |
% on the history stack. |
| 2505 |
% \changes{v3.5a}{2005/05/23}{Correction for nested changebars} |
| 2506 |
% \begin{macrocode} |
| 2507 |
\cb@checkpage\z@ |
| 2508 |
% \end{macrocode} |
| 2509 |
% Temporarily assign the page number to |\cb@pagecount| as that |
| 2510 |
% register is used by |\cb@setBeginPoints|. Note that it's value is |
| 2511 |
% offset by one from the page counter. |
| 2512 |
% \begin{macrocode} |
| 2513 |
\cb@cnta\cb@pagecount |
| 2514 |
\cb@pagecount\cb@page\advance\cb@pagecount\m@ne |
| 2515 |
\ifvmode |
| 2516 |
\cb@setBeginPoints |
| 2517 |
\else |
| 2518 |
\vbox to \z@{% |
| 2519 |
% \end{macrocode} |
| 2520 |
% When we are in horizontal mode we jump up a line to set the |
| 2521 |
% starting point of the changebar. |
| 2522 |
% \begin{macrocode} |
| 2523 |
\vskip -\ht\strutbox |
| 2524 |
\cb@setBeginPoints |
| 2525 |
\vskip \ht\strutbox}% |
| 2526 |
\fi |
| 2527 |
% \end{macrocode} |
| 2528 |
% Restore |\cb@pagecount|. |
| 2529 |
% \changes{v3.7c}{2024/01/01}{Added \cs{ignorespaces} at the end to |
| 2530 |
% prevent a spcae token from creaping into the output} |
| 2531 |
% \begin{macrocode} |
| 2532 |
\cb@pagecount\cb@cnta |
| 2533 |
\cb@advancePoint\ignorespaces} |
| 2534 |
% \end{macrocode} |
| 2535 |
% \end{macro} |
| 2536 |
% |
| 2537 |
% \begin{macro}{\cb@advancePoint} |
| 2538 |
% The macro |\cb@advancePoint| advances the count register |
| 2539 |
% |\cb@nextpoint|. When the maximum number is reached, the |
| 2540 |
% numbering is reset. |
| 2541 |
% \begin{macrocode} |
| 2542 |
\def\cb@advancePoint{% |
| 2543 |
\global\advance\cb@nextpoint by 4\relax |
| 2544 |
\ifnum\cb@nextpoint>\cb@maxpoint |
| 2545 |
\global\cb@nextpoint=\cb@minpoint\relax |
| 2546 |
\fi} |
| 2547 |
% \end{macrocode} |
| 2548 |
% \end{macro} |
| 2549 |
% |
| 2550 |
% \begin{macro}{\cb@end} |
| 2551 |
% This macro ends a changebar. It pops the current point and |
| 2552 |
% nesting level off |\cb@currentstack| and sets the end point by |
| 2553 |
% calling |\cb@setEndPoints| with the parameter corresponding to |
| 2554 |
% the \emph{beginning} point number. It writes the \file{.aux} file |
| 2555 |
% and joins the points. |
| 2556 |
% When in horizontal mode we put the call to |\cb@setEndPoints| |
| 2557 |
% inside a |\vadjust|. This ensures that things with a large depth, |
| 2558 |
% e.g. a parbox or formula will be completely covered. By default |
| 2559 |
% these have their baseline centered, and thus otherwise the |
| 2560 |
% changebar would stop there. |
| 2561 |
% |
| 2562 |
% \changes{v3.3a}{1997/09/26}{Added \cs{ignorespaces}} |
| 2563 |
% \changes{v3.3g}{1999/06/11}{Added stack tracing} |
| 2564 |
% \changes{v3.3h}{1999/06/15}{Now check the history stack to find the |
| 2565 |
% page on which this point ends up} |
| 2566 |
% \changes{v3.5a}{2005/05/23}{Added \cs{vadjust} in horizontal mode.} |
| 2567 |
% \begin{macrocode} |
| 2568 |
\def\cb@end{% |
| 2569 |
\cb@trace@stack{end of bar on page \the\c@page}% |
| 2570 |
\cb@pop\cb@currentstack |
| 2571 |
\ifnum\cb@topleft=\cb@nil |
| 2572 |
\PackageWarning{Changebar}% |
| 2573 |
{Badly nested changebars; Expect erroneous results}% |
| 2574 |
\else |
| 2575 |
% \end{macrocode} |
| 2576 |
% Call |\cb@checkpage| to find the page this point finally ends up |
| 2577 |
% on. |
| 2578 |
% \changes{v3.5a}{2005/05/23}{Correction for nested changebars} |
| 2579 |
% \begin{macrocode} |
| 2580 |
\cb@checkpage\thr@@ |
| 2581 |
% \end{macrocode} |
| 2582 |
% Again, we need to temporarily overwrite |\cb@pagecount|. |
| 2583 |
% \changes{v3.7c}{2024/01/01}{We need \cs{ignorespacesafterend} here, |
| 2584 |
% not \cs{ignorespaces}} |
| 2585 |
% \begin{macrocode} |
| 2586 |
\cb@cnta\cb@pagecount |
| 2587 |
\cb@pagecount\cb@page\advance\cb@pagecount\m@ne |
| 2588 |
\ifvmode |
| 2589 |
\cb@setEndPoints |
| 2590 |
\else |
| 2591 |
\vadjust{\cb@setEndPoints}% |
| 2592 |
\fi |
| 2593 |
\cb@pagecount\cb@cnta |
| 2594 |
\fi |
| 2595 |
\ignorespacesafterend} |
| 2596 |
% \end{macrocode} |
| 2597 |
%\end{macro} |
| 2598 |
% |
| 2599 |
% \begin{macro}{\cb@checkpage} |
| 2600 |
% \changes{v3.3h}{1999/06/15}{Macro added} |
| 2601 |
% The macro |\cb@checkpage| checks the history stack in order to |
| 2602 |
% find out on which page a set of points finaly ends up. |
| 2603 |
% |
| 2604 |
% We expect the identification of the points in |\cb@topleft| and |
| 2605 |
% |\cb@page|. The resulting page will be stored in |\cb@page|. |
| 2606 |
% The parameter indicates whether we are searching for a begin |
| 2607 |
% point (0) or end point (3). |
| 2608 |
% \changes{v3.3i}{1999/06/18}{Check for and handle the situation that |
| 2609 |
% the history stack is too short due to new bars added to a |
| 2610 |
% document} |
| 2611 |
% \changes{v3.5a}{2005/05/23}{Correction for nested changebars} |
| 2612 |
% \begin{macrocode} |
| 2613 |
\def\cb@checkpage#1{% |
| 2614 |
% \end{macrocode} |
| 2615 |
% First store the identifiers in temporary registers. |
| 2616 |
% \begin{macrocode} |
| 2617 |
\cb@cnta\cb@topleft\relax |
| 2618 |
\advance\cb@cnta by #1\relax |
| 2619 |
\cb@cntb\cb@page\relax |
| 2620 |
\cb@dima\cb@curbarwd\relax |
| 2621 |
% \end{macrocode} |
| 2622 |
% Then pop the history stack. |
| 2623 |
% \begin{macrocode} |
| 2624 |
\cb@pop\cb@historystack |
| 2625 |
% \end{macrocode} |
| 2626 |
% If it was empty there is nothing to check and we're done. |
| 2627 |
% \begin{macrocode} |
| 2628 |
\ifnum\cb@topleft=\cb@nil |
| 2629 |
\else |
| 2630 |
% \end{macrocode} |
| 2631 |
% \changes{v3.5a}{2005/05/23}{Correction for moving floats} |
| 2632 |
% Now keep popping the stack until |\cb@topleft| is found. The values |
| 2633 |
% popped from the stack are pushed on a temporary stack to be pushed |
| 2634 |
% back later. This could perhaps be implemented more efficiently if |
| 2635 |
% the stacks had a different design. |
| 2636 |
% \begin{macrocode} |
| 2637 |
\cb@FindPageNum |
| 2638 |
% \end{macrocode} |
| 2639 |
% \changes{v3.5a}{2005/05/23}{Correction for nested changebars} |
| 2640 |
% \begin{macrocode} |
| 2641 |
\ifnum\cb@topleft>\cb@maxpoint\else |
| 2642 |
% \end{macrocode} |
| 2643 |
% Now that we've found it overwrite |\cb@cntb| with the |
| 2644 |
% |\cb@page| from the stack. |
| 2645 |
% \begin{macrocode} |
| 2646 |
\cb@cntb\cb@page |
| 2647 |
\fi |
| 2648 |
% \end{macrocode} |
| 2649 |
% Now we restore the history stack to it's original state. |
| 2650 |
% \begin{macrocode} |
| 2651 |
\@whilenum\cb@topleft>\cb@nil\do{% |
| 2652 |
\cb@push\cb@historystack |
| 2653 |
\cb@pop\cb@tempstack}% |
| 2654 |
\fi |
| 2655 |
% \end{macrocode} |
| 2656 |
% Finally return the correct values |
| 2657 |
% \changes{v3.5a}{2005/05/23}{Correction for nested changebars} |
| 2658 |
% \begin{macrocode} |
| 2659 |
\advance\cb@cnta by -#1\relax |
| 2660 |
\cb@topleft\cb@cnta\relax |
| 2661 |
\cb@page\cb@cntb\relax |
| 2662 |
\cb@curbarwd\cb@dima\relax |
| 2663 |
} |
| 2664 |
% \end{macrocode} |
| 2665 |
% \end{macro} |
| 2666 |
% |
| 2667 |
% \begin{macro}{\cb@FindPageNum} |
| 2668 |
% |\cb@FindPageNum| recursively searches through the history stack until |
| 2669 |
% an entry is found that is equal to |\cb@cnta|. |
| 2670 |
% \begin{macrocode} |
| 2671 |
\def\cb@FindPageNum{% |
| 2672 |
\ifnum\cb@topleft=\cb@cnta |
| 2673 |
% \end{macrocode} |
| 2674 |
% We have found it, exit the macro, otherwise push the current entry on |
| 2675 |
% the temporary stack and pop a new one from the history stack. |
| 2676 |
% \begin{macrocode} |
| 2677 |
\else |
| 2678 |
\cb@push\cb@tempstack |
| 2679 |
\cb@pop\cb@historystack |
| 2680 |
% \end{macrocode} |
| 2681 |
% When the user adds changebars to his document we might run out of |
| 2682 |
% the history stack before we find a match. This would send \TeX\ |
| 2683 |
% into an endless loop if it wasn't detected and handled. |
| 2684 |
% \begin{macrocode} |
| 2685 |
\ifnum\cb@topleft=\cb@nil |
| 2686 |
\cb@trace{Ran out of history stack, new changebar?}% |
| 2687 |
% \end{macrocode} |
| 2688 |
% In this case we give |\cb@topleft| an `impossible value' to |
| 2689 |
% remember this special situation. |
| 2690 |
% \begin{macrocode} |
| 2691 |
\cb@topleft\cb@maxpoint\advance\cb@topleft\@ne |
| 2692 |
\else |
| 2693 |
% \end{macrocode} |
| 2694 |
% Recursively call ourselves. |
| 2695 |
% \begin{macrocode} |
| 2696 |
\expandafter\expandafter\expandafter\cb@FindPageNum |
| 2697 |
\fi |
| 2698 |
\fi |
| 2699 |
}% |
| 2700 |
% \end{macrocode} |
| 2701 |
% \end{macro} |
| 2702 |
% |
| 2703 |
% \begin{macro}{\cb@setBeginPoints} |
| 2704 |
% \changes{v3.3a}{1997/09/26}{Renamed from \cs{cb@setBeginPoint} and |
| 2705 |
% removed parameter; use new dimension register for positioning} |
| 2706 |
% The macro |\cb@setBeginPoints| assigns a position to the top left |
| 2707 |
% and top right points. It determines wether the point is on an even |
| 2708 |
% or an odd page and uses the right dimension to position the |
| 2709 |
% point. Keep in mind that the value of |\cb@pagecount| is one |
| 2710 |
% less than the value of |\c@page| unless the latter has been reset |
| 2711 |
% by the user. |
| 2712 |
% |
| 2713 |
% The top left point is used to write an entry on the \file{.aux} |
| 2714 |
% file to create the history stack on the next run. |
| 2715 |
% \changes{v3.5a}{2005/05/23}{Correction for mixed onecolumn and twocolumn |
| 2716 |
% documents and page number changes} |
| 2717 |
% \begin{macrocode} |
| 2718 |
\def\cb@setBeginPoints{% |
| 2719 |
\cb@topright=\cb@topleft\advance\cb@topright by\@ne |
| 2720 |
\cb@cntb=\cb@pagecount |
| 2721 |
\divide\cb@cntb by\tw@ |
| 2722 |
\ifodd\cb@cntb |
| 2723 |
\cb@defpoint\cb@topleft\cb@even@left |
| 2724 |
\cb@defpoint\cb@topright\cb@even@right |
| 2725 |
\else |
| 2726 |
\cb@defpoint\cb@topleft\cb@odd@left |
| 2727 |
\cb@defpoint\cb@topright\cb@odd@right |
| 2728 |
\fi |
| 2729 |
\cb@writeAux\cb@topleft |
| 2730 |
} |
| 2731 |
% \end{macrocode} |
| 2732 |
% \end{macro} |
| 2733 |
% |
| 2734 |
% \begin{macro}{\cb@setEndPoints} |
| 2735 |
% \changes{v3.3a}{1997/09/26}{Renamed from \cs{cb@setEndPoint} and |
| 2736 |
% removed parameter; use new dimension register for positioning} |
| 2737 |
% The macro |\cb@setEndPoints| assigns positions to the bottom |
| 2738 |
% points for a change bar. It then instructs the driver to connect |
| 2739 |
% two points with a bar. The macro assumes that the width of the |
| 2740 |
% bar is stored in |\cb@curbarwd|. |
| 2741 |
% |
| 2742 |
% The bottom right point is used to write to the \file{.aux} file |
| 2743 |
% to signal the end of the current bar on the history stack. |
| 2744 |
% \changes{v3.3g}{1999/06/12}{Take the setting of \Lopt{twoside} into |
| 2745 |
% account} |
| 2746 |
% \changes{v3.5a}{2005/05/23}{The test for \Lopt{twoside} is really |
| 2747 |
% unnecessary if the even side is always chosen for an even page} |
| 2748 |
% \changes{v3.5a}{2005/05/23}{Correction for mixed onecolumn and twocolumn |
| 2749 |
% documents and page number changes} |
| 2750 |
% \begin{macrocode} |
| 2751 |
\def\cb@setEndPoints{% |
| 2752 |
\cb@topright=\cb@topleft\advance\cb@topright by\@ne |
| 2753 |
\cb@botleft=\cb@topleft\advance\cb@botleft by\tw@ |
| 2754 |
\cb@botright=\cb@topleft\advance\cb@botright by\thr@@ |
| 2755 |
\cb@cntb=\cb@pagecount |
| 2756 |
\divide\cb@cntb by\tw@ |
| 2757 |
\ifodd\cb@cntb |
| 2758 |
\cb@defpoint\cb@botleft\cb@even@left |
| 2759 |
\cb@defpoint\cb@botright\cb@even@right |
| 2760 |
\else |
| 2761 |
\cb@defpoint\cb@botleft\cb@odd@left |
| 2762 |
\cb@defpoint\cb@botright\cb@odd@right |
| 2763 |
\fi |
| 2764 |
\cb@writeAux\cb@botright |
| 2765 |
\edef\cb@leftbar{% |
| 2766 |
\noexpand\cb@connect{\cb@topleft}{\cb@botleft}{\cb@curbarwd}}% |
| 2767 |
\edef\cb@rightbar{% |
| 2768 |
\noexpand\cb@connect{\cb@topright}{\cb@botright}{\cb@curbarwd}}% |
| 2769 |
% \end{macrocode} |
| 2770 |
% \changes{v3.3a}{1997/09/26}{Added support for typesetting twocolumn |
| 2771 |
% text with changebars} |
| 2772 |
% \changes{v3.5a}{2005/05/23}{Checking |@firstcolumn| outside the output |
| 2773 |
% routine is unreliable; check \cs{cb@pagecount} instead} |
| 2774 |
% In twocolumn pages always use outerbars |
| 2775 |
% \begin{macrocode} |
| 2776 |
\if@twocolumn |
| 2777 |
\ifodd\cb@pagecount\cb@rightbar\else\cb@leftbar\fi |
| 2778 |
% \end{macrocode} |
| 2779 |
% |
| 2780 |
% \changes{v3.4e}{2001/09/07}{The \cs{outerbars} conditional should be |
| 2781 |
% inside an \cs{else} clause} |
| 2782 |
% \changes{v3.5a}{2005/05/23}{Series of \cs{if}s replaced by |
| 2783 |
% \cs{ifcase} on \cs{cb@barsplace}} |
| 2784 |
% \begin{macrocode} |
| 2785 |
\else |
| 2786 |
\ifcase\cb@barsplace |
| 2787 |
% \end{macrocode} |
| 2788 |
% 0=innerbars |
| 2789 |
% \begin{macrocode} |
| 2790 |
\ifodd\cb@cntb |
| 2791 |
\cb@rightbar |
| 2792 |
\else |
| 2793 |
\if@twoside\cb@leftbar\else\cb@rightbar\fi |
| 2794 |
\fi |
| 2795 |
\or |
| 2796 |
% \end{macrocode} |
| 2797 |
% 1=outerbars |
| 2798 |
% \begin{macrocode} |
| 2799 |
\ifodd\cb@cntb |
| 2800 |
\cb@leftbar |
| 2801 |
\else |
| 2802 |
\if@twoside\cb@rightbar\else\cb@leftbar\fi |
| 2803 |
\fi |
| 2804 |
\or |
| 2805 |
% \end{macrocode} |
| 2806 |
% 2=leftbars |
| 2807 |
% \begin{macrocode} |
| 2808 |
\cb@leftbar |
| 2809 |
\or |
| 2810 |
% \end{macrocode} |
| 2811 |
% 3=rightbars |
| 2812 |
% \begin{macrocode} |
| 2813 |
\cb@rightbar |
| 2814 |
\fi |
| 2815 |
\fi |
| 2816 |
}% |
| 2817 |
% \end{macrocode} |
| 2818 |
% \end{macro} |
| 2819 |
% |
| 2820 |
% \begin{macro}{\cb@writeAux} |
| 2821 |
% The macro |\cb@writeAux| writes information about a changebar |
| 2822 |
% point to the auxiliary file. The number of the point, the |
| 2823 |
% pagenumber and the width of the bar are written out as arguments |
| 2824 |
% to |\cb@barpoint|. This latter macro will be expanded when the |
| 2825 |
% auxiliary file is read in. The macro assumes that the width of |
| 2826 |
% bar is stored in |\cb@curbarwd|. |
| 2827 |
% |
| 2828 |
% The code is only executed when auxiliary files are enabled, as |
| 2829 |
% there's no sense in trying to write to an unopened file. |
| 2830 |
% \begin{macrocode} |
| 2831 |
\def\cb@writeAux#1{% |
| 2832 |
\if@filesw |
| 2833 |
\begingroup |
| 2834 |
\edef\point{\the#1}% |
| 2835 |
\edef\level{\the\cb@curbarwd}% |
| 2836 |
\let\the=\z@ |
| 2837 |
\edef\cb@temp{\write\@auxout |
| 2838 |
{\string\cb@barpoint{\point}{\the\cb@pagecount}{\level}}}% |
| 2839 |
\cb@temp |
| 2840 |
\endgroup |
| 2841 |
\fi} |
| 2842 |
% \end{macrocode} |
| 2843 |
% \end{macro} |
| 2844 |
% |
| 2845 |
% \subsection{Macros for Making It Work Across Page Breaks} |
| 2846 |
% \label{pagebreak} |
| 2847 |
% |
| 2848 |
% \changes{v3.5a}{2005/05/23}{Changes for twocolumn support: Detect page |
| 2849 |
% number changes in righthand columns.} |
| 2850 |
% \begin{Var}{@cb@pagejump} |
| 2851 |
% A switch to indicate that we have made a page correction. |
| 2852 |
% \begin{macrocode} |
| 2853 |
\newif\if@cb@pagejump |
| 2854 |
% \end{macrocode} |
| 2855 |
% \end{Var} |
| 2856 |
% \begin{macro}{\cb@pagejumplist} |
| 2857 |
% The list of pagecounts to be corrected. |
| 2858 |
% \begin{macrocode} |
| 2859 |
\def\cb@pagejumplst{-1} |
| 2860 |
% \end{macrocode} |
| 2861 |
% \end{macro} |
| 2862 |
% \begin{macro}{\cb@nextpagejump} |
| 2863 |
% The next pagecount from the list. |
| 2864 |
% \begin{macrocode} |
| 2865 |
\def\cb@nextpagejump{-1} |
| 2866 |
% \end{macrocode} |
| 2867 |
% \end{macro} |
| 2868 |
% \begin{macro}{\cb@pagejump} |
| 2869 |
% This macro is written to the \file{.aux} file when a pagecount in a |
| 2870 |
% lefthand column should be corrected. The argument is the incorrect |
| 2871 |
% pagecount. |
| 2872 |
% \begin{macrocode} |
| 2873 |
\def\cb@pagejump#1{\xdef\cb@pagejumplst{\cb@pagejumplst,#1}} |
| 2874 |
% \end{macrocode} |
| 2875 |
% \end{macro} |
| 2876 |
% \begin{macro}{\cb@writepagejump} |
| 2877 |
% This macro writes a |\cb@pagejump| entry to the \file{.aux} file. |
| 2878 |
% It does it by putting the |\write| command in the |\@leftcolumn| so |
| 2879 |
% that it will be properly positioned relative to the bar points. |
| 2880 |
% \begin{macrocode} |
| 2881 |
\def\cb@writepagejump#1{ |
| 2882 |
\cb@cntb=\cb@pagecount |
| 2883 |
\advance\cb@cntb by#1\relax |
| 2884 |
\global\setbox\@leftcolumn\vbox to\@colht{% |
| 2885 |
\edef\cb@temp{\write\@auxout{\string\cb@pagejump{\the\cb@cntb}}}% |
| 2886 |
\cb@temp |
| 2887 |
\dimen@ \dp\@leftcolumn |
| 2888 |
\unvbox \@leftcolumn |
| 2889 |
\vskip -\dimen@ |
| 2890 |
}% |
| 2891 |
} |
| 2892 |
% \end{macrocode} |
| 2893 |
% \end{macro} |
| 2894 |
% \begin{macro}{\cb@poppagejump} |
| 2895 |
% Pop an entry from |pagejumplst|. The entry is put in |\cb@nextpagejump|. |
| 2896 |
% \begin{macrocode} |
| 2897 |
\def\cb@poppagejump#1,#2\relax{% |
| 2898 |
\gdef\cb@nextpagejump{#1}% |
| 2899 |
\gdef\cb@pagejumplst{#2}} |
| 2900 |
% \end{macrocode} |
| 2901 |
% \end{macro} |
| 2902 |
% |
| 2903 |
% \begin{macro}{\cb@checkpagecount} |
| 2904 |
% \changes{v3.5a}{2005/05/23}{Changes for better twocolumn support} |
| 2905 |
% This macro checks that |\cb@pagecount| is correct at the beginning of |
| 2906 |
% a column or page. |
| 2907 |
% First we ensure that |\cb@pagecount| has the proper parity: odd in the |
| 2908 |
% righthand column of a twocolumn page, even in the lefthand column of a |
| 2909 |
% twocolumn page and in onecolumn pages. |
| 2910 |
% \begin{macrocode} |
| 2911 |
\def\cb@checkpagecount{% |
| 2912 |
\if@twocolumn |
| 2913 |
\if@firstcolumn |
| 2914 |
\ifodd\cb@pagecount\global\advance\cb@pagecount by\@ne\fi |
| 2915 |
\fi |
| 2916 |
\else |
| 2917 |
\ifodd\cb@pagecount\global\advance\cb@pagecount by\@ne\fi |
| 2918 |
\fi |
| 2919 |
% \end{macrocode} |
| 2920 |
% \changes{v3.5a}{2005/05/23}{Changes for better twocolumn support} |
| 2921 |
% Also, in twosided documents, |\cb@pagecount|/2 must be odd on even pages |
| 2922 |
% and even on odd pages. If necessary, increase |\cb@pagecount| by 2. For |
| 2923 |
% onesided documents, we don't do this as it doesn't matter (but it |
| 2924 |
% would be harmless). |
| 2925 |
% In the righthand column in twoside documents we must check if |
| 2926 |
% |\cb@pagecount|/2 has the proper parity (see below). |
| 2927 |
% If it is incorrect, the page number has changed after the lefthand |
| 2928 |
% column, so |\cb@pagecount| is incorrect there. Therefore we write a |
| 2929 |
% command in the \file{.aux} file so that in the next run the lefthand |
| 2930 |
% column will correct its |\cb@pagecount|. We also need to signal |
| 2931 |
% a rerun. If the correction was |
| 2932 |
% made in the lefthand column, the flag |@cb@pagejump| is set, and we have |
| 2933 |
% to be careful in the righthand column. If in the righthand column the |
| 2934 |
% flag is set and |\cb@pagecount| is correct, the correction in the |
| 2935 |
% lefthand column worked, but we still have to write into the |
| 2936 |
% \file{.aux} file for the next run. If on the other hand |
| 2937 |
% |\cb@pagecount| is incorrect while the flag is set, apparently the |
| 2938 |
% correction in the lefthand column should not have been done (probably |
| 2939 |
% because the document has changed), so we do nothing. |
| 2940 |
% \begin{macrocode} |
| 2941 |
\if@twoside |
| 2942 |
\cb@cntb=\cb@pagecount |
| 2943 |
\divide\cb@cntb by\tw@ |
| 2944 |
\advance\cb@cntb by-\c@page |
| 2945 |
\ifodd\cb@cntb |
| 2946 |
% \end{macrocode} |
| 2947 |
% Here |\cb@pagecount| seems correct. Check if there is a page jump. |
| 2948 |
% \begin{macrocode} |
| 2949 |
\if@twocolumn |
| 2950 |
\if@firstcolumn |
| 2951 |
\@whilenum\cb@pagecount>\cb@nextpagejump\do{% |
| 2952 |
\expandafter\cb@poppagejump\cb@pagejumplst\relax}% |
| 2953 |
\ifnum\cb@pagecount=\cb@nextpagejump |
| 2954 |
\cb@trace{Page jump: \string\cb@pagecount=\the\cb@pagecount} |
| 2955 |
\global\advance\cb@pagecount by\tw@ |
| 2956 |
\global\@cb@pagejumptrue |
| 2957 |
\else |
| 2958 |
\global\@cb@pagejumpfalse |
| 2959 |
\fi |
| 2960 |
\else |
| 2961 |
% \end{macrocode} |
| 2962 |
% In the righthand column check the flag (see above). If set, write a |
| 2963 |
% pagejump, but compensate for the increase done in the lefthand column. |
| 2964 |
% \begin{macrocode} |
| 2965 |
\if@cb@pagejump |
| 2966 |
\cb@writepagejump{-3}% |
| 2967 |
\fi |
| 2968 |
\fi |
| 2969 |
\fi |
| 2970 |
\else |
| 2971 |
% \end{macrocode} |
| 2972 |
% Here |\cb@pagecount| is incorrect. |
| 2973 |
% \begin{macrocode} |
| 2974 |
\if@twocolumn |
| 2975 |
\if@firstcolumn |
| 2976 |
\global\advance\cb@pagecount by\tw@ |
| 2977 |
\global\@cb@pagejumpfalse |
| 2978 |
\else |
| 2979 |
\if@cb@pagejump |
| 2980 |
\cb@trace{Page jump annulled, % |
| 2981 |
\string\cb@pagecount=\the\cb@pagecount} |
| 2982 |
\else |
| 2983 |
\cb@writepagejump{-1}% |
| 2984 |
\global\advance\cb@pagecount by\tw@ |
| 2985 |
\cb@rerun |
| 2986 |
\fi |
| 2987 |
\fi |
| 2988 |
\else |
| 2989 |
\global\advance\cb@pagecount by\tw@ |
| 2990 |
\fi |
| 2991 |
\fi |
| 2992 |
\fi |
| 2993 |
} |
| 2994 |
% \end{macrocode} |
| 2995 |
% \end{macro} |
| 2996 |
% |
| 2997 |
% \begin{macro}{\@makecol} |
| 2998 |
% \begin{macro}{\@vtryfc} |
| 2999 |
% |
| 3000 |
% These internal \LaTeX\ macros are modified in order to end the |
| 3001 |
% changebars spanning the current page break (if any) and restart |
| 3002 |
% them on the next page. The modifications are needed to reset the |
| 3003 |
% special points for this page and add begin bars to top of box255. |
| 3004 |
% The bars carried over from the previous page, and hence to be |
| 3005 |
% restarted on this page, have been saved on the stack |
| 3006 |
% |\cb@beginstack|. This stack is used to define new starting |
| 3007 |
% points for the change bars, which are added to thetop of box |
| 3008 |
% |\@cclv|. Then the stack |\cb@endstack| is built and |
| 3009 |
% processed by |\cb@processActive|. Finally the original |
| 3010 |
% |\@makecol| (saved as |\cb@makecol|) is executed. |
| 3011 |
% |
| 3012 |
% \changes{3.2}{1994/04/21}{Added setting of \cs{boxmaxdepth}} |
| 3013 |
% \changes{v3.3a}{1997/09/26}{Let \cs{cb@writeAux} be \cs{@gobble} to |
| 3014 |
% prevent extra entries in the \file{.aux} file} |
| 3015 |
% \changes{v3.3a}{1997/09/26}{Now use the command |
| 3016 |
% \cs{cb@startSpanBars} to define top points for bars spoanning a |
| 3017 |
% page break} |
| 3018 |
% \changes{v3.5a}{2005/05/23}{Changes for better twocolumn support} |
| 3019 |
% \begin{macrocode} |
| 3020 |
\let\ltx@makecol\@makecol |
| 3021 |
\def\cb@makecol{% |
| 3022 |
\if@twocolumn |
| 3023 |
\cb@trace{Twocolumn: \if@firstcolumn Left \else Right \fi column}% |
| 3024 |
\fi |
| 3025 |
\cb@trace@stack{before makecol, page \the\c@page, |
| 3026 |
\string\cb@pagecount=\the\cb@pagecount}% |
| 3027 |
\let\cb@writeAux\@gobble |
| 3028 |
% \end{macrocode} |
| 3029 |
% First make sure that |\cb@pagecount| is correct. |
| 3030 |
% Then add the necessary bar points at beginning and end. |
| 3031 |
% \begin{macrocode} |
| 3032 |
\cb@checkpagecount |
| 3033 |
\setbox\@cclv \vbox{% |
| 3034 |
\cb@resetpoints |
| 3035 |
\cb@startSpanBars |
| 3036 |
\unvbox\@cclv |
| 3037 |
\boxmaxdepth\maxdepth}% |
| 3038 |
\global\advance\cb@pagecount by\@ne |
| 3039 |
\cb@buildstack\cb@processActive |
| 3040 |
\ltx@makecol |
| 3041 |
% \end{macrocode} |
| 3042 |
% \changes{v3.5a}{2005/05/23}{Changes for better twocolumn support} |
| 3043 |
% In twocolumn pages write information to the aux file to indicate which |
| 3044 |
% column we are in. This write must precede the whole column, including |
| 3045 |
% floats. Therefore we insert it in the front of |\@outputbox|. |
| 3046 |
% \begin{macrocode} |
| 3047 |
\if@twocolumn |
| 3048 |
\global\setbox\@outputbox \vbox to\@colht {% |
| 3049 |
\if@firstcolumn\write\@auxout{\string\@cb@firstcolumntrue}% |
| 3050 |
\else\write\@auxout{\string\@cb@firstcolumnfalse}% |
| 3051 |
\fi |
| 3052 |
\dimen@ \dp\@outputbox |
| 3053 |
\unvbox \@outputbox |
| 3054 |
\vskip -\dimen@ |
| 3055 |
}% |
| 3056 |
\fi |
| 3057 |
\cb@trace@stack{after makecol, page \the\c@page, |
| 3058 |
\string\cb@pagecount=\the\cb@pagecount}% |
| 3059 |
} |
| 3060 |
\let\@makecol\cb@makecol |
| 3061 |
% \end{macrocode} |
| 3062 |
% When \LaTeX\ makes a page with only floats it doesn't use |
| 3063 |
% |\@makecol|; instead it calls |\@vtryfc|, so we have to modify |
| 3064 |
% this macro as well. |
| 3065 |
% \changes{v3.3a}{1997/09/26}{Let \cs{cb@writeAux} be \cs{@gobble} to |
| 3066 |
% prevent extra entries in the \file{.aux} file} |
| 3067 |
% \changes{v3.3a}{1997/09/26}{Now use the command |
| 3068 |
% \cs{cb@startSpanBars} to define top points for bars spoanning a |
| 3069 |
% page break} |
| 3070 |
% \changes{v3.5a}{2005/05/23}{We don't want spanning changebars from a |
| 3071 |
% previous page in a float column. |
| 3072 |
% The original code didn't work anyway. It did set \@outputbox, |
| 3073 |
% which is immediately discarded in \cs{@ltx@vtryfc}.} |
| 3074 |
% In twocolumn mode we must write either \cs{@cb@firstcolumntrue} or |
| 3075 |
% \cs{@cb@firstcolumnfalse} to the \file{.aux} file. |
| 3076 |
% \begin{macrocode} |
| 3077 |
\let\ltx@vtryfc\@vtryfc |
| 3078 |
\def\cb@vtryfc#1{% |
| 3079 |
\cb@trace{In vtryfc, page \the\c@page, |
| 3080 |
\string\cb@pagecount=\the\cb@pagecount}% |
| 3081 |
\let\cb@writeAux\@gobble |
| 3082 |
% \end{macrocode} |
| 3083 |
% First make sure that |\cb@pagecount| is correct. |
| 3084 |
% Then generate a |\@cb@firstcolumntrue| or |\@cb@firstcolumnfalse| in |
| 3085 |
% twocolumn mode. |
| 3086 |
% \begin{macrocode} |
| 3087 |
\cb@checkpagecount |
| 3088 |
\ltx@vtryfc{#1}% |
| 3089 |
\if@twocolumn |
| 3090 |
\global\setbox\@outputbox \vbox to\@colht{% |
| 3091 |
\if@firstcolumn\write\@auxout{\string\@cb@firstcolumntrue}% |
| 3092 |
\else\write\@auxout{\string\@cb@firstcolumnfalse}% |
| 3093 |
\fi |
| 3094 |
\unvbox\@outputbox |
| 3095 |
\boxmaxdepth\maxdepth |
| 3096 |
}% |
| 3097 |
\fi |
| 3098 |
\global\advance\cb@pagecount by \@ne |
| 3099 |
} |
| 3100 |
\let\@vtryfc\cb@vtryfc |
| 3101 |
% \end{macrocode} |
| 3102 |
% \end{macro} |
| 3103 |
% \end{macro} |
| 3104 |
% |
| 3105 |
% \begin{macro}{\cb@processActive} |
| 3106 |
% |
| 3107 |
% This macro processes each element on span stack. Each element |
| 3108 |
% represents a bar that crosses the page break. There could be more |
| 3109 |
% than one if bars are nested. It works as follows: |
| 3110 |
% |
| 3111 |
% \begin{verbatim} |
| 3112 |
% pop top element of span stack |
| 3113 |
% if point null (i.e., stack empty) then done |
| 3114 |
% else |
| 3115 |
% do an end bar on box255 |
| 3116 |
% save start for new bar at top of next page in \cb@startSaves |
| 3117 |
% push active point back onto history stack (need to reprocess |
| 3118 |
% on next page). |
| 3119 |
% \end{verbatim} |
| 3120 |
% |
| 3121 |
% \begin{macrocode} |
| 3122 |
\def\cb@processActive{% |
| 3123 |
\cb@pop\cb@endstack |
| 3124 |
\ifnum\cb@topleft=\cb@nil |
| 3125 |
\else |
| 3126 |
\setbox\@cclv\vbox{% |
| 3127 |
\unvbox\@cclv |
| 3128 |
\boxmaxdepth\maxdepth |
| 3129 |
\advance\cb@pagecount by -1\relax |
| 3130 |
\cb@setEndPoints}% |
| 3131 |
\cb@push\cb@historystack |
| 3132 |
% \end{macrocode} |
| 3133 |
% |
| 3134 |
% \changes{v3.3a}{1997/09/26}{Now also push points on (new) |
| 3135 |
% \cs{cb@beginstack}} |
| 3136 |
% \begin{macrocode} |
| 3137 |
\cb@push\cb@beginstack |
| 3138 |
\expandafter\cb@processActive |
| 3139 |
\fi} |
| 3140 |
% \end{macrocode} |
| 3141 |
% \end{macro} |
| 3142 |
% |
| 3143 |
% \changes{v3.3a}{1997/09/26}{Removed \cs{cb@saveBeginPoints}} |
| 3144 |
% |
| 3145 |
% \begin{macro}{\cb@startSpanBars} |
| 3146 |
% \changes{v3.3a}{1997/09/26}{New macro} |
| 3147 |
% This macro defines new points for each bar that was pushed on the |
| 3148 |
% |\cb@beginstack|. Afterwards |\cb@beginstack| is empty. |
| 3149 |
% \changes{v3.3g}{1999/06/11}{Added stack tracing; no longer push |
| 3150 |
% points on \cs{cb@currenstack}} |
| 3151 |
% \begin{macrocode} |
| 3152 |
\def\cb@startSpanBars{% |
| 3153 |
\cb@pop\cb@beginstack |
| 3154 |
\ifnum\cb@topleft=\cb@nil |
| 3155 |
\else |
| 3156 |
\cb@setBeginPoints |
| 3157 |
\cb@trace@stack{after StartSpanBars, page \the\c@page}% |
| 3158 |
\expandafter\cb@startSpanBars |
| 3159 |
\fi |
| 3160 |
} |
| 3161 |
% \end{macrocode} |
| 3162 |
% \end{macro} |
| 3163 |
% |
| 3164 |
% \begin{macro}{\cb@buildstack} |
| 3165 |
% \begin{macro}{\cb@endstack} |
| 3166 |
% |
| 3167 |
% The macro |\cb@buildstack| initializes the stack with open bars |
| 3168 |
% and starts populating it. |
| 3169 |
% \begin{macrocode} |
| 3170 |
\def\cb@buildstack{% |
| 3171 |
\cb@initstack\cb@endstack |
| 3172 |
\cb@pushNextActive} |
| 3173 |
% \end{macrocode} |
| 3174 |
% \end{macro} |
| 3175 |
% \end{macro} |
| 3176 |
% |
| 3177 |
% \begin{macro}{\cb@pushNextActive} |
| 3178 |
% This macro pops the top element off the history stack |
| 3179 |
% (|\cb@historystack|). If the top left point is on a future page, |
| 3180 |
% it is pushed back onto the history stack and processing stops. |
| 3181 |
% If the point on the current or a previous page and it has an odd |
| 3182 |
% number, the point is pushed on the stack with end points |
| 3183 |
% |\cb@endstack|); if the point has an even number, it is popped |
| 3184 |
% off the stack with end points since the bar to which it belongs |
| 3185 |
% has terminated on the current page. |
| 3186 |
% \begin{macrocode} |
| 3187 |
\def\cb@pushNextActive{% |
| 3188 |
\cb@pop\cb@historystack |
| 3189 |
\ifnum\cb@topleft=\cb@nil |
| 3190 |
\else |
| 3191 |
\ifnum\cb@page>\cb@pagecount |
| 3192 |
\cb@push\cb@historystack |
| 3193 |
\else |
| 3194 |
\ifodd\cb@topleft |
| 3195 |
\cb@push\cb@endstack |
| 3196 |
\else |
| 3197 |
\cb@pop\cb@endstack |
| 3198 |
\fi |
| 3199 |
\expandafter\expandafter\expandafter\cb@pushNextActive |
| 3200 |
\fi |
| 3201 |
\fi} |
| 3202 |
% \end{macrocode} |
| 3203 |
% \end{macro} |
| 3204 |
% |
| 3205 |
% \subsection{Macros For Managing The Stacks of Bar points} |
| 3206 |
% |
| 3207 |
% The macros make use of four stacks corresponding to |\special| |
| 3208 |
% defpoints. Each stack takes the form \texttt{<element> |
| 3209 |
% ... <element>} |
| 3210 |
% |
| 3211 |
% Each element is of the form \texttt{xxxnyyypzzzl} where |
| 3212 |
% \texttt{xxx} is the number of the special point, \texttt{yyy} is |
| 3213 |
% the page on which this point is set, and \texttt{zzz} is the |
| 3214 |
% dimension used when connecting this point. |
| 3215 |
% |
| 3216 |
% The stack |\cb@historystack| is built from the log information |
| 3217 |
% and initially lists all the points. As pages are processed, |
| 3218 |
% points are popped off the stack and discarded. |
| 3219 |
% |
| 3220 |
% The stack |\cb@endstack| and |\cb@beginstack| are two temporary |
| 3221 |
% stacks used by the output routine and contain the stack with |
| 3222 |
% definitions for of all bars crossing the current pagebreak (there |
| 3223 |
% may be more than one with nested bars). |
| 3224 |
% They are built by popping elements off the history stack. |
| 3225 |
% |
| 3226 |
% The stack |\cb@currentstack| contains all the current bars. |
| 3227 |
% A |\cb@start| pushes an element onto this stack. |
| 3228 |
% A |\cb@end| pops the top element off the stack and uses the |
| 3229 |
% info to terminate the bar. |
| 3230 |
% |
| 3231 |
% For performance and memory reasons, the history stack, which can |
| 3232 |
% be very long, is special cased and a file is used to store this |
| 3233 |
% stack rather than an internal macro. The ``external'' interface |
| 3234 |
% to this stack is identical to what is described above. However, |
| 3235 |
% when the history stack is popped, a line from the file is first |
| 3236 |
% read and appended to the macro |\cb@historystack|. |
| 3237 |
% |
| 3238 |
% \begin{macro}{\cb@initstack} |
| 3239 |
% A macro to (globally) initialize a stack. |
| 3240 |
% \begin{macrocode} |
| 3241 |
\def\cb@initstack#1{\xdef#1{}} |
| 3242 |
% \end{macrocode} |
| 3243 |
% \end{macro} |
| 3244 |
% |
| 3245 |
% \begin{macro}{\cb@historystack} |
| 3246 |
% \begin{macro}{\cb@write} |
| 3247 |
% \begin{macro}{\cb@read} |
| 3248 |
% We need to initialise a stack to store the entries read from the |
| 3249 |
% external history file. |
| 3250 |
% \begin{macrocode} |
| 3251 |
\cb@initstack\cb@historystack |
| 3252 |
% \end{macrocode} |
| 3253 |
% We also need to allocate a read and a write stream for the |
| 3254 |
% history file. |
| 3255 |
% \begin{macrocode} |
| 3256 |
\newwrite\cb@write |
| 3257 |
\newread\cb@read |
| 3258 |
% \end{macrocode} |
| 3259 |
% And we open the history file for writing (which is done when the |
| 3260 |
% \file{.aux} file is read in). |
| 3261 |
% \begin{macrocode} |
| 3262 |
\immediate\openout\cb@write=\jobname.cb\relax |
| 3263 |
% \end{macrocode} |
| 3264 |
% \end{macro} |
| 3265 |
% \end{macro} |
| 3266 |
% \end{macro} |
| 3267 |
% |
| 3268 |
% \begin{macro}{\cb@endstack} |
| 3269 |
% \begin{macro}{\cb@beginstack} |
| 3270 |
% Allocate two stacks for the bars that span the current page break. |
| 3271 |
% \begin{macrocode} |
| 3272 |
\cb@initstack\cb@endstack |
| 3273 |
\cb@initstack\cb@beginstack |
| 3274 |
% \end{macrocode} |
| 3275 |
% \end{macro} |
| 3276 |
% \end{macro} |
| 3277 |
% |
| 3278 |
% \begin{macro}{\cb@tempstack} |
| 3279 |
% Allocate a stack for temporary storage |
| 3280 |
% \begin{macrocode} |
| 3281 |
\cb@initstack\cb@tempstack |
| 3282 |
% \end{macrocode} |
| 3283 |
% \end{macro} |
| 3284 |
% |
| 3285 |
% \begin{macro}{\cb@currentstack} |
| 3286 |
% And we allocate an extra stack that is needed to implement nesting |
| 3287 |
% without having to rely on \TeX's grouping mechanism. |
| 3288 |
% \begin{macrocode} |
| 3289 |
\cb@initstack\cb@currentstack |
| 3290 |
% \end{macrocode} |
| 3291 |
% \end{macro} |
| 3292 |
% |
| 3293 |
% \begin{macro}{\cb@pop} |
| 3294 |
% |
| 3295 |
% This macro pops the top element off the named stack and puts the |
| 3296 |
% point value into |\cb@topleft|, the page value into |\cb@page| |
| 3297 |
% and the bar width into |\cb@curbarwd|. If the stack is empty, it |
| 3298 |
% returns a void value (|\cb@nil|) in |\cb@topleft| and sets |
| 3299 |
% |\cb@page=0|. |
| 3300 |
% |
| 3301 |
% \changes{v3.4b}{2001/08/27}{Use global assignments, added more stack |
| 3302 |
% tracing info} |
| 3303 |
% \changes{v3.5a}{2005/05/23}{The check for history stack is improved. |
| 3304 |
% Originally it succeeded if the stack contents was equal to the history |
| 3305 |
% stack; now it specifically checks that we are popping the history |
| 3306 |
% stack itself. Moreover we read from file only if the history |
| 3307 |
% stack is empty.} |
| 3308 |
% \begin{macrocode} |
| 3309 |
\def\cb@thehistorystack{\cb@historystack} |
| 3310 |
\def\cb@pop#1{% |
| 3311 |
\ifx #1\@empty |
| 3312 |
\def\cb@temp{#1}% |
| 3313 |
\ifx\cb@temp\cb@thehistorystack |
| 3314 |
\ifeof\cb@read |
| 3315 |
\else |
| 3316 |
{\endlinechar=-1\read\cb@read to\cb@temp |
| 3317 |
\xdef\cb@historystack{\cb@historystack\cb@temp}% |
| 3318 |
}% |
| 3319 |
\fi |
| 3320 |
\fi |
| 3321 |
\fi |
| 3322 |
\ifx#1\@empty |
| 3323 |
\global\cb@topleft\cb@nil |
| 3324 |
\global\cb@page\z@\relax |
| 3325 |
\else |
| 3326 |
\expandafter\cb@carcdr#1e#1% |
| 3327 |
\fi |
| 3328 |
\cb@trace@pop{#1}} |
| 3329 |
% \end{macrocode} |
| 3330 |
% \end{macro} |
| 3331 |
% |
| 3332 |
% \begin{macro}{\cb@carcdr} |
| 3333 |
% This macro is used to `decode' a stack entry. |
| 3334 |
% \changes{v3.3a}{1997/09/26}{No longer use \cs{@tempdima}} |
| 3335 |
% \changes{v3.4b}{2001/08/27}{Use global assignments} |
| 3336 |
% \begin{macrocode} |
| 3337 |
\def\cb@carcdr#1n#2p#3l#4e#5{% |
| 3338 |
\global\cb@topleft#1\relax |
| 3339 |
\global\cb@page#2\relax |
| 3340 |
\global\cb@curbarwd#3\relax |
| 3341 |
\xdef#5{#4}} |
| 3342 |
% \end{macrocode} |
| 3343 |
% \end{macro} |
| 3344 |
% |
| 3345 |
% \begin{macro}{\cb@push} |
| 3346 |
% |
| 3347 |
% The macro |\cb@push| Pushes |\cb@topleft|, |\cb@page| and |
| 3348 |
% |\cb@curbarwd| onto the top of the named stack. |
| 3349 |
% |
| 3350 |
% \changes{v3.4b}{2001/08/27}{Added more stack tracing info} |
| 3351 |
% \begin{macrocode} |
| 3352 |
\def\cb@push#1{% |
| 3353 |
\xdef#1{\the\cb@topleft n\the\cb@page p\the\cb@curbarwd l#1}% |
| 3354 |
\cb@trace@push{#1}} |
| 3355 |
|
| 3356 |
% \end{macrocode} |
| 3357 |
% \end{macro} |
| 3358 |
% |
| 3359 |
% \begin{macro}{\cb@barpoint} |
| 3360 |
% The macro |\cb@barpoint| populates the history file. It writes |
| 3361 |
% one line to \file{.cb} file which is equivalent to one |
| 3362 |
% \meta{element} described above. |
| 3363 |
% \changes{v3.5a}{2005/05/23}{Changes for twocolumn support: if a bar point |
| 3364 |
% is in the left column we have to subtract one from the pagecount.} |
| 3365 |
% \begin{macrocode} |
| 3366 |
\def\cb@barpoint#1#2#3{\cb@cnta=#2 |
| 3367 |
\if@cb@firstcolumn\advance\cb@cnta by\m@ne\fi |
| 3368 |
\immediate\write\cb@write{#1n\the\cb@cnta p#3l}} |
| 3369 |
% \end{macrocode} |
| 3370 |
% \end{macro} |
| 3371 |
% |
| 3372 |
% \subsection{Macros For Checking That The \file{.aux} File Is Stable} |
| 3373 |
% |
| 3374 |
% \begin{macro}{\AtBeginDocument} |
| 3375 |
% |
| 3376 |
% While reading the \file{.aux} file, \LaTeX{} has created the |
| 3377 |
% history stack in a separate file. We need to close that file and |
| 3378 |
% open it for reading. Also the `initialisation' of the |
| 3379 |
% |\special| commands has to take place. While we are |
| 3380 |
% modifying the macro we also include the computation of the |
| 3381 |
% possible positions of the changebars |
| 3382 |
% |
| 3383 |
% For these actions we need to add to the \LaTeX\ begin-document |
| 3384 |
% hook. |
| 3385 |
% \changes{3.2}{1994/04/21}{Use the \cs{AtBeginDocument} instead of |
| 3386 |
% redefining \cs{document}} |
| 3387 |
% \begin{macrocode} |
| 3388 |
\AtBeginDocument{% |
| 3389 |
\cb@setup@specials |
| 3390 |
% \end{macrocode} |
| 3391 |
% \changes{v3.5a}{2005/05/23}{Changes for better twocolumn support} |
| 3392 |
% Add a sentinel to \cs{cb@pagejumplst}. |
| 3393 |
% \begin{macrocode} |
| 3394 |
\cb@pagejump{999999999,}% |
| 3395 |
% \end{macrocode} |
| 3396 |
% \changes{v3.5a}{2005/05/23}{Adaption of \cs{cb@pagecount} is no longer |
| 3397 |
% necessary, as \cs{cb@pagecount} will be adjusted at the beginning of |
| 3398 |
% \cs{@makecol} and \cs{@vtryfc}.} |
| 3399 |
% Compute the left and right positions of the changebars. |
| 3400 |
% \changes{v3.4g}{2004/01/09}{Added tracing information for the left |
| 3401 |
% and right postions} |
| 3402 |
% \changes{v3.6d}{2022-05-06}{Added \cs{relax} to end the filename} |
| 3403 |
% \begin{macrocode} |
| 3404 |
\cb@positions |
| 3405 |
\cb@trace{% |
| 3406 |
Odd left : \the\cb@odd@left\space |
| 3407 |
Odd right : \the\cb@odd@right\MessageBreak |
| 3408 |
Even left: \the\cb@even@left\space |
| 3409 |
Even right: \the\cb@even@right |
| 3410 |
}% |
| 3411 |
\immediate\closeout\cb@write |
| 3412 |
\immediate\openin\cb@read=\jobname.cb\relax} |
| 3413 |
% \end{macrocode} |
| 3414 |
% \end{macro} |
| 3415 |
% |
| 3416 |
% \begin{macro}{\AtEndDocument} |
| 3417 |
% We need to issue a |\clearpage| to flush rest of document. (Note |
| 3418 |
% that I believe there is contention in this area: are there in |
| 3419 |
% fact situations in which the end-document hooks need to be called |
| 3420 |
% \emph{before} the final |\clearpage|? --- the documentation of |
| 3421 |
% \LaTeX\ itself implies that there are.) Then closes the \file{.cb} |
| 3422 |
% file and reopens it for checking. Initialize history stack (to |
| 3423 |
% be read from file). Let |\cb@barpoint=\cb@checkHistory| for |
| 3424 |
% checking. |
| 3425 |
% \changes{3.2}{1994/04/21}{Use \cs{AtEndDocument} now instead of |
| 3426 |
% redefining \cs{enddocument}} |
| 3427 |
% \changes{v3.6d}{2022-05-06}{Added \cs{relax} to end the filename} |
| 3428 |
% \begin{macrocode} |
| 3429 |
\AtEndDocument{% |
| 3430 |
\clearpage |
| 3431 |
\cb@initstack\cb@historystack |
| 3432 |
\immediate\closein\cb@read |
| 3433 |
\immediate\openin\cb@read=\jobname.cb\relax |
| 3434 |
% \end{macrocode} |
| 3435 |
% |
| 3436 |
% \changes{v3.5a}{2005/05/23}{For pdftex we also close and reread the |
| 3437 |
% \file{.cb2} file.} |
| 3438 |
% Let |\cb@pdfxy=\cb@checkPdfxy| for checking. Make |\cb@pagejump| dummy. |
| 3439 |
% \begin{macrocode} |
| 3440 |
\ifx\cb@readxy\@undefined |
| 3441 |
\else |
| 3442 |
\immediate\closein\cb@readxy |
| 3443 |
\immediate\openin\cb@readxy=\jobname.cb2\relax |
| 3444 |
\def\cb@pdfpoints{}% |
| 3445 |
\def\cb@pdfpagenr{0}% |
| 3446 |
\fi |
| 3447 |
\@cb@firstcolumnfalse |
| 3448 |
\cb@checkrerun |
| 3449 |
\let\cb@pdfxy\cb@checkPdfxy |
| 3450 |
\let\cb@pagejump\@gobble |
| 3451 |
\let\cb@barpoint\cb@checkHistory} |
| 3452 |
% \end{macrocode} |
| 3453 |
% \end{macro} |
| 3454 |
% |
| 3455 |
% \begin{macro}{\cb@checkHistory} |
| 3456 |
% |
| 3457 |
% Pops the top of the history stack (|\jobname.cb|) and checks to |
| 3458 |
% see if the point and page numbers are the same as the arguments |
| 3459 |
% $\#1$ and $\#2$ respectively. Prints a warning message if |
| 3460 |
% different. |
| 3461 |
% \changes{v3.5a}{2005/05/23}{Changes for twocolumn support: if a bar point |
| 3462 |
% is in the left column we have to subtract one from the pagecount.} |
| 3463 |
% \begin{macrocode} |
| 3464 |
\def\cb@checkHistory#1#2#3{% |
| 3465 |
\cb@pop\cb@historystack |
| 3466 |
\ifnum #1=\cb@topleft\relax |
| 3467 |
\cb@cnta=#2 |
| 3468 |
\if@cb@firstcolumn\advance\cb@cnta by\m@ne\fi |
| 3469 |
\ifnum \cb@cnta=\cb@page\relax |
| 3470 |
% \end{macrocode} |
| 3471 |
% Both page and point numbers are equal; do nothing, |
| 3472 |
% \begin{macrocode} |
| 3473 |
\else |
| 3474 |
% \end{macrocode} |
| 3475 |
% but generate a warning when page numbers don't match, or |
| 3476 |
% \begin{macrocode} |
| 3477 |
\cb@error |
| 3478 |
\fi |
| 3479 |
\else |
| 3480 |
% \end{macrocode} |
| 3481 |
% when point numbers don't match. |
| 3482 |
% \begin{macrocode} |
| 3483 |
\cb@error |
| 3484 |
\fi} |
| 3485 |
% \end{macrocode} |
| 3486 |
% Dummy definition for |\cb@checkPdfxy|. This will be overwritten by |
| 3487 |
% the \Lopt{pdftex} and \Lopt{xetex} options. |
| 3488 |
% \begin{macrocode} |
| 3489 |
\def\cb@checkPdfxy#1#2#3#4#5{} |
| 3490 |
% \end{macrocode} |
| 3491 |
% \end{macro} |
| 3492 |
% |
| 3493 |
% \begin{macro}{\cb@rerun} |
| 3494 |
% \changes{v3.5a}{2005/05/23}{Changes for better twocolumn support} |
| 3495 |
% The macro |\cb@rerun| is called when we detect that we need to rerun |
| 3496 |
% \LaTeX. |
| 3497 |
% \begin{macrocode} |
| 3498 |
\def\cb@rerun{% |
| 3499 |
\global\let\cb@checkrerun\cb@error} |
| 3500 |
\let\cb@checkrerun\relax |
| 3501 |
% \end{macrocode} |
| 3502 |
% \end{macro} |
| 3503 |
% |
| 3504 |
% \begin{macro}{\cb@error} |
| 3505 |
% When a mismatch between the changebar information in the |
| 3506 |
% auxiliary file and the history stack is detected a warning is |
| 3507 |
% issued; further checking is disabled. |
| 3508 |
% \changes{v3.5a}{2005/05/23}{Added pdftex support} |
| 3509 |
% For pdf\TeX and Xe\TeX we also disable |
| 3510 |
% |\cb@checkPdfxy|. |
| 3511 |
% \begin{macrocode} |
| 3512 |
\def\cb@error{% |
| 3513 |
\PackageWarning{Changebar}% |
| 3514 |
{Changebar info has changed.\MessageBreak |
| 3515 |
Rerun to get the bars right} |
| 3516 |
\gdef\cb@checkHistory##1##2##3{}% |
| 3517 |
\let\cb@barpoint\cb@checkHistory |
| 3518 |
\gdef\cb@checkPdfxy##1##2##3##4##5{}% |
| 3519 |
\let\cb@pdfxy\cb@checkPdfxy} |
| 3520 |
% \end{macrocode} |
| 3521 |
% \end{macro} |
| 3522 |
% |
| 3523 |
% \subsection{Macros For Making It Work With Nested Floats/Footnotes} |
| 3524 |
% |
| 3525 |
% \begin{macro}{\end@float} |
| 3526 |
% This is a replacement for the \LaTeX-macro of the same name. All |
| 3527 |
% it does is check to see if changebars are active and, if so, it |
| 3528 |
% puts changebars around the box containing the float. Then it |
| 3529 |
% calls the original \LaTeX\ |\end@float|. |
| 3530 |
% |
| 3531 |
% \begin{macrocode} |
| 3532 |
\let\ltx@end@float\end@float |
| 3533 |
% \end{macrocode} |
| 3534 |
% \changes{v3.3g}{1999/06/11}{Added stack tracing} |
| 3535 |
% \changes{v3.4b}{2001/08/27}{Call \cs{@endfloatbox} en use |
| 3536 |
% \cs{color@vbox} to take the extra box and group for color into |
| 3537 |
% account} |
| 3538 |
% \begin{macrocode} |
| 3539 |
\def\cb@end@float{% |
| 3540 |
\cb@trace@stack{end float on page \the\c@page}% |
| 3541 |
\cb@pop\cb@currentstack |
| 3542 |
\ifnum\cb@topleft=\cb@nil |
| 3543 |
\else |
| 3544 |
\cb@push\cb@currentstack |
| 3545 |
\global\cb@curbarwd=\cb@curbarwd |
| 3546 |
\@endfloatbox |
| 3547 |
\global\setbox\@currbox |
| 3548 |
\color@vbox |
| 3549 |
\normalcolor |
| 3550 |
\vbox\bgroup\cb@start[\cb@curbarwd]\unvbox\@currbox\cb@end |
| 3551 |
\fi |
| 3552 |
\ltx@end@float} |
| 3553 |
\let\end@float\cb@end@float |
| 3554 |
% \end{macrocode} |
| 3555 |
% This only works if this new version of |\end@float| is really |
| 3556 |
% used. With \LaTeX2.09 the documentstyles used to contain: |
| 3557 |
% \begin{verbatim} |
| 3558 |
% \let\endfigure\end@float |
| 3559 |
% \end{verbatim} |
| 3560 |
% In that case this binding has to be repeated after the |
| 3561 |
% redefinition of |\end@float|. However, the \LaTeXe\ class files |
| 3562 |
% use |\newenvironment| to define the \Lenv{figure} and |
| 3563 |
% \Lenv{table} environments. In that case there is no need to |
| 3564 |
% rebind |\endfigure|. |
| 3565 |
% \changes{3.2}{1994/04/21}{Removed |
| 3566 |
% \cs{let}\cs{endfigure}\cs{end@float}, no longer necessary} |
| 3567 |
% |
| 3568 |
% \begin{macro}{\@xympar} |
| 3569 |
% There is one snag with this redefinition in that the macro |
| 3570 |
% |\end@float| is also used by the command |\marginpar|. This may |
| 3571 |
% lead to problems with stack underflow. Therefore we need to |
| 3572 |
% redefine an internal macro from the marginal paragraph mechanism |
| 3573 |
% as well. The solution is to make sure the this macro uses the |
| 3574 |
% original definition of |\end@float|. |
| 3575 |
% \changes{v3.5d}{2005/12/24}{Redefine \cs{@xympar} to use the |
| 3576 |
% original version of \cs{end@float}} |
| 3577 |
% \begin{macrocode} |
| 3578 |
\let\ltx@@xympar\@xympar |
| 3579 |
\def\@xympar{% |
| 3580 |
\let\end@float\ltx@end@float |
| 3581 |
\ltx@@xympar |
| 3582 |
\let\end@float\cb@end@float} |
| 3583 |
% \end{macrocode} |
| 3584 |
% \end{macro} |
| 3585 |
% |
| 3586 |
% \end{macro} |
| 3587 |
% |
| 3588 |
% \begin{macro}{\float@end} |
| 3589 |
% When the \pkg{float} package is being used we need to take care |
| 3590 |
% of its changes to the float mechanism. It defines it's own macros |
| 3591 |
% (|\float@end| and |\float@dblend| which need to be modified for |
| 3592 |
% changebars to work. |
| 3593 |
% |
| 3594 |
% First we'll save the original as |\flt@float@end|. |
| 3595 |
% \begin{macrocode} |
| 3596 |
\let\flt@float@end\float@end |
| 3597 |
% \end{macrocode} |
| 3598 |
% Then we redefine it to insert the changebarcode. |
| 3599 |
% \begin{macrocode} |
| 3600 |
\def\float@end{% |
| 3601 |
\cb@trace@stack{end float on page \the\c@page}% |
| 3602 |
\cb@pop\cb@currentstack |
| 3603 |
\ifnum\cb@topleft=\cb@nil |
| 3604 |
\else |
| 3605 |
\cb@push\cb@currentstack |
| 3606 |
\global\cb@curbarwd\cb@curbarwd |
| 3607 |
\@endfloatbox |
| 3608 |
\global\setbox\@currbox |
| 3609 |
\color@vbox |
| 3610 |
\normalcolor |
| 3611 |
\vbox\bgroup\cb@start[\cb@curbarwd]\unvbox\@currbox\cb@end |
| 3612 |
\fi |
| 3613 |
\let\end@float\ltx@end@float |
| 3614 |
\flt@float@end |
| 3615 |
} |
| 3616 |
% \end{macrocode} |
| 3617 |
% \end{macro} |
| 3618 |
% |
| 3619 |
% \begin{macro}{\end@dblfloat} |
| 3620 |
% This is a replacement for the \LaTeX-macro of the same name. All |
| 3621 |
% it does is check to see if changebars are active and, if so, it |
| 3622 |
% puts changebars around the box containing the float. In this case |
| 3623 |
% the \LaTeX\ macro had to be rewritten. |
| 3624 |
% |
| 3625 |
% \changes{v3.4e}{2001/09/07}{Double column floats only carry a |
| 3626 |
% changebar with an appropriate change of \cs{end@dblfloat}} |
| 3627 |
% \begin{macrocode} |
| 3628 |
\let\ltx@end@dblfloat\end@dblfloat |
| 3629 |
\def\cb@end@dblfloat{% |
| 3630 |
\if@twocolumn |
| 3631 |
\cb@trace@stack{end dblfloat on page \the\c@page}% |
| 3632 |
\cb@pop\cb@currentstack |
| 3633 |
\ifnum\cb@topleft=\cb@nil |
| 3634 |
\else |
| 3635 |
\cb@push\cb@currentstack |
| 3636 |
\global\cb@curbarwd=\cb@curbarwd |
| 3637 |
\@endfloatbox |
| 3638 |
\global\setbox\@currbox |
| 3639 |
\color@vbox |
| 3640 |
\normalcolor |
| 3641 |
\vbox\bgroup\cb@start[\cb@curbarwd]\unvbox\@currbox\cb@end |
| 3642 |
\fi |
| 3643 |
\@endfloatbox |
| 3644 |
\ifnum\@floatpenalty <\z@ |
| 3645 |
\@largefloatcheck |
| 3646 |
\@cons\@dbldeferlist\@currbox |
| 3647 |
\fi |
| 3648 |
\ifnum \@floatpenalty =-\@Mii \@Esphack\fi |
| 3649 |
\else |
| 3650 |
\end@float |
| 3651 |
\fi} |
| 3652 |
\let\end@dblfloat\cb@end@dblfloat |
| 3653 |
% \end{macrocode} |
| 3654 |
% \end{macro} |
| 3655 |
% |
| 3656 |
% \begin{macro}{\float@dblend} |
| 3657 |
% Something similar needs to be done for the case where the |
| 3658 |
% \pkg{float} package is being used... |
| 3659 |
% \begin{macrocode} |
| 3660 |
\let\flt@float@dblend\float@dblend |
| 3661 |
\def\float@dblend{% |
| 3662 |
\cb@trace@stack{end dbl float on page \the\c@page}% |
| 3663 |
\cb@pop\cb@currentstack |
| 3664 |
\ifnum\cb@topleft=\cb@nil |
| 3665 |
\else |
| 3666 |
\cb@push\cb@currentstack |
| 3667 |
\global\cb@curbarwd=\cb@curbarwd |
| 3668 |
\@endfloatbox |
| 3669 |
\global\setbox\@currbox |
| 3670 |
\color@vbox |
| 3671 |
\normalcolor |
| 3672 |
\vbox\bgroup\cb@start[\cb@curbarwd]\unvbox\@currbox\cb@end |
| 3673 |
\fi |
| 3674 |
\let\end@dblfloat\ltx@end@dblfloat |
| 3675 |
\flt@float@dblend |
| 3676 |
} |
| 3677 |
% \end{macrocode} |
| 3678 |
% \end{macro} |
| 3679 |
% |
| 3680 |
% \begin{macro}{\@footnotetext} |
| 3681 |
% This is a replacement for the \LaTeX\ macro of the same name. |
| 3682 |
% It simply checks to see if changebars are active, and if so, |
| 3683 |
% wraps the macro argument (i.e., the footnote) in changebars. |
| 3684 |
% |
| 3685 |
% \changes{3.1b}{1993/10/11}{Added missing percent sign to prevent |
| 3686 |
% spurious white space in the output.} |
| 3687 |
% \begin{macrocode} |
| 3688 |
\let\ltx@footnotetext\@footnotetext |
| 3689 |
% \end{macrocode} |
| 3690 |
% \changes{v3.3g}{1999/06/11}{Added stack tracing} |
| 3691 |
% \begin{macrocode} |
| 3692 |
\long\def\cb@footnotetext#1{% |
| 3693 |
\cb@trace@stack{end footnote on page \the\c@page}% |
| 3694 |
\cb@pop\cb@currentstack |
| 3695 |
\ifnum\cb@topleft=\cb@nil |
| 3696 |
\ltx@footnotetext{#1}% |
| 3697 |
\else |
| 3698 |
\cb@push\cb@currentstack |
| 3699 |
\edef\cb@temp{\the\cb@curbarwd}% |
| 3700 |
\ltx@footnotetext{\cb@start[\cb@temp]#1\cb@end}% |
| 3701 |
\fi} |
| 3702 |
\let\@footnotetext\cb@footnotetext |
| 3703 |
% \end{macrocode} |
| 3704 |
% \end{macro} |
| 3705 |
% |
| 3706 |
% \begin{macro}{\@mpfootnotetext} |
| 3707 |
% |
| 3708 |
% Replacement for the \LaTeX\ macro of the same name. Same thing |
| 3709 |
% as |\@footnotetext|. |
| 3710 |
% |
| 3711 |
% \changes{3.1b}{1993/10/11}{Added missing percent sign to prevent |
| 3712 |
% spurious white space in the output.} |
| 3713 |
% \begin{macrocode} |
| 3714 |
\let\ltx@mpfootnotetext\@mpfootnotetext |
| 3715 |
% \end{macrocode} |
| 3716 |
% \begin{macrocode} |
| 3717 |
\long\def\cb@mpfootnotetext#1{% |
| 3718 |
\cb@pop\cb@currentstack |
| 3719 |
\ifnum\cb@topleft=\cb@nil |
| 3720 |
\ltx@mpfootnotetext{#1}% |
| 3721 |
\else |
| 3722 |
\cb@push\cb@currentstack |
| 3723 |
\edef\cb@temp{\the\cb@curbarwd}% |
| 3724 |
\ltx@mpfootnotetext{\cb@start[\cb@temp]#1\cb@end}% |
| 3725 |
\fi} |
| 3726 |
\let\@mpfootnotetext\cb@mpfootnotetext |
| 3727 |
%</package> |
| 3728 |
% \end{macrocode} |
| 3729 |
% \end{macro} |
| 3730 |
% |
| 3731 |
% |
| 3732 |
% \Finale |
| 3733 |
% |
| 3734 |
\endinput |
| 3735 |
%% \CharacterTable |
| 3736 |
%% {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 |
| 3737 |
%% 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 |
| 3738 |
%% Digits \0\1\2\3\4\5\6\7\8\9 |
| 3739 |
%% Exclamation \! Double quote \" Hash (number) \# |
| 3740 |
%% Dollar \$ Percent \% Ampersand \& |
| 3741 |
%% Acute accent \' Left paren \( Right paren \) |
| 3742 |
%% Asterisk \* Plus \+ Comma \, |
| 3743 |
%% Minus \- Point \. Solidus \/ |
| 3744 |
%% Colon \: Semicolon \; Less than \< |
| 3745 |
%% Equals \= Greater than \> Question mark \? |
| 3746 |
%% Commercial at \@ Left bracket \[ Backslash \\ |
| 3747 |
%% Right bracket \] Circumflex \^ Underscore \_ |
| 3748 |
%% Grave accent \` Left brace \{ Vertical bar \| |
| 3749 |
%% Right brace \} Tilde \~} |
| 3750 |
%% |
| 3751 |
%% |