| 1 |
% \iffalse^^A meta-comment |
| 2 |
% ====================================================================== |
| 3 |
% scrlayer-notecolumn.dtx |
| 4 |
% Copyright (c) Markus Kohm, 2013-2025 |
| 5 |
% |
| 6 |
% This file is part of the LaTeX2e KOMA-Script bundle. |
| 7 |
% |
| 8 |
% This work may be distributed and/or modified under the conditions of |
| 9 |
% the LaTeX Project Public License, version 1.3c of the license. |
| 10 |
% The latest version of this license is in |
| 11 |
% http://www.latex-project.org/lppl.txt |
| 12 |
% and version 1.3c or later is part of all distributions of LaTeX |
| 13 |
% version 2005/12/01 and of this work. |
| 14 |
% |
| 15 |
% This work has the LPPL maintenance status "author-maintained". |
| 16 |
% |
| 17 |
% The Current Maintainer and author of this work is Markus Kohm. |
| 18 |
% |
| 19 |
% This work consists of all files listed in MANIFEST.md. |
| 20 |
% ---------------------------------------------------------------------- |
| 21 |
% ====================================================================== |
| 22 |
%%% From File: $Id: scrlayer-notecolumn.dtx 4254 2025-12-31 12:10:11Z kohm $ |
| 23 |
%<identify>%%% (run: identify) |
| 24 |
%<init>%%% (run: init) |
| 25 |
%<options>%%% (run: options) |
| 26 |
%<body>%%% (run: body) |
| 27 |
%<final>%%% (run: final) |
| 28 |
%<*dtx> |
| 29 |
\ifx\ProvidesFile\undefined\def\ProvidesFile#1[#2]{}\fi |
| 30 |
\begingroup |
| 31 |
\def\filedate$#1: #2-#3-#4 #5${\gdef\filedate{#2/#3/#4}} |
| 32 |
\filedate$Date: 2025-12-31 13:10:11 +0100 (Mi, 31. Dez 2025) $ |
| 33 |
\def\filerevision$#1: #2 ${\gdef\filerevision{v0.4.#2}} |
| 34 |
\filerevision$Revision: 4254 $ |
| 35 |
\edef\reserved@a{% |
| 36 |
\noexpand\endgroup |
| 37 |
\noexpand\ProvidesFile{scrlayer-notecolumn.dtx}% |
| 38 |
[\filedate\space\filerevision\space |
| 39 |
KOMA-Script package source |
| 40 |
}% |
| 41 |
\reserved@a |
| 42 |
%</dtx> |
| 43 |
%<*identify|doc> |
| 44 |
%<interface>\NeedsTeXFormat{LaTeX2e}[2022/06/01] |
| 45 |
%<interface>\ProvidesPackage{scrlayer-notecolumn}[% |
| 46 |
%<doc>\ProvidesFile{scrlayer-notecolumn.tex}[% |
| 47 |
% Sometimes following will be replaced by !KOMASCRIPTVERSION: |
| 48 |
%!SCRLAYERVERSION |
| 49 |
%<interface> package |
| 50 |
%</identify|doc> |
| 51 |
%<*dtx|identify|doc> |
| 52 |
(end user interface for scrlayer)] |
| 53 |
%</dtx|identify|doc> |
| 54 |
%<*dtx> |
| 55 |
\ifx\documentclass\undefined |
| 56 |
\input scrdocstrip.tex |
| 57 |
\@@input scrkernel-version.dtx |
| 58 |
\expandafter\let\csname ifbetawas\expandafter\endcsname |
| 59 |
\csname ifbeta\endcsname |
| 60 |
\expandafter\let\csname ifbeta\expandafter\endcsname |
| 61 |
\csname iftrue\endcsname |
| 62 |
\@@input scrstrip.inc |
| 63 |
\KOMAdefVariable{COPYRIGHTFROM}{2013} |
| 64 |
\KOMAdefVariable{SCRLAYERVERSION}{% |
| 65 |
\space\space\filedate\space\filerevision\space KOMA-Script |
| 66 |
}% |
| 67 |
\def\@defCOPYRIGHTTILL#1/#2/#3\@nil{% |
| 68 |
\def\@tempa{#1}\def\@tempb{}\ifx\@tempa\@tempb\else |
| 69 |
\KOMAdefVariable{COPYRIGHTTILL}{#1}% |
| 70 |
\fi |
| 71 |
}\expandafter\@defCOPYRIGHTTILL\filedate\@nil |
| 72 |
\generate{\usepreamble\defaultpreamble |
| 73 |
\file{scrlayer-notecolumn.sty}{% |
| 74 |
\from{scrlayer-notecolumn.dtx}{interface,notecolumn,identify}% |
| 75 |
\from{scrlayer.dtx}{interface,notecolumn,init}% |
| 76 |
\from{scrlayer-notecolumn.dtx}{interface,notecolumn,init}% |
| 77 |
\from{scrlayer.dtx}{interface,notecolumn,options}% |
| 78 |
\from{scrlayer-notecolumn.dtx}{interface,notecolumn,options}% |
| 79 |
\from{scrlayer.dtx}{interface,notecolumn,body}% |
| 80 |
\from{scrlayer-notecolumn.dtx}{interface,notecolumn,body}% |
| 81 |
\from{scrlayer-notecolumn.dtx}{interface,notecolumn,final}% |
| 82 |
\from{scrlogo.dtx}{logo}% |
| 83 |
}% |
| 84 |
} |
| 85 |
\expandafter\let\csname ifbeta\expandafter\endcsname |
| 86 |
\csname ifbetawas\endcsname |
| 87 |
\@@input scrstrop.inc |
| 88 |
\else |
| 89 |
\let\endbatchfile\relax |
| 90 |
\fi |
| 91 |
\endbatchfile |
| 92 |
\documentclass[USenglish]{koma-script-source-doc} |
| 93 |
\usepackage{babel} |
| 94 |
\usepackage{hvlogos} |
| 95 |
\setcounter{StandardModuleDepth}{2} |
| 96 |
\begin{document} |
| 97 |
\DocInput{scrlayer-notecolumn.dtx} |
| 98 |
\end{document} |
| 99 |
%</dtx> |
| 100 |
% \fi^^A meta-comment |
| 101 |
% |
| 102 |
% \changes{v0.0}{2013/04/26}{start of interface} |
| 103 |
% \changes{v0.3.3532}{2020/09/11}{do not use deprecated interface commands} |
| 104 |
% \changes{v3.36}{2022/02/10}{switch over from \cls*{scrdoc} to |
| 105 |
% \cls*{koma-script-source-doc}} |
| 106 |
% \changes{v3.36}{2022/02/10}{require package \pkg*{scrlogo} instead of |
| 107 |
% defining \cs{KOMAScript}} |
| 108 |
% \changes{v3.40}{2023/04/17}{guide names changed} |
| 109 |
% |
| 110 |
% \GetFileInfo{scrlayer-notecolumn.dtx} |
| 111 |
% \title{Providing Note Columns Similar to \cs{marginpar} with |
| 112 |
% \href{https://komascript.de}{\KOMAScript} Package |
| 113 |
% \pkg*{scrlayer-notecolumn} as Proof of Concept about Layers with |
| 114 |
% \href{https://komascript.de}{\KOMAScript} Package \pkg*{scrlayer}} |
| 115 |
% \author{\href{mailto:[email protected]}{Markus Kohm}} |
| 116 |
% \date{Version \fileversion{} of \filedate} |
| 117 |
% \maketitle |
| 118 |
% \begin{abstract} |
| 119 |
% This package is only a proof of concept. The main sense of the package is, |
| 120 |
% to show the power of layers with \pkg{scrlayer}. It was never intended to |
| 121 |
% be used as a productivity package. So there is no support for using |
| 122 |
% it. Several features are only rudimentary. Several can be improved. Please |
| 123 |
% feel free to fork this package. |
| 124 |
% \end{abstract} |
| 125 |
% \tableofcontents |
| 126 |
% |
| 127 |
% \section{User Manual} |
| 128 |
% |
| 129 |
% You can find the user manuals of \pkg*{scrlayer-notecolumn} in the |
| 130 |
% \KOMAScript{} manual, either the German \file{scrguide-de.pdf} or the |
| 131 |
% English \file{scrguide-en.pdf}. |
| 132 |
% |
| 133 |
% \MaybeStop{\PrintIndex} |
| 134 |
% |
| 135 |
% \section{Implementation of \pkg*{scrlayer-notecolumn}} |
| 136 |
% |
| 137 |
% \begin{macrocode} |
| 138 |
%<*interface> |
| 139 |
% \end{macrocode} |
| 140 |
% |
| 141 |
% |
| 142 |
% \subsection{Initialising some values before the options} |
| 143 |
% |
| 144 |
% Initialization before all options (even the options from |
| 145 |
% \file{scrlayer.dtx}). |
| 146 |
% |
| 147 |
% Here we test the used pdf\TeX{} primitives. |
| 148 |
% \changes{v0.1}{2015/10/07}{ready for renaming \cs{pdfsavepos} and |
| 149 |
% \cs{pdflastypos} in luaTeX} |
| 150 |
% \changes{v0.1.2483}{2016/06/28}{grouping fixed} |
| 151 |
% \begin{macrocode} |
| 152 |
%<*init> |
| 153 |
\@tempswatrue |
| 154 |
\scr@ifundefinedorrelax{pdfsavepos}{% |
| 155 |
\scr@ifundefinedorrelax{savepos}{% |
| 156 |
\expandafter\@tempswafalse |
| 157 |
}{% |
| 158 |
\let\scr@savepos\savepos |
| 159 |
}% |
| 160 |
}{% |
| 161 |
\let\scr@savepos\pdfsavepos |
| 162 |
} |
| 163 |
\scr@ifundefinedorrelax{pdflastypos}{% |
| 164 |
\scr@ifundefinedorrelax{lastypos}{% |
| 165 |
\expandafter\@tempswafalse |
| 166 |
}{% |
| 167 |
\let\scr@lastypos\lastypos |
| 168 |
}% |
| 169 |
}{% |
| 170 |
\let\scr@lastypos\pdflastypos |
| 171 |
}% |
| 172 |
\if@tempswa\else |
| 173 |
\PackageError{scrlayer-notecolumn}{missing pdfTeX/luaTeX features}{% |
| 174 |
This package needs \string\pdfsavepos\space or \string\savepos\space |
| 175 |
and\MessageBreak |
| 176 |
\string\pdflastypos\space or \string\lastypos.\MessageBreak |
| 177 |
This error is fatal, because usage of the package without these |
| 178 |
features\MessageBreak |
| 179 |
cannot work!\MessageBreak |
| 180 |
You shouldn't continue, but if you'd try, I'll try to abort the LaTeX run |
| 181 |
}% |
| 182 |
\batchmode\csname @@end\endcsname\end |
| 183 |
\fi |
| 184 |
%</init> |
| 185 |
% \end{macrocode} |
| 186 |
% |
| 187 |
% |
| 188 |
% \subsection{Making a note column} |
| 189 |
% |
| 190 |
% The package supports a various number of note columns. Each is referenced by |
| 191 |
% a unique name. |
| 192 |
% |
| 193 |
% \begin{command}{\DeclareNoteColumn} |
| 194 |
% \begin{description} |
| 195 |
% \item[\oarg{option list}:] a comma-separated list of |
| 196 |
% \texttt{\meta{key}=\meta{value}} pairs. |
| 197 |
% \item[\marg{string}:] the name of the note column (must be fully expandable |
| 198 |
% and expand to a string only). |
| 199 |
% \end{description} |
| 200 |
% That's the primary command for note columns. It defines everything, the note |
| 201 |
% column needs. |
| 202 |
% \begin{macrocode} |
| 203 |
%<*body> |
| 204 |
\newcommand*{\DeclareNoteColumn}[2][]{% |
| 205 |
% \end{macrocode} |
| 206 |
% First of all we need a box register. The contents of the note column will be |
| 207 |
% build inside of this register. Since \eTeX{} registers shouldn't be a |
| 208 |
% problem. User should use package \pkg{etex}, if he or she runs out of |
| 209 |
% registers. Note, that the registers will stay allocated, if the interface |
| 210 |
% will be removed! Nevertheless, the name will be destroyed! |
| 211 |
% \begin{macrocode} |
| 212 |
\@ifundefined{slnc@#2@box}{% |
| 213 |
\expandafter\newsavebox\csname slnc@#2@box\endcsname |
| 214 |
}{}% |
| 215 |
% \end{macrocode} |
| 216 |
% There's also a kind of item stack of unprocessed notes for each note column. |
| 217 |
% \begin{macrocode} |
| 218 |
\@ifundefined{slnc@#2@unprocessed}{% |
| 219 |
\@namedef{slnc@#2@unprocessed}{}% |
| 220 |
}{}% |
| 221 |
% \end{macrocode} |
| 222 |
% Next we need a horizontal positions and a width for the note column. Neither |
| 223 |
% the horizontal position nor the width are stretchable or shrinkable. The |
| 224 |
% position should be variable depending on the page. So it's better to use a |
| 225 |
% macro instead of a length. The width isn't more variable than, e.g., the |
| 226 |
% text width. So we can use a macro too. Both will be initialised to the |
| 227 |
% normal marginal note column later. |
| 228 |
% \changes{3.27}{2019/02/14}{initialization of one color stack per note column} |
| 229 |
% For color support we also need one color stack per note column. A color |
| 230 |
% stack is a feature only available for pdf\TeX{} and lua\TeX{}. |
| 231 |
% \begin{macrocode} |
| 232 |
\@ifundefined{slnc@#2@colorstack}{% |
| 233 |
\scr@ifundefinedorrelax{pdfcolorstackinit}{% |
| 234 |
\scr@ifundefinedorrelax{pdffeedback}{}{% |
| 235 |
\expandafter\chardef\csname slnc@#2@colorstack\endcsname= |
| 236 |
\pdffeedback colorstackinit direct {\slnc@initial@black}% |
| 237 |
}% |
| 238 |
}{% |
| 239 |
\expandafter\chardef\csname slnc@#2@colorstack\endcsname= |
| 240 |
\pdfcolorstackinit direct {\slnc@initial@black}% |
| 241 |
}% |
| 242 |
}{}% |
| 243 |
% \end{macrocode} |
| 244 |
% If there isn't a font element for the (new) note column, we define a new one |
| 245 |
% and add it to the auto-remove code: |
| 246 |
% \begin{macrocode} |
| 247 |
\@ifundefined{scr@fnt@notecolumn.#2}{% |
| 248 |
\@ifundefined{@notecolumn.#2font}{}{% |
| 249 |
\PackageInfo{scrlayer-notecolumn}{using already defined |
| 250 |
macro\MessageBreak |
| 251 |
`\expandafter\string\csname @notecolumn.#2font\endcsname' for font |
| 252 |
element\MessageBreak |
| 253 |
`notecolumn.#2'% |
| 254 |
}% |
| 255 |
}% |
| 256 |
\newkomafont{notecolumn.#2}{}% |
| 257 |
}{% |
| 258 |
\PackageInfo{scrlayer-notecolumn}{using already defined font |
| 259 |
element\MessageBreak |
| 260 |
`notecolumn.#2'% |
| 261 |
}% |
| 262 |
}% |
| 263 |
% \end{macrocode} |
| 264 |
% After the initialisation we process the options, that may change the initial |
| 265 |
% values. |
| 266 |
% \begin{macrocode} |
| 267 |
\newcommand*{\slnc@name}{}% |
| 268 |
\edef\slnc@name{#2}% |
| 269 |
\FamilyExecuteOptions[.definenotecolumn]{KOMAarg}{marginpar,#1}% |
| 270 |
\let\slnc@name\relax |
| 271 |
% \end{macrocode} |
| 272 |
% The values are set up, so they may be used to declare a layer. |
| 273 |
% \begin{macrocode} |
| 274 |
\DeclareLayer[% |
| 275 |
foreground,% |
| 276 |
align=tl,% |
| 277 |
voffset=1in+\topmargin+\headheight+\headsep,% |
| 278 |
height=\dimexpr\textheight+\topskip\relax,% |
| 279 |
hoffset=\csname slnc@#2@pos\endcsname,% |
| 280 |
width=\csname slnc@#2@width\endcsname,% |
| 281 |
contents=\slnc@processnotes{#2}% |
| 282 |
]{notecolumn.#2} |
| 283 |
% \end{macrocode} |
| 284 |
% We need to add the layer to every page style. The easiest way to do this is |
| 285 |
% to add it to the pseudo layer page style \pstyle{@everystyle@}. |
| 286 |
% \changes{v0.1.1681}{2014/02/05}{add the layer only once} |
| 287 |
% \begin{macrocode} |
| 288 |
\IfLayerAtPageStyle{@everystyle@}{notecolumn.#2}{}{% |
| 289 |
\AddLayersToPageStyle{@everystyle@}{notecolumn.#2}% |
| 290 |
}% |
| 291 |
% \end{macrocode} |
| 292 |
% Last but not least, we add the new note column to the note column procession |
| 293 |
% list. |
| 294 |
% \begin{macrocode} |
| 295 |
\@cons\slnc@processnotecolumns{{#2}}% |
| 296 |
} |
| 297 |
% \end{macrocode} |
| 298 |
% \begin{macro}{\slnc@initial@black} |
| 299 |
% \changes{v0.2.3085}{2019/02/14}{added} |
| 300 |
% The initial black is the color used to initialize the color stacks. As long |
| 301 |
% as only pdf\TeX{} and lua\TeX{} provide color stacks, we can initialize it |
| 302 |
% with \texttt{0 g 0 G}. However it may be better to use the initial |
| 303 |
% \cs{current@color} of the used color package. Using \cs{default@color} would |
| 304 |
% be even better, but this is not available until \cs{begin\{document\}}. |
| 305 |
% \begin{macrocode} |
| 306 |
\newcommand*{\slnc@initial@black}{0 g 0 G}% |
| 307 |
\AfterPackage*{color}{% |
| 308 |
\let\slnc@initial@black\current@color |
| 309 |
\AtBeginDocument{\let\slnc@initial@black\default@color}% |
| 310 |
}% |
| 311 |
\AfterPackage*{xcolor}{% |
| 312 |
\let\slnc@initial@black\current@color |
| 313 |
\AtBeginDocument{\let\slnc@initial@black\default@color}% |
| 314 |
}% |
| 315 |
% \end{macrocode} |
| 316 |
% \end{macro}^^A \slnc@initial@black |
| 317 |
% \begin{macro}{\slnc@processnotecolumns} |
| 318 |
% This is a list of all declared note columns in \LaTeX{} syntax (using |
| 319 |
% \cs{@cons} and \cs{@elt} etc.). |
| 320 |
% \begin{macrocode} |
| 321 |
\newcommand*{\slnc@processnotecolumns}{}% |
| 322 |
% \end{macrocode} |
| 323 |
% \end{macro}^^A \slnc@processnotecolumns |
| 324 |
% \begin{macrocode} |
| 325 |
%</body> |
| 326 |
% \end{macrocode} |
| 327 |
% One note column will be declared by default: |
| 328 |
% \begin{macrocode} |
| 329 |
%<*final> |
| 330 |
\DeclareNoteColumn{marginpar} |
| 331 |
%</final> |
| 332 |
%<*body> |
| 333 |
% \end{macrocode} |
| 334 |
% \begin{macro}{\slnc@testforpagestylewarning} |
| 335 |
% Not all page styles are layer page styles, but only layer page styles can be |
| 336 |
% extended by the note column layers. So we warn, if another page style has |
| 337 |
% been selected. |
| 338 |
% \begin{macrocode} |
| 339 |
\newcommand*{\slnc@testforpagestylewarning}{% |
| 340 |
\IfLayerPageStyleExists{\currentpagestyle}{}{% |
| 341 |
\PackageWarning{scrlayer-notecolumn}{% |
| 342 |
output of note columns delayed,\MessageBreak |
| 343 |
because\expandafter\IfArgIsEmpty\expandafter{\currentpagestyle}{}{% |
| 344 |
with |
| 345 |
\IfArgIsEmpty{\currentpagestyle}`\currentpagestyle'\MessageBreak}% |
| 346 |
a page style has been selected, that\MessageBreak |
| 347 |
isn't a layer page style,% |
| 348 |
}% |
| 349 |
}% |
| 350 |
}% |
| 351 |
\AfterSelectAnyPageStyle{\slnc@testforpagestylewarning} |
| 352 |
% \end{macrocode} |
| 353 |
% \end{macro}^^A \slnc@testforpagestylewarning |
| 354 |
% \begin{option}{position,width,font,marginpar,normalmarginpar,reversemarginpar} |
| 355 |
% Last but not least we have to define the options for the \meta{option |
| 356 |
% list}. |
| 357 |
% \begin{macrocode} |
| 358 |
\DefineFamilyMember[.definenotecolumn]{KOMAarg} |
| 359 |
\DefineFamilyKey[.definenotecolumn]{KOMAarg}{position}{% |
| 360 |
\@namedef{slnc@\slnc@name @pos}{\dimexpr #1\relax}% |
| 361 |
\FamilyKeyStateProcessed |
| 362 |
} |
| 363 |
\DefineFamilyKey[.definenotecolumn]{KOMAarg}{width}{% |
| 364 |
\@namedef{slnc@\slnc@name @width}{\dimexpr #1\relax}% |
| 365 |
\FamilyKeyStateProcessed |
| 366 |
} |
| 367 |
\DefineFamilyKey[.definenotecolumn]{KOMAarg}{font}{% |
| 368 |
\setkomafont{notecolumn.\slnc@name}{#1}% |
| 369 |
\FamilyKeyStateProcessed |
| 370 |
} |
| 371 |
\DefineFamilyKey[.definenotecolumn]{KOMAarg}{marginpar}[\relax]{% |
| 372 |
\FamilyKeyStateProcessed |
| 373 |
\scrlayer@testunexpectedarg{marginpar}{#1}% |
| 374 |
\edef\reserved@a{\noexpand\slnc@defpos{\slnc@name}}\reserved@a |
| 375 |
\@namedef{slnc@\slnc@name @width}{\marginparwidth}% |
| 376 |
} |
| 377 |
% \end{macrocode} |
| 378 |
% \begin{macro}{\slnc@defpos} |
| 379 |
% Little helper for option \opt{marginpar}. The argument is the expanded |
| 380 |
% name of the note column. |
| 381 |
% \begin{macrocode} |
| 382 |
\newcommand*\slnc@defpos[1]{% |
| 383 |
\@namedef{slnc@#1@pos}{% |
| 384 |
\ifodd\value{page} |
| 385 |
\if@reversemargin |
| 386 |
% \end{macrocode} |
| 387 |
% The reverse marginal note column on odd pages is at the left margin. |
| 388 |
% \begin{macrocode} |
| 389 |
\dimexpr \oddsidemargin+1in |
| 390 |
-\marginparsep-\csname slnc@#1@width\endcsname\relax |
| 391 |
\else |
| 392 |
% \end{macrocode} |
| 393 |
% The normal marginal note column on odd pages is the right margin. |
| 394 |
% \begin{macrocode} |
| 395 |
\dimexpr \oddsidemargin+1in |
| 396 |
+\textwidth+\marginparsep\relax |
| 397 |
\fi |
| 398 |
\else |
| 399 |
\if@twoside |
| 400 |
\if@reversemargin |
| 401 |
% \end{macrocode} |
| 402 |
% The reverse marginal note column on even pages is the right margin. |
| 403 |
% \begin{macrocode} |
| 404 |
\dimexpr \evensidemargin+1in |
| 405 |
+\textwidth+\marginparsep\relax |
| 406 |
\else |
| 407 |
% \end{macrocode} |
| 408 |
% The normal marginal note column on even pages is at the left margin. |
| 409 |
% \begin{macrocode} |
| 410 |
\dimexpr \evensidemargin+1in |
| 411 |
-\marginparsep-\csname slnc@#1@width\endcsname\relax |
| 412 |
\fi |
| 413 |
\else |
| 414 |
% \end{macrocode} |
| 415 |
% \begin{macrocode} |
| 416 |
% If not in two-side mode, do the same already done for odd pages. |
| 417 |
\if@reversemargin |
| 418 |
\dimexpr \oddsidemargin+1in |
| 419 |
-\marginparsep-\csname slnc@#1@width\endcsname\relax |
| 420 |
\else |
| 421 |
\dimexpr \oddsidemargin+1in |
| 422 |
+\textwidth+\marginparsep\relax |
| 423 |
\fi |
| 424 |
\fi |
| 425 |
\fi |
| 426 |
}% |
| 427 |
}% |
| 428 |
% \end{macrocode} |
| 429 |
% \end{macro}^^A \slnc@defpos |
| 430 |
% \begin{macrocode} |
| 431 |
\DefineFamilyKey[.definenotecolumn]{KOMAarg}{normalmarginpar}[\relax]{% |
| 432 |
\FamilyKeyStateProcessed |
| 433 |
\scrlayer@testunexpectedarg{normalmarginpar}{#1}% |
| 434 |
\edef\reserved@a{\noexpand\slnc@defnormalpos{\slnc@name}}\reserved@a |
| 435 |
\@namedef{slnc@\slnc@name @width}{\marginparwidth}% |
| 436 |
} |
| 437 |
% \end{macrocode} |
| 438 |
% \begin{macro}{\slnc@defnormalpos} |
| 439 |
% Little helper for option \opt{normalmarginpar}. The argument is the |
| 440 |
% expanded name of the note column. |
| 441 |
% \begin{macrocode} |
| 442 |
\newcommand*\slnc@defnormalpos[1]{% |
| 443 |
\@namedef{slnc@#1@pos}{% |
| 444 |
\ifodd\value{page} |
| 445 |
% \end{macrocode} |
| 446 |
% The normal marginal note column on odd pages is the right margin. |
| 447 |
% \begin{macrocode} |
| 448 |
\dimexpr \oddsidemargin+1in |
| 449 |
+\textwidth+\marginparsep\relax |
| 450 |
\else |
| 451 |
\if@twoside |
| 452 |
% \end{macrocode} |
| 453 |
% The normal marginal note column on even pages is at the left margin. |
| 454 |
% \begin{macrocode} |
| 455 |
\dimexpr \evensidemargin+1in |
| 456 |
-\marginparsep-\csname slnc@#1@width\endcsname\relax |
| 457 |
\else |
| 458 |
% \end{macrocode} |
| 459 |
% \begin{macrocode} |
| 460 |
% If not in two-side mode, do the same already done for odd pages. |
| 461 |
\dimexpr \oddsidemargin+1in |
| 462 |
+\textwidth+\marginparsep\relax |
| 463 |
\fi |
| 464 |
\fi |
| 465 |
}% |
| 466 |
}% |
| 467 |
% \end{macrocode} |
| 468 |
% \end{macro}^^A \slnc@defnormalpos |
| 469 |
% \begin{macrocode} |
| 470 |
\DefineFamilyKey[.definenotecolumn]{KOMAarg}{reversemarginpar}[\relax]{% |
| 471 |
\FamilyKeyStateProcessed |
| 472 |
\scrlayer@testunexpectedarg{reversemarginpar}{#1}% |
| 473 |
\edef\reserved@a{\noexpand\slnc@defreversepos{\slnc@name}}\reserved@a |
| 474 |
\@namedef{slnc@\slnc@name @width}{\marginparwidth}% |
| 475 |
} |
| 476 |
% \end{macrocode} |
| 477 |
% \begin{macro}{\slnc@defreversepos} |
| 478 |
% Little helper for option \opt{reversemarginpar}. The argument is the |
| 479 |
% expanded name of the note column. |
| 480 |
% \begin{macrocode} |
| 481 |
\newcommand*\slnc@defreversepos[1]{% |
| 482 |
\@namedef{slnc@#1@pos}{% |
| 483 |
\ifodd\value{page} |
| 484 |
% \end{macrocode} |
| 485 |
% The reverse marginal note column on odd pages is at the left margin. |
| 486 |
% \begin{macrocode} |
| 487 |
\dimexpr \oddsidemargin+1in |
| 488 |
-\marginparsep-\csname slnc@#1@width\endcsname\relax |
| 489 |
\else |
| 490 |
\if@twoside |
| 491 |
% \end{macrocode} |
| 492 |
% The reverse marginal note column on even pages is the right margin. |
| 493 |
% \begin{macrocode} |
| 494 |
\dimexpr \evensidemargin+1in |
| 495 |
+\textwidth+\marginparsep\relax |
| 496 |
\else |
| 497 |
% \end{macrocode} |
| 498 |
% \begin{macrocode} |
| 499 |
% If not in two-side mode, do the same already done for odd pages. |
| 500 |
\dimexpr \oddsidemargin+1in |
| 501 |
-\marginparsep-\csname slnc@#1@width\endcsname\relax |
| 502 |
\fi |
| 503 |
\fi |
| 504 |
}% |
| 505 |
}% |
| 506 |
% \end{macrocode} |
| 507 |
% \end{macro}^^A \slnc@defreversepos |
| 508 |
% \begin{macrocode} |
| 509 |
%</body> |
| 510 |
% \end{macrocode} |
| 511 |
% \end{option}^^A position … reversemarginpar |
| 512 |
% \end{command}^^A \DeclareNoteColumn |
| 513 |
% |
| 514 |
% \begin{command}{\DeclareNewNoteColumn,\ProvideNoteColumn,\RedeclareNoteColumn} |
| 515 |
% Like \cs{DeclareNoteColumn} but with restrictions, if the note column has |
| 516 |
% (not) been declared already. |
| 517 |
% \begin{macrocode} |
| 518 |
%<*body> |
| 519 |
\newcommand*{\DeclareNewNoteColumn}[2][]{% |
| 520 |
\scr@ifundefinedorrelax{slnc@#2@box}{}{% |
| 521 |
\PackageError{scrlayer-notecolumn}{note column `#2' already defined}{% |
| 522 |
You may declare only note columns, that haven't been declared |
| 523 |
previously using\MessageBreak |
| 524 |
\string\DeclareNewNoteColumn. See also the alternatives |
| 525 |
\string\RedeclareNoteColumn,\MessageBreak |
| 526 |
\string\ProvideNoteColumn, and \string\DeclareNoteColumn.\MessageBreak |
| 527 |
Nevertheless, if you'll continue, declaration will be done.% |
| 528 |
}% |
| 529 |
}% |
| 530 |
\DeclareNoteColumn[{#1}]{#2}% |
| 531 |
}% |
| 532 |
\newcommand*{\ProvideNoteColumn}[2][]{% |
| 533 |
\scr@ifundefinedorrelax{slnc@#2@box}{}{% |
| 534 |
\PackageInfo{scrlayer-notecolumn}{\string\ProvideNoteColumn{#2} |
| 535 |
ignored,\MessageBreak |
| 536 |
because of already defined\MessageBreak |
| 537 |
not column}% |
| 538 |
}{% |
| 539 |
\DeclareNoteColumn[{#1}]{#2}% |
| 540 |
}% |
| 541 |
}% |
| 542 |
\newcommand*{\RedeclareNoteColumn}[2][]{% |
| 543 |
\scr@ifundefinedorrelax{slnc@#2@box}{% |
| 544 |
\PackageError{scrlayer-notecolumn}{note column `#2' undefined}{% |
| 545 |
You may declare only note columns, that have been declared |
| 546 |
previously using\MessageBreak |
| 547 |
\string\RedeclareNoteColumn. See also the alternatives |
| 548 |
\string\DeclareNewNoteColumn,\MessageBreak |
| 549 |
\string\ProvideNoteColumn, and \string\DeclareNoteColumn.\MessageBreak |
| 550 |
Nevertheless, if you'll continue, declaration will be done.% |
| 551 |
}% |
| 552 |
}{}% |
| 553 |
\DeclareNoteColumn[{#1}]{#2}% |
| 554 |
}% |
| 555 |
%</body> |
| 556 |
% \end{macrocode} |
| 557 |
% \end{command} |
| 558 |
% |
| 559 |
% |
| 560 |
% \subsection{Setting a note column} |
| 561 |
% |
| 562 |
% We already have commands to declare note columns. But we also need a command |
| 563 |
% to put contents into the note columns and to output the note columns. |
| 564 |
% |
| 565 |
% \begin{macro}{\tf@slnc} |
| 566 |
% \changes{v0.1.2395}{2016/03/25}{write to \file{aux}-file with |
| 567 |
% \cs{if@filesw}} |
| 568 |
% \begin{macro}{\slnc@initwrite,\slnc@openwrite} |
| 569 |
% \changes{v0.1.2928}{2018/02/02}{use \cs{closein} instead of \cs{closeout} |
| 570 |
% to close \cs{slnc@file}} |
| 571 |
% First of all we need a file to write the notes to. We use the |
| 572 |
% \file{aux}-file to write into the file, because we need to read the file |
| 573 |
% while the document will be typeset and the same time we need to write into |
| 574 |
% the file. Note, that the file will be still reserved on auto-removing the |
| 575 |
% interface! |
| 576 |
% \begin{macrocode} |
| 577 |
%<*body> |
| 578 |
\newwrite\tf@slnc |
| 579 |
\AtBeginDocument{% |
| 580 |
\if@filesw |
| 581 |
\immediate\write\@auxout{% |
| 582 |
\noexpand\csname slnc@initwrite\noexpand\endcsname |
| 583 |
}% |
| 584 |
\fi |
| 585 |
}% |
| 586 |
\AtEndDocument{\let\slnc@initwrite\slnc@openwrite}% |
| 587 |
\newcommand*{\slnc@initwrite}{}% |
| 588 |
\newcommand*{\slnc@openwrite}{% |
| 589 |
\immediate\closein\slnc@file |
| 590 |
%<*trace> |
| 591 |
\PackageInfo{scrlayer-notecolumn}{% |
| 592 |
Opening `\jobname.slnc'\MessageBreak |
| 593 |
for writing}% |
| 594 |
%</trace> |
| 595 |
\immediate\openout\tf@slnc\jobname.slnc |
| 596 |
} |
| 597 |
% \end{macrocode} |
| 598 |
% After reading the main \file{aux}-file at |\end{document}|, we again |
| 599 |
% calculate the md5 checksum of the \file{slnc}-file. If it has been changed |
| 600 |
% we set |\if@tempswa| to |\iftrue| to provocate a rerun message. |
| 601 |
% \changes{v0.1.2872}{2018/01/17}{usage of Lua function \texttt{slncmdfivesum}} |
| 602 |
% \changes{v0.1.2972}{2018/04/01}{usage of not yet documented Xe\TeX{} |
| 603 |
% primitive \cs{mdfivesum}} |
| 604 |
% \begin{macrocode} |
| 605 |
\AfterReadingMainAux{% |
| 606 |
\immediate\closeout\tf@slnc |
| 607 |
\begingroup |
| 608 |
\scr@ifundefinedorrelax{pdfmdfivesum}{% |
| 609 |
\scr@ifundefinedorrelax{mdfivesum}{% |
| 610 |
\ifdefined\directlua |
| 611 |
\edef\reserved@a{\directlua{slnc.mdfivesum(slnc.slncfile)}}% |
| 612 |
\else |
| 613 |
\let\reserved@a\relax |
| 614 |
\fi |
| 615 |
}{% |
| 616 |
\edef\reserved@a{\mdfivesum file {\jobname.slnc}}% |
| 617 |
}% |
| 618 |
}{% |
| 619 |
\edef\reserved@a{\pdfmdfivesum file {\jobname.slnc}}% |
| 620 |
}% |
| 621 |
\ifx\reserved@a\relax |
| 622 |
\PackageWarningNoLine{scrlayer-notecolumn}{% |
| 623 |
\string\pdfmdfivesum\space unavailable.\MessageBreak |
| 624 |
The package needs \string\pdfmdfivesum,\MessageBreak |
| 625 |
\string\mdfivesum, or LuaTeX to test whether\MessageBreak |
| 626 |
or not one more LaTeX run is needed to place the\MessageBreak |
| 627 |
note columns correctly. If these are unavailable\MessageBreak |
| 628 |
you have to do the decision without the help\MessageBreak |
| 629 |
of the package% |
| 630 |
}% |
| 631 |
\else |
| 632 |
\ifx \slnc@mdfivesum\reserved@a |
| 633 |
%<*trace> |
| 634 |
\PackageInfo{scrlayer-notecolumn}{% |
| 635 |
MD5 of current `\jobname.slnc':\MessageBreak |
| 636 |
\reserved@a}% |
| 637 |
%</trace> |
| 638 |
\else |
| 639 |
%<*trace> |
| 640 |
\PackageWarningNoLine{scrlayer-notecolumn}{% |
| 641 |
MD5 of slnc-file changed.\MessageBreak |
| 642 |
Last: \slnc@mdfivesum\MessageBreak |
| 643 |
New: \space \reserved@a\MessageBreak |
| 644 |
At least one more LaTeX rerun needed to\MessageBreak |
| 645 |
make note columns right% |
| 646 |
}% |
| 647 |
%</trace> |
| 648 |
\aftergroup\@tempswatrue |
| 649 |
\fi |
| 650 |
\fi |
| 651 |
\endgroup |
| 652 |
} |
| 653 |
%</body> |
| 654 |
% \end{macrocode} |
| 655 |
% \changes{v0.3.3600}{2021/05/30}{use of \pkg*{scrwfile}'s never list}% |
| 656 |
% The easiest way to make it compatible with \pkg*{scrwfile} is to put it |
| 657 |
% on the \emph{never} list. |
| 658 |
% \begin{macrocode} |
| 659 |
%<*body> |
| 660 |
\AfterPackage*{scrwfile}{% |
| 661 |
\@ifundefined{scrwfile@never}{\def}{\g@addto@macro}% |
| 662 |
\scrwfile@never{slnc}% |
| 663 |
} |
| 664 |
%</body> |
| 665 |
% \end{macrocode} |
| 666 |
% \end{macro}^^A \slnc@initwrite,\slnc@openwrite |
| 667 |
% \end{macro}^^A \tf@slnc |
| 668 |
% |
| 669 |
% \begin{command}{\makenote} |
| 670 |
% \begin{description} |
| 671 |
% \item[\oarg{string}:] the name of the note column the note should be added |
| 672 |
% to (must be fully expandable and expand to a string only). The default |
| 673 |
% value is |marginpar|. |
| 674 |
% \item[\marg{code}:] the code, that should become par of the note |
| 675 |
% column. Note, that this will be written protected to a file. So you have |
| 676 |
% to use \cs{protect} if a macro shouldn't be expanded while writing or may |
| 677 |
% break while writing. |
| 678 |
% \end{description} |
| 679 |
% There is a star variant with the same parameters, that writes the |
| 680 |
% \meta{code} un-expanded. To do so, we need some internal commands. |
| 681 |
% \begin{macro}{\slnc@unexpanded,\slnc@makenote} |
| 682 |
% \changes{v0.1.2583}{2017/02/08}{added} |
| 683 |
% \begin{macrocode} |
| 684 |
%<*body> |
| 685 |
\newcommand*{\slnc@unexpanded}{} |
| 686 |
\let\slnc@unexpanded\detokenize |
| 687 |
\newcommand*{\makenote}{% |
| 688 |
\kernel@ifstar{\let\slnc@unexpanded\detokenize\slnc@makenote}% |
| 689 |
{\let\slnc@unexpanded\@firstofone\slnc@makenote}% |
| 690 |
}% |
| 691 |
\newcommand{\slnc@makenote}[2][marginpar]{% |
| 692 |
\@bsphack |
| 693 |
\scr@savepos |
| 694 |
\addtocontents{slnc}{% |
| 695 |
\string\slnc@note{#1}% |
| 696 |
{\noexpand\number\value{slncpage}}% |
| 697 |
{\noexpand\number\scr@lastypos}% |
| 698 |
{\slnc@unexpanded{#2}}% |
| 699 |
}% |
| 700 |
\IfLayerPageStyleExists{\currentpagestyle}{}{% |
| 701 |
\PackageWarning{scrlayer-scrpage}{% |
| 702 |
Detected \string\makenote\space at page with non-layer\MessageBreak |
| 703 |
page style% |
| 704 |
\expandafter\IfArgIsEmpty\expandafter{\currentpagestyle}{}{ |
| 705 |
\currentpagestyle}.\MessageBreak |
| 706 |
Delayed or too early output of the note is\MessageBreak |
| 707 |
expected and not a bug in such cases. Even\MessageBreak |
| 708 |
flipping notes without terminating states\MessageBreak |
| 709 |
would be possible and not a bug.\MessageBreak |
| 710 |
Redefinition of all used page styles to\MessageBreak |
| 711 |
layer page styles would be recommended at\MessageBreak |
| 712 |
least the page style used for the\MessageBreak |
| 713 |
note% |
| 714 |
} |
| 715 |
}% |
| 716 |
\@esphack |
| 717 |
}% |
| 718 |
% \end{macrocode} |
| 719 |
% \begin{counter}{slncpage} |
| 720 |
% This counter should be increased once per page with note column. This may |
| 721 |
% be done simply at a once per page executed hook of |
| 722 |
% \pstyle{@everystyle@}. You should note, that auto-remove wouldn't |
| 723 |
% remove the counter. |
| 724 |
% \begin{macrocode} |
| 725 |
\@ifundefined{c@slncpage}{% |
| 726 |
\newcounter{slncpage}% |
| 727 |
\AddToLayerPageStyleOptions{@everystyle@}{% |
| 728 |
onbackground=\stepcounter{slncpage}% |
| 729 |
}% |
| 730 |
}{} |
| 731 |
%</body> |
| 732 |
% \end{macrocode} |
| 733 |
% \end{counter}^^A slncpage |
| 734 |
% \end{macro}^^A \slnc@makenote,\slnc@unexpanded |
| 735 |
% \end{command}^^A \makenote |
| 736 |
% |
| 737 |
% \begin{macro}{\slnc@processnotes} |
| 738 |
% \begin{description} |
| 739 |
% \item[\marg{string}:] the name of the note column (must be fully expandable |
| 740 |
% an expand to a string only). |
| 741 |
% \end{description} |
| 742 |
% Each note column typesets the notes with this command. It works in following |
| 743 |
% steps: |
| 744 |
% \begin{macrocode} |
| 745 |
%<*body> |
| 746 |
\newcommand*{\slnc@processnotes}[1]{% |
| 747 |
% \end{macrocode} |
| 748 |
% Read as long notes from the notes file until the number at \#2 of |
| 749 |
% \cs{slnc@note} in the file is greater than \cnt{slncpage}. Put all |
| 750 |
% these to the corresponding unprocessed list. |
| 751 |
% \begin{macrocode} |
| 752 |
\begingroup |
| 753 |
\slnc@readnotes{\value{slncpage}}% |
| 754 |
% \end{macrocode} |
| 755 |
% Process the unprocessed list of the current note column |
| 756 |
% \begin{macrocode} |
| 757 |
\expandafter\let\expandafter\reserved@a |
| 758 |
\csname slnc@#1@unprocessed\endcsname |
| 759 |
\expandafter\global |
| 760 |
\expandafter\let\csname slnc@#1@unprocessed\endcsname\@empty |
| 761 |
\def\slnc@notesyncfonttest##1{% |
| 762 |
\ifhmode |
| 763 |
\PackageError{scrlayer-notecolumn}{% |
| 764 |
illegal font setting for `notecolumn.##1'% |
| 765 |
}{% |
| 766 |
Current setting of font for `notecolumn.##1' switches |
| 767 |
from\MessageBreak |
| 768 |
vertical mode to horizontal mode. This is |
| 769 |
illegal!\MessageBreak |
| 770 |
You have to change the font setting to fix |
| 771 |
this.\MessageBreak |
| 772 |
If you'll continue vertical alignment of notes may fail% |
| 773 |
}% |
| 774 |
\par\vskip-\dimexpr \baselineskip+\parskip\relax |
| 775 |
\fi |
| 776 |
}% |
| 777 |
\long\def\slnc@note##1##2##3##4{% |
| 778 |
%<trace> \PackageInfo{scrlayer-notecolumn}{TRACE (slnc): ##2<=\theslncpage?}% |
| 779 |
\ifnum ##2>\value{slncpage}\relax |
| 780 |
%<trace> \PackageInfo{scrlayer-notecolumn}{TRACE (slnc): no: unprocess note}% |
| 781 |
\expandafter\g@addto@macro\csname slnc@#1@unprocessed\endcsname{% |
| 782 |
\slnc@note{##1}{##2}{##3}{##4}% |
| 783 |
}% |
| 784 |
\else |
| 785 |
\ifnum ##2<\value{slncpage}\relax |
| 786 |
\PackageWarning{scrlayer-notecolumn}{note of type `#1' delayed}% |
| 787 |
\fi |
| 788 |
\boxmaxdepth\maxdepth |
| 789 |
\expandafter\setbox\csname slnc@#1@box\endcsname\vbox{% |
| 790 |
\expandafter\hsize\csname slnc@#1@width\endcsname |
| 791 |
\normalfont\normalsize |
| 792 |
% \end{macrocode} |
| 793 |
% \changes{v0.2.3085}{2019/02/14}{using color stack if available} |
| 794 |
% If a color stack is available we switch to it before changing the font. So a |
| 795 |
% color definition inside the font would overwrite every color change inside |
| 796 |
% the column! But if we don't have a color stack, color switching is not |
| 797 |
% permitted! |
| 798 |
% \begin{macrocode} |
| 799 |
\slnc@switchcolorstack{#1}% |
| 800 |
{% |
| 801 |
\usekomafont{notecolumn.#1}{% |
| 802 |
\slnc@notesyncfonttest{#1}% |
| 803 |
\expandafter\ifvoid\csname slnc@#1@box\endcsname |
| 804 |
\expandafter\setbox\csname slnc@#1@box\endcsname\vbox{% |
| 805 |
\kern\dimexpr\topskip-\baselineskip\relax |
| 806 |
}% |
| 807 |
\fi |
| 808 |
% \end{macrocode} |
| 809 |
% \changes{v0.1}{2015/10/07}{ready for renaming \cs{pdfpageheight} in |
| 810 |
% luaTeX} |
| 811 |
% From lua\TeX~0.80.1 \cs{pdfpageheight} will be renamed into |
| 812 |
% \cs{pageheight}. So we have to do an extra test for the new primitive. |
| 813 |
% \begin{macrocode} |
| 814 |
\scr@ifundefinedorrelax{pdfpageheight}{% |
| 815 |
\scr@ifundefinedorrelax{pageheight}{% |
| 816 |
\@tempdima=\paperheight |
| 817 |
}{% |
| 818 |
\@tempdima=\pageheight |
| 819 |
}% |
| 820 |
}{% |
| 821 |
\@tempdima=\pdfpageheight |
| 822 |
}% |
| 823 |
\@tempdima=\dimexpr \@tempdima-##3sp |
| 824 |
-1in-\topmargin |
| 825 |
-\headheight-\headsep |
| 826 |
-\baselineskip |
| 827 |
\relax |
| 828 |
\@tempdimb=\dimexpr \expandafter\ht\csname slnc@#1@box\endcsname |
| 829 |
+\expandafter\dp\csname slnc@#1@box\endcsname |
| 830 |
\relax |
| 831 |
\ifdim\@tempdima<\@tempdimb |
| 832 |
%<*trace> |
| 833 |
\PackageInfo{scrlayer-notecolumn}{% |
| 834 |
Note moved down from\MessageBreak |
| 835 |
\the\@tempdima\space to \the\@tempdimb\MessageBreak |
| 836 |
at note box `#1' |
| 837 |
}% |
| 838 |
%</trace> |
| 839 |
\else |
| 840 |
\ifdim\@tempdima>\@tempdimb |
| 841 |
%<*trace> |
| 842 |
\PackageInfo{scrlayer-notecolumn}{% |
| 843 |
Adding vertical white space from\MessageBreak |
| 844 |
\the\@tempdimb\space to \the\@tempdima\MessageBreak |
| 845 |
into note box `#1' |
| 846 |
}% |
| 847 |
%</trace> |
| 848 |
\expandafter\setbox\csname slnc@#1@box\endcsname |
| 849 |
\vbox {% |
| 850 |
\expandafter\unvbox\csname slnc@#1@box\endcsname |
| 851 |
\kern\dimexpr\@tempdima-\@tempdimb\relax |
| 852 |
}% |
| 853 |
\fi |
| 854 |
\fi |
| 855 |
\expandafter\ifvoid\expandafter\csname slnc@#1@box\endcsname |
| 856 |
\else |
| 857 |
\@tempdima\dimexpr |
| 858 |
\dp\strutbox |
| 859 |
-\dp\csname slnc@#1@box\endcsname |
| 860 |
\relax |
| 861 |
\expandafter\unvbox\csname slnc@#1@box\endcsname |
| 862 |
\ifdim\@tempdima>\z@ \kern\@tempdima\fi |
| 863 |
\fi |
| 864 |
% \end{macrocode} |
| 865 |
% \changes{v0.1.2582}{2017/02/08}{restore several commands} |
| 866 |
% Some commands have to be restored when processing the note. |
| 867 |
% \begin{macrocode} |
| 868 |
\slnc@restoreinnote |
| 869 |
\strut\ignorespaces ##4\par |
| 870 |
}% |
| 871 |
}% |
| 872 |
}% |
| 873 |
\fi |
| 874 |
}% |
| 875 |
\def\slnc@sync##1##2##3##4{% |
| 876 |
\ifnum ##2>\value{slncpage}\relax |
| 877 |
\expandafter\g@addto@macro\csname slnc@#1@unprocessed\endcsname{% |
| 878 |
\slnc@sync{##1}{##2}{##3}{}% |
| 879 |
}% |
| 880 |
\else |
| 881 |
\if@filesw |
| 882 |
\expandafter\setbox\csname slnc@#1@box\endcsname\vbox{% |
| 883 |
\expandafter\unvbox\csname slnc@#1@box\endcsname |
| 884 |
\scr@savepos |
| 885 |
\protected@write\@auxout{}{% |
| 886 |
\string\newlabel{notecolumn.##1.##3.syncnote.label}{% |
| 887 |
{% |
| 888 |
\noexpand\number\scr@lastypos |
| 889 |
}{\thepage}% |
| 890 |
}% |
| 891 |
}% |
| 892 |
}% |
| 893 |
\fi |
| 894 |
\fi |
| 895 |
}% |
| 896 |
\reserved@a |
| 897 |
\expandafter\ifvoid\csname slnc@#1@box\endcsname |
| 898 |
%<*trace> |
| 899 |
\PackageInfo{scrlayer-notecolumn}{Note box `#1' empty}% |
| 900 |
%</trace> |
| 901 |
\else |
| 902 |
\ifdim \dimexpr \expandafter\ht\csname slnc@#1@box\endcsname |
| 903 |
+\expandafter\dp\csname slnc@#1@box\endcsname |
| 904 |
\relax >\textheight\relax |
| 905 |
%<*trace> |
| 906 |
\PackageInfo{scrlayer-notecolumn}{Split note box `#1'}% |
| 907 |
%</trace> |
| 908 |
\splittopskip\topskip |
| 909 |
\splitmaxdepth\baselineskip |
| 910 |
% \end{macrocode} |
| 911 |
% Bring back the colors: |
| 912 |
% \changes{v0.2.3085}{2019/02/14}{\cs{slnc@switchcolorstack} added} |
| 913 |
% \begin{macrocode} |
| 914 |
\usekomafont{notecolumn.#1}{% |
| 915 |
\expandafter\vsplit\csname slnc@#1@box\endcsname to |
| 916 |
\textheight\relax |
| 917 |
}% |
| 918 |
\expandafter\ifvoid\csname slnc@#1@box\endcsname |
| 919 |
\else |
| 920 |
\expandafter\setbox\csname slnc@#1@box\endcsname\vbox{% |
| 921 |
\slnc@switchcolorstack{#1}% |
| 922 |
\expandafter\unvbox\csname slnc@#1@box\endcsname |
| 923 |
}% |
| 924 |
\fi |
| 925 |
\else |
| 926 |
%<*trace> |
| 927 |
\PackageInfo{scrlayer-notecolumn}{Flush note box `#1'}% |
| 928 |
%</trace> |
| 929 |
% \end{macrocode} |
| 930 |
% Bring back the colors: |
| 931 |
% \changes{v0.2.3085}{2019/02/14}{\cs{slnc@switchcolorstack} added} |
| 932 |
% \begin{macrocode} |
| 933 |
\usekomafont{notecolumn.#1}{% |
| 934 |
\slnc@switchcolorstack{#1}% |
| 935 |
\expandafter\box\csname slnc@#1@box\endcsname% |
| 936 |
}% |
| 937 |
\fi |
| 938 |
\fi |
| 939 |
\expandafter\global |
| 940 |
\expandafter\setbox\csname slnc@#1@box\expandafter\endcsname |
| 941 |
\expandafter\box\csname slnc@#1@box\endcsname |
| 942 |
\endgroup |
| 943 |
} |
| 944 |
% \end{macrocode} |
| 945 |
% \begin{macro}{\slnc@switchcolorstack} |
| 946 |
% \changes{v0.2.3085}{2019/02/14}{added} |
| 947 |
% This either redefines \cs{set@color} or switches to the color stack of the |
| 948 |
% note column given by the argument. |
| 949 |
% \begin{macrocode} |
| 950 |
\newcommand*{\slnc@switchcolorstack}[1]{% |
| 951 |
\scr@ifundefinedorrelax{slnc@#1@colorstack}{% |
| 952 |
\def\set@color{% |
| 953 |
\PackageWarningNoLine{scrlayer-notecolumn}{% |
| 954 |
unsupported change of color!\MessageBreak |
| 955 |
It seems you are using a TeX engine,\MessageBreak |
| 956 |
that does not support switching the\MessageBreak |
| 957 |
color stack like pdfTeX or luaTeX do.\MessageBreak |
| 958 |
Because of this, usage of \string\color,\MessageBreak |
| 959 |
\string\textcolor\space etc. inside a note |
| 960 |
column\MessageBreak |
| 961 |
is not supported% |
| 962 |
}% |
| 963 |
}% |
| 964 |
}{% |
| 965 |
\scr@ifundefinedorrelax{@pdfcolorstack}{% |
| 966 |
}{% |
| 967 |
\expandafter\let\expandafter\@pdfcolorstack |
| 968 |
\csname slnc@#1@colorstack\endcsname |
| 969 |
}% |
| 970 |
\scr@ifundefinedorrelax{pdfcolorstack}{% |
| 971 |
\scr@ifundefinedorrelax{pdfextension}{% |
| 972 |
\PackageError{scrlayer-notecolumm}{% |
| 973 |
color stack defined but not usable% |
| 974 |
}{% |
| 975 |
\expandafter\string |
| 976 |
\csname slnc@#1@colorstack\endcsname\space defined |
| 977 |
\MessageBreak |
| 978 |
but neither \string\pdfcolorstack\space nor |
| 979 |
\string\pdfextension.\MessageBreak |
| 980 |
This should never happen!% |
| 981 |
}% |
| 982 |
}{% |
| 983 |
\pdfextension colorstack |
| 984 |
\csname slnc@#1@colorstack\endcsname current\relax |
| 985 |
}% |
| 986 |
}{% |
| 987 |
\pdfcolorstack |
| 988 |
\csname slnc@#1@colorstack\endcsname current\relax |
| 989 |
}% |
| 990 |
}% |
| 991 |
}% |
| 992 |
% \end{macrocode} |
| 993 |
% \end{macro}^^A \slnc@switchcolorstack |
| 994 |
% \begin{command}{\restoreinnote} |
| 995 |
% \changes{v0.1.2582}{2017/02/08}{added} |
| 996 |
% \begin{macro}{\slnc@restoreinnote} |
| 997 |
% \changes{v0.1.2582}{2017/02/08}{added} |
| 998 |
% Some commands have to be restored while processing the notes. By default |
| 999 |
% these are \cs{label}, \cs{index}, \cs{glossary}. More can be added using |
| 1000 |
% \cs{restoreinnote}. The storage is \cs{slnc@restoreinnote}. |
| 1001 |
% \begin{macrocode} |
| 1002 |
\newcommand*{\slnc@restoreinnote}{} |
| 1003 |
\let\slnc@restoreinnote\@empty |
| 1004 |
\newcommand*\restoreinnote[1]{% |
| 1005 |
\AtBeginDocument{% |
| 1006 |
\expandafter\newcommand\expandafter*\csname slnc\string#1\endcsname{}% |
| 1007 |
\expandafter\let\csname slnc\string#1\endcsname#1% |
| 1008 |
\g@addto@macro\slnc@restoreinnote{% |
| 1009 |
\expandafter\let\expandafter#1\csname slnc\string#1\endcsname |
| 1010 |
}% |
| 1011 |
}% |
| 1012 |
} |
| 1013 |
\@onlypreamble\restoreinnote |
| 1014 |
\restoreinnote\label |
| 1015 |
\restoreinnote\index |
| 1016 |
\restoreinnote\glossary |
| 1017 |
% \end{macrocode} |
| 1018 |
% \end{macro}^^A \slnc@restoreinnote |
| 1019 |
% \end{command}^^A \restoreinnote |
| 1020 |
% \begin{macro}{\slnc@readnotes} |
| 1021 |
% Read as long notes from the notes file until the number at \#2 of |
| 1022 |
% \cs{slnc@note} or \cs{slnc@sync} in the file is greater than |
| 1023 |
% \cnt{slncpage}. Put all these to the corresponding unprocessed list. |
| 1024 |
% \begin{macro}{\slnc@catcodes} |
| 1025 |
% \changes{v0.3}{2019/03/02}{added} |
| 1026 |
% We need a helper macro \cs{slnc@catcodes} to restore (some of) the catcodes |
| 1027 |
% before reading from file. |
| 1028 |
% \begin{macrocode} |
| 1029 |
\newcommand*{\slnc@catcodes}{}% |
| 1030 |
\AtBeginDocument{% |
| 1031 |
\begingroup |
| 1032 |
\def\do#1{% |
| 1033 |
\protected@xdef\slnc@catcodes{\slnc@catcodes |
| 1034 |
\catcode`\protect#1=\the\catcode`#1\relax |
| 1035 |
}% |
| 1036 |
}% |
| 1037 |
\dospecials |
| 1038 |
\let\protect\noexpand |
| 1039 |
\xdef\slnc@catcodes{\slnc@catcodes\catcode`\protect\@=11\relax}% |
| 1040 |
\endgroup |
| 1041 |
} |
| 1042 |
% \end{macrocode} |
| 1043 |
% \end{macro}^^A \slnc@catcodes |
| 1044 |
% \begin{macrocode} |
| 1045 |
\newcommand*\slnc@readnotes[1]{% |
| 1046 |
\ifeof\slnc@file\else |
| 1047 |
\ifnum \number #1<\slnc@unprocessed\relax |
| 1048 |
\@tempswafalse |
| 1049 |
\else |
| 1050 |
\@tempswatrue |
| 1051 |
\fi |
| 1052 |
\@whilesw\if@tempswa\fi{% |
| 1053 |
\begingroup |
| 1054 |
\slnc@catcodes |
| 1055 |
\endlinechar\m@ne |
| 1056 |
\read\slnc@file to\reserved@a |
| 1057 |
\edef\reserved@a{% |
| 1058 |
\endgroup |
| 1059 |
\noexpand\def\noexpand\reserved@a{% |
| 1060 |
\unexpanded\expandafter{\reserved@a}% |
| 1061 |
}% |
| 1062 |
}% |
| 1063 |
\reserved@a |
| 1064 |
\expandafter\slnc@iofv\expandafter\reserved@b\reserved@a |
| 1065 |
\@empty\@empty\@empty\@empty\@empty |
| 1066 |
\@tempswafalse |
| 1067 |
\@for\reserved@c :={\slnc@note },{\slnc@sync }\do{% |
| 1068 |
\ifx\reserved@b\reserved@c \@tempswatrue\fi |
| 1069 |
}% |
| 1070 |
\if@tempswa |
| 1071 |
\@tempswafalse |
| 1072 |
\expandafter\slnc@iiiofv\expandafter\reserved@b\reserved@a |
| 1073 |
\@empty\@empty\@empty\@empty\@empty |
| 1074 |
\ifx\reserved@b\@empty |
| 1075 |
\PackageError{scrlayer-notecolumn}{internal syntax error}{% |
| 1076 |
Unexpected syntax of file `\jobname.slnc'.\MessageBreak |
| 1077 |
Second argument should be a number.\MessageBreak |
| 1078 |
I don't know what to do with\MessageBreak |
| 1079 |
\expandafter\detokenize\expandafter{\reserved@a}% |
| 1080 |
}% |
| 1081 |
\@tempswatrue |
| 1082 |
\else |
| 1083 |
\global\let\slnc@unprocessed\reserved@b |
| 1084 |
\expandafter\slnc@iiofv\expandafter\reserved@b\reserved@a |
| 1085 |
\@empty\@empty\@empty\@empty\@empty |
| 1086 |
\@ifundefined{slnc@\reserved@b @unprocessed}{% |
| 1087 |
\PackageWarning{scrlayer-notecolumn}{% |
| 1088 |
column `\reserved@b' undefined.\MessageBreak |
| 1089 |
You should declare the column before the usage.\MessageBreak |
| 1090 |
Notes will be lost% |
| 1091 |
}% |
| 1092 |
}{% |
| 1093 |
\expandafter\g@addto@macro |
| 1094 |
\csname slnc@\reserved@b @unprocessed\expandafter\endcsname |
| 1095 |
\expandafter{% |
| 1096 |
\reserved@a |
| 1097 |
}% |
| 1098 |
}% |
| 1099 |
\ifnum \number #1<\slnc@unprocessed\relax |
| 1100 |
\@tempswafalse |
| 1101 |
\else |
| 1102 |
\@tempswatrue |
| 1103 |
\fi |
| 1104 |
\fi |
| 1105 |
\else |
| 1106 |
%<*trace> |
| 1107 |
\PackageInfo{scrlayer-notecolumn}{% |
| 1108 |
Ignoring `\expandafter\detokenize\expandafter{\reserved@a}'}% |
| 1109 |
%</trace> |
| 1110 |
\@tempswatrue |
| 1111 |
\fi |
| 1112 |
\ifeof\slnc@file\@tempswafalse\fi |
| 1113 |
}% |
| 1114 |
\fi |
| 1115 |
}% |
| 1116 |
% \end{macrocode} |
| 1117 |
% \end{macro}^^A \slnc@readnotes |
| 1118 |
% \begin{macro}{\slnc@iofv,\slnc@iiofv,\slnc@iiiofv} |
| 1119 |
% \begin{macrocode} |
| 1120 |
\newcommand\slnc@iofv[6]{\def#1{#2}}% |
| 1121 |
\newcommand\slnc@iiofv[6]{\def#1{#3}}% |
| 1122 |
\newcommand\slnc@iiiofv[6]{\def#1{#4}}% |
| 1123 |
% \end{macrocode} |
| 1124 |
% \end{macro}^^A \slnc@iofv … \slnc@iiiofv |
| 1125 |
% \begin{macro}{\slnc@unprocessed} |
| 1126 |
% The \#2 of the last read note column from notes file. |
| 1127 |
% \begin{macrocode} |
| 1128 |
\newcommand*{\slnc@unprocessed}{0}% |
| 1129 |
%</body> |
| 1130 |
% \end{macrocode} |
| 1131 |
% \begin{macro}{\slnc@file} |
| 1132 |
% The input file with the unprocessed notes. |
| 1133 |
% \changes{v0.1.2928}{2018/02/02}{use \cs{closein} instead of \cs{closeout} |
| 1134 |
% to close \cs{slnc@file}} |
| 1135 |
% \begin{macro}{\slnc@mdfivesum} |
| 1136 |
% \changes{v0.1.2872}{2018/01/17}{definition and usage of Lua function |
| 1137 |
% \texttt{slncmdfivesum}} |
| 1138 |
% \changes{v0.1.2972}{2018/04/01}{usage of not yet documented \XeTeX{} |
| 1139 |
% primitive \cs{mdfivesum}} |
| 1140 |
% \changes{v0.3.3591}{2021/03/25}{Lua function name changed to |
| 1141 |
% \texttt{slnc.mdfivesum}} |
| 1142 |
% \changes{v0.3.3591}{2021/03/25}{new Lua variable \texttt{slnc.slncfile}} |
| 1143 |
% The MD5 sum of the file before opening it for reading. |
| 1144 |
% \begin{macrocode} |
| 1145 |
%<*body> |
| 1146 |
\newcommand*{\slnc@mdfivesum}{} |
| 1147 |
\let\slnc@mdfivesum\@empty |
| 1148 |
\scr@ifundefinedorrelax{pdfmdfivesum}{% |
| 1149 |
\scr@ifundefinedorrelax{mdfivesum}{% |
| 1150 |
\ifdefined\directlua |
| 1151 |
\directlua{% |
| 1152 |
slnc = slnc or {} |
| 1153 |
function slnc.mdfivesum(filename) |
| 1154 |
local fh = io.open(filename,"rb") |
| 1155 |
if fh then |
| 1156 |
local sum=md5.sumhexa(fh:read("*a")) |
| 1157 |
tex.sprint(sum) |
| 1158 |
fh:close() |
| 1159 |
end |
| 1160 |
end |
| 1161 |
if (string.sub(tex.jobname,1,1) == '"') |
| 1162 |
and (string.sub(tex.jobname,string.len(tex.jobname),-1) == '"') |
| 1163 |
then |
| 1164 |
slnc.slncfile = string.sub(tex.jobname,2,-2) |
| 1165 |
else |
| 1166 |
slnc.slncfile = tex.jobname |
| 1167 |
end |
| 1168 |
slnc.slncfile = slnc.slncfile .. '.slnc' |
| 1169 |
}% |
| 1170 |
\xdef\slnc@mdfivesum{\directlua{slnc.mdfivesum(slnc.slncfile)}}% |
| 1171 |
\fi |
| 1172 |
}{% |
| 1173 |
\xdef\slnc@mdfivesum{\mdfivesum file {\jobname.slnc}}% |
| 1174 |
}% |
| 1175 |
}{% |
| 1176 |
\xdef\slnc@mdfivesum{\pdfmdfivesum file {\jobname.slnc}}% |
| 1177 |
}% |
| 1178 |
%<*trace> |
| 1179 |
\scr@ifundefinedorrelax{slnc@mdfivesum}{}{% |
| 1180 |
\PackageInfo{scrlayer-notecolumn}{% |
| 1181 |
MD5 of last `\jobname.slnc':\MessageBreak |
| 1182 |
\slnc@mdfivesum}% |
| 1183 |
}% |
| 1184 |
%</trace> |
| 1185 |
\newread\slnc@file |
| 1186 |
\immediate\openin\slnc@file \jobname.slnc |
| 1187 |
%</body> |
| 1188 |
% \end{macrocode} |
| 1189 |
% \end{macro}^^A \slnc@mdfivesum |
| 1190 |
% \end{macro}^^A \slnc@file |
| 1191 |
% \end{macro}^^A \slnc@unprocessed |
| 1192 |
% \end{macro}^^A \slnc@processnotes |
| 1193 |
% |
| 1194 |
% \begin{option}{autoclearnotecolumns} |
| 1195 |
% \begin{macro}{\ifslnc@autoclearnotecolumns,\slnc@autoclearnotecolumnstrue, |
| 1196 |
% \slnc@autoclearnotecolumnsfalse} |
| 1197 |
% \begin{macrocode} |
| 1198 |
%<*options> |
| 1199 |
\KOMA@ifkey{autoclearnotecolumns}{slnc@autoclearnotecolumns} |
| 1200 |
\slnc@autoclearnotecolumnstrue |
| 1201 |
%</options> |
| 1202 |
%<*final> |
| 1203 |
\let\reserved@a\clearpage |
| 1204 |
\def\clearpage{% |
| 1205 |
\ifslnc@autoclearnotecolumns\clearnotecolumns\relax\fi |
| 1206 |
}% |
| 1207 |
\expandafter\g@addto@macro\expandafter\clearpage\expandafter{\reserved@a} |
| 1208 |
%</final> |
| 1209 |
% \end{macrocode} |
| 1210 |
% \end{macro} |
| 1211 |
% \end{option} |
| 1212 |
% |
| 1213 |
% \begin{command}{\clearnotecolumn} |
| 1214 |
% \begin{description} |
| 1215 |
% \item[\oarg{string}:] the name of the note column (must be fully |
| 1216 |
% expandable and expand to a string only). Default is |marginpar|. |
| 1217 |
% \end{description} |
| 1218 |
% Output as many (empty) pages as needed to output all unprocessed notes of |
| 1219 |
% one note column. Note, that the output of the first page may result in more |
| 1220 |
% unprocessed notes. But the output of the following (empty) pages shouldn't. |
| 1221 |
% \begin{macrocode} |
| 1222 |
%<*body> |
| 1223 |
\newcounter{slnc@clearnote@label}% |
| 1224 |
\newcommand*\clearnotecolumn[1][marginpar]{% |
| 1225 |
\begingroup |
| 1226 |
\slnc@autoclearnotecolumnsfalse |
| 1227 |
% \end{macrocode} |
| 1228 |
% First of all we need to know the note column page of this page. |
| 1229 |
% \begin{macrocode} |
| 1230 |
\stepcounter{slnc@clearnote@label}% |
| 1231 |
\if@filesw |
| 1232 |
\protected@write\@auxout{% |
| 1233 |
\let\theslncpage\relax |
| 1234 |
\let\slnc@voidtest\relax |
| 1235 |
}{% |
| 1236 |
\string\newlabel{notecolumn.\theslnc@clearnote@label}% |
| 1237 |
{{\theslncpage}{\slnc@voidtest{#1}}}% |
| 1238 |
}% |
| 1239 |
\fi |
| 1240 |
\scr@ifundefinedorrelax{r@notecolumn.\theslnc@clearnote@label}{% |
| 1241 |
\PackageInfo{scrlayer-notecolumn}{% |
| 1242 |
Using estimated to low value for clearing\MessageBreak |
| 1243 |
note colum `#1'% |
| 1244 |
} |
| 1245 |
\edef\slnc@cmp@value{\the\value{slncpage}}% |
| 1246 |
\let\reserved@a\z@ |
| 1247 |
}{% |
| 1248 |
\edef\reserved@a{% |
| 1249 |
\@nameuse{r@notecolumn.\theslnc@clearnote@label}\@empty\@empty |
| 1250 |
}% |
| 1251 |
\edef\slnc@cmp@value{\expandafter\slnc@firstof\reserved@a\@nil}% |
| 1252 |
\edef\reserved@a{\expandafter\slnc@secondof\reserved@a\@nil}% |
| 1253 |
}% |
| 1254 |
%<*trace> |
| 1255 |
\PackageInfo{scrlayer-notecolumn}{% |
| 1256 |
TRACE (slnc): clearnote=\@nameuse{theslnc@clearnote@label}, |
| 1257 |
abspage=\the\value{slncpage}, until page=\slnc@cmp@value, |
| 1258 |
process=\reserved@a, pagetotal=\the\pagetotal, topskip=\the\topskip}% |
| 1259 |
%</trace> |
| 1260 |
\ifvmode\ifdim \pagetotal<\topskip |
| 1261 |
% \end{macrocode} |
| 1262 |
% \cs{clearpage} wouldn't result in a new page, so we do not have to output |
| 1263 |
% the notes of this page but only until the previous. |
| 1264 |
% \begin{macrocode} |
| 1265 |
\edef\slnc@cmp@value{\the\numexpr\slnc@cmp@value-1}% |
| 1266 |
%<trace> \PackageInfo{scrlayer-notecolumn}{TRACE (slnc): until page=\slnc@cmp@value}% |
| 1267 |
\fi\fi |
| 1268 |
\ifnum \reserved@a=\z@ |
| 1269 |
% \end{macrocode} |
| 1270 |
% Next we read all notes until the end of the current page, but only |
| 1271 |
% if a \cs{clearpage} wouldn't result in a new page. |
| 1272 |
% \begin{macrocode} |
| 1273 |
\ifvmode |
| 1274 |
\ifdim \pagetotal<\topskip |
| 1275 |
\else |
| 1276 |
\slnc@readnotes{\slnc@cmp@value}% |
| 1277 |
\fi |
| 1278 |
\else |
| 1279 |
\slnc@readnotes{\slnc@cmp@value}% |
| 1280 |
\fi |
| 1281 |
\begingroup |
| 1282 |
\aftergroup\@tempswafalse |
| 1283 |
\long\def\slnc@note##1##2##3##4{% |
| 1284 |
\ifnum ##2>\slnc@cmp@value\relax \else \aftergroup\@tempswatrue\fi |
| 1285 |
}% |
| 1286 |
\let\slnc@sync\slnc@note |
| 1287 |
\csname slnc@#1@unprocessed\endcsname |
| 1288 |
\endgroup |
| 1289 |
\else |
| 1290 |
\PackageInfo{scrlayer-notecolumn}{% |
| 1291 |
box of note column `#1'\MessageBreak |
| 1292 |
not empty after page of \string\clearnotecolumn}% |
| 1293 |
\@tempswatrue |
| 1294 |
\fi |
| 1295 |
\if@tempswa |
| 1296 |
% \end{macrocode} |
| 1297 |
% Yes, we have! |
| 1298 |
% \begin{macrocode} |
| 1299 |
\IfLayerPageStyleExists{\currentpagestyle}{}{% |
| 1300 |
\PackageWarning{scrlayer-notecolumn}{% |
| 1301 |
\string\clearnotecolumn\space while active non-layer\MessageBreak |
| 1302 |
page style.\MessageBreak |
| 1303 |
Activate empty page style until note column\MessageBreak |
| 1304 |
has been cleared% |
| 1305 |
}% |
| 1306 |
\pagestyle{empty}% |
| 1307 |
}% |
| 1308 |
\@tempswatrue |
| 1309 |
\fi |
| 1310 |
\@whilesw\if@tempswa\fi{% |
| 1311 |
%<trace> \PackageInfo{scrlayer-notecolumn}{TRACE (slnc): add \string\clearpage}% |
| 1312 |
% \end{macrocode} |
| 1313 |
% Yes, we have (maybe again)! |
| 1314 |
% \begin{macrocode} |
| 1315 |
\clearpage |
| 1316 |
\expandafter\ifcase \slnc@voidtest{#1}% |
| 1317 |
\begingroup |
| 1318 |
\aftergroup\@tempswafalse |
| 1319 |
\long\def\slnc@note##1##2##3##4{% |
| 1320 |
\ifnum ##2>\slnc@cmp@value\relax \else \aftergroup\@tempswatrue\fi |
| 1321 |
}% |
| 1322 |
\let\slnc@sync\slnc@note |
| 1323 |
\csname slnc@#1@unprocessed\endcsname |
| 1324 |
\endgroup |
| 1325 |
\else |
| 1326 |
\@tempswatrue |
| 1327 |
\fi |
| 1328 |
\if@tempswa |
| 1329 |
% \end{macrocode} |
| 1330 |
% And we still have: So we have to output one more page. |
| 1331 |
% \begin{macrocode} |
| 1332 |
\null |
| 1333 |
\fi |
| 1334 |
}% |
| 1335 |
\endgroup |
| 1336 |
} |
| 1337 |
% \end{macrocode} |
| 1338 |
% \begin{macro}{\slnc@firstof,\slnc@secondof} |
| 1339 |
% We need these little helpers, because some packages like |
| 1340 |
% \pkg{hyperref} extend the label mechanism by additional arguments. |
| 1341 |
% \begin{macrocode} |
| 1342 |
\newcommand*{\slnc@firstof}{} |
| 1343 |
\def\slnc@firstof#1#2\@nil{#1}% |
| 1344 |
\newcommand*{\slnc@secondof}{} |
| 1345 |
\def\slnc@secondof#1#2#3\@nil{#2}% |
| 1346 |
% \end{macrocode} |
| 1347 |
% \end{macro}^^A \slnc@firstof,\slnc@secondof |
| 1348 |
% \begin{macro}{\slnc@voidtest} |
| 1349 |
% \begin{description} |
| 1350 |
% \item[\marg{string}:] the name of a note column (must be fully |
| 1351 |
% expandable and expand to a string only). |
| 1352 |
% \end{description} |
| 1353 |
% If the box of the note column is empty/void it returns \cs{z@} otherwise |
| 1354 |
% \cs{@ne}. |
| 1355 |
% \begin{macrocode} |
| 1356 |
\newcommand*{\slnc@voidtest}[1]{% |
| 1357 |
\expandafter\ifvoid \csname slnc@#1@box\endcsname \z@\else \@ne\fi |
| 1358 |
} |
| 1359 |
%</body> |
| 1360 |
% \end{macrocode} |
| 1361 |
% \end{macro}^^A \slnc@voidtest |
| 1362 |
% \end{command}^^A \clearnotecolumn |
| 1363 |
% |
| 1364 |
% \begin{command}{\clearnotecolumns} |
| 1365 |
% \changes{v3.26}{2018/08/29}{\cs{scr@trim@spaces} added} |
| 1366 |
% \changes{v3.26}{2018/08/29}{removed spurious \cs{expandafter}} |
| 1367 |
% \begin{description} |
| 1368 |
% \item[\oarg{string list}:] comma separated list of note column names (must |
| 1369 |
% be fully expandable and each element must expand to a string only, that is |
| 1370 |
% the name of a note column); if omitted or empty all note columns will be |
| 1371 |
% used. |
| 1372 |
% \end{description} |
| 1373 |
% Output as many (empty) pages as needed to output all unprocessed notes of |
| 1374 |
% all (given) note columns. Note, that the output of the first page may |
| 1375 |
% result in more unprocessed notes. But the output of the following (empty) |
| 1376 |
% pages shouldn't. |
| 1377 |
% \begin{macrocode} |
| 1378 |
%<*body> |
| 1379 |
\newcommand*\clearnotecolumns[1][\relax]{% |
| 1380 |
\begingroup |
| 1381 |
\slnc@autoclearnotecolumnsfalse |
| 1382 |
\ifx\relax#1\relax\else |
| 1383 |
\let\slnc@processnotecolumns\@empty |
| 1384 |
\edef\reserved@a{#1}% |
| 1385 |
\@for\reserved@a:=\reserved@a\do {% |
| 1386 |
\scr@trim@spaces\reserved@a |
| 1387 |
\ifx\reserved@a\@empty\else |
| 1388 |
\expandafter\l@addto@macro\expandafter\slnc@processnotecolumns |
| 1389 |
\expandafter{\expandafter\@elt\expandafter{\reserved@a}}% |
| 1390 |
\fi |
| 1391 |
}% |
| 1392 |
\fi |
| 1393 |
% \end{macrocode} |
| 1394 |
% First of all we need to know the note column page of this page. |
| 1395 |
% \begin{macrocode} |
| 1396 |
\stepcounter{slnc@clearnote@label}% |
| 1397 |
\if@filesw |
| 1398 |
\begingroup |
| 1399 |
\def\@elt##1{+\slnc@voidtest{##1}}% |
| 1400 |
\protected@write\@auxout{% |
| 1401 |
\let\theslncpage\relax |
| 1402 |
\let\slnc@voidtest\relax |
| 1403 |
}{% |
| 1404 |
\string\newlabel{notecolumn.\theslnc@clearnote@label}% |
| 1405 |
{{\theslncpage}{\numexpr \slnc@processnotecolumns\relax}}% |
| 1406 |
}% |
| 1407 |
\endgroup |
| 1408 |
\fi |
| 1409 |
\scr@ifundefinedorrelax{r@notecolumn.\theslnc@clearnote@label}{% |
| 1410 |
\begingroup |
| 1411 |
\def\@elt##1{, `##1'}% |
| 1412 |
\PackageInfo{scrlayer-notecolumn}{% |
| 1413 |
Using estimated to low value for\MessageBreak |
| 1414 |
clearing note colums\MessageBreak |
| 1415 |
\expandafter\@gobble\slnc@processnotecolumns |
| 1416 |
}% |
| 1417 |
\endgroup |
| 1418 |
\edef\slnc@cmp@value{\the\value{slncpage}}% |
| 1419 |
\let\reserved@a\z@ |
| 1420 |
}{% |
| 1421 |
\edef\reserved@a{% |
| 1422 |
\@nameuse{r@notecolumn.\theslnc@clearnote@label}\@empty\@empty |
| 1423 |
}% |
| 1424 |
\edef\slnc@cmp@value{\expandafter\slnc@firstof\reserved@a\@nil}% |
| 1425 |
\edef\reserved@a{\expandafter\slnc@secondof\reserved@a\@nil}% |
| 1426 |
}% |
| 1427 |
%<*trace> |
| 1428 |
\PackageInfo{scrlayer-notecolumn}{% |
| 1429 |
TRACE (slnc): clearnote=\@nameuse{theslnc@clearnote@label}, |
| 1430 |
abspage=\theslncpage, until page=\slnc@cmp@value, |
| 1431 |
process=\reserved@a, pagetotal=\the\pagetotal, topskip=\the\topskip}% |
| 1432 |
%</trace> |
| 1433 |
\ifvmode\ifdim \pagetotal<\topskip |
| 1434 |
% \end{macrocode} |
| 1435 |
% \cs{clearpage} wouldn't result in a new page, so we do not have to output |
| 1436 |
% the notes of this page but only until the previous. |
| 1437 |
% \begin{macrocode} |
| 1438 |
\edef\slnc@cmp@value{\the\numexpr\slnc@cmp@value-1}% |
| 1439 |
%<trace> \PackageInfo{scrlayer-notecolumn}{TRACE (slnc): until page=\slnc@cmp@value}% |
| 1440 |
\fi\fi |
| 1441 |
\ifnum \reserved@a=\z@ |
| 1442 |
% \end{macrocode} |
| 1443 |
% Next we read all notes until the end of the current page, but only |
| 1444 |
% if a \cs{clearpage} wouldn't result in a new page. |
| 1445 |
% \begin{macrocode} |
| 1446 |
\ifvmode |
| 1447 |
\ifdim \pagetotal<\topskip |
| 1448 |
\else |
| 1449 |
\slnc@readnotes{\slnc@cmp@value}% |
| 1450 |
\fi |
| 1451 |
\else |
| 1452 |
\slnc@readnotes{\slnc@cmp@value}% |
| 1453 |
\fi |
| 1454 |
\begingroup |
| 1455 |
\aftergroup\@tempswafalse |
| 1456 |
\long\def\slnc@note##1##2##3##4{% |
| 1457 |
\ifnum ##2>\slnc@cmp@value\relax \else \aftergroup\@tempswatrue\fi |
| 1458 |
}% |
| 1459 |
\let\slnc@sync\slnc@note |
| 1460 |
\def\@elt##1{\csname slnc@##1@unprocessed\endcsname}% |
| 1461 |
\slnc@processnotecolumns |
| 1462 |
\endgroup |
| 1463 |
\else |
| 1464 |
\PackageInfo{scrlayer-notecolumn}{% |
| 1465 |
box of at least one note column\MessageBreak |
| 1466 |
not empty after page of \string\clearnotecolumns}% |
| 1467 |
\@tempswatrue |
| 1468 |
\fi |
| 1469 |
\if@tempswa |
| 1470 |
% \end{macrocode} |
| 1471 |
% Yes, we have! |
| 1472 |
% \begin{macrocode} |
| 1473 |
\IfLayerPageStyleExists{\currentpagestyle}{}{% |
| 1474 |
\PackageWarning{scrlayer-notecolumn}{% |
| 1475 |
\string\clearnotecolumns\space while active non-layer\MessageBreak |
| 1476 |
page style.\MessageBreak |
| 1477 |
Activating empty page style until note\MessageBreak |
| 1478 |
column has been cleared% |
| 1479 |
}% |
| 1480 |
\pagestyle{empty}% |
| 1481 |
}% |
| 1482 |
\@tempswatrue |
| 1483 |
\fi |
| 1484 |
\@whilesw\if@tempswa\fi{% |
| 1485 |
%<trace> \PackageInfo{scrlayer-notecolumn}{TRACE (slnc): adding \string\clearpage}% |
| 1486 |
% \end{macrocode} |
| 1487 |
% Yes, we have (maybe again)! |
| 1488 |
% \begin{macrocode} |
| 1489 |
\clearpage |
| 1490 |
\begingroup |
| 1491 |
\def\@elt##1{+\slnc@voidtest{##1}}% |
| 1492 |
\ifcase \numexpr \slnc@processnotecolumns\relax |
| 1493 |
\aftergroup\@tempswafalse |
| 1494 |
\long\def\slnc@note##1##2##3##4{% |
| 1495 |
\ifnum ##2>\slnc@cmp@value\relax \else \aftergroup\@tempswatrue\fi |
| 1496 |
}% |
| 1497 |
\let\slnc@sync\slnc@note |
| 1498 |
\def\@elt##1{\csname slnc@##1@unprocessed\endcsname}% |
| 1499 |
\slnc@processnotecolumns |
| 1500 |
\else |
| 1501 |
\aftergroup\@tempswatrue |
| 1502 |
\fi |
| 1503 |
\endgroup |
| 1504 |
\if@tempswa |
| 1505 |
% \end{macrocode} |
| 1506 |
% And we still have: So we have to output one more page. |
| 1507 |
% \begin{macrocode} |
| 1508 |
\null |
| 1509 |
\fi |
| 1510 |
}% |
| 1511 |
\endgroup |
| 1512 |
} |
| 1513 |
%</body> |
| 1514 |
% \end{macrocode} |
| 1515 |
% \end{command}^^A \clearnotecolumns |
| 1516 |
% |
| 1517 |
% |
| 1518 |
% \subsection{Syncronisation of text and note} |
| 1519 |
% \label{sec:scrlayer-notecolumn.sync} |
| 1520 |
% |
| 1521 |
% Until yet we have the text and we have note columns. Normally note entries |
| 1522 |
% to a note column are in sync with the text position, that makes the |
| 1523 |
% note. But if there are collisions the sync may be lost. In this case the |
| 1524 |
% note may be later (but never earlier), so we need a mechanism to force |
| 1525 |
% synchronisation of the text with the note. |
| 1526 |
% |
| 1527 |
% \begin{command}{\syncwithnotecolumn,\syncwithnotecolumns} |
| 1528 |
% \changes{v3.26}{2018/08/29}{\cs{scr@trim@spaces} added} |
| 1529 |
% \changes{v3.26}{2018/08/29}{removed spurious \cs{expandafter}} |
| 1530 |
% \begin{description} |
| 1531 |
% \item[\oarg{string}:] the name of the note column to sync with (this must be |
| 1532 |
% fully expandable and expand to the name of a note column). By default sync |
| 1533 |
% with note column |marginpar|. |
| 1534 |
% \end{description} |
| 1535 |
% \begin{counter}{slnc@syncpoint} |
| 1536 |
% Add at the \LaTeX{} run after the next \LaTeX{} run as much space to the |
| 1537 |
% text (not the note column!) as needed to reach the next position at the |
| 1538 |
% note column. This is not the same like \cs{clearnotecolumn}, because it |
| 1539 |
% doesn't need to go to the next page, but it needs at least three \LaTeX{} |
| 1540 |
% runs to terminate. |
| 1541 |
% \begin{macrocode} |
| 1542 |
%<*body> |
| 1543 |
\newcounter{slnc@syncpoint}% |
| 1544 |
\newcommand*{\syncwithnotecolumn}[1][marginpar]{% |
| 1545 |
\begingroup |
| 1546 |
\edef\reserved@a{\endgroup\noexpand\syncwithnotecolumns[{#1}]}% |
| 1547 |
\reserved@a |
| 1548 |
} |
| 1549 |
\newcommand*{\syncwithnotecolumns}[1][\relax]{% |
| 1550 |
\begingroup |
| 1551 |
\ifx\relax#1\relax\else |
| 1552 |
\let\slnc@processnotecolumns\@empty |
| 1553 |
\edef\reserved@a{#1}% |
| 1554 |
\@for\reserved@a:=\reserved@a\do {% |
| 1555 |
\scr@trim@spaces\reserved@a |
| 1556 |
\ifx\reserved@a\@empty\else |
| 1557 |
\expandafter\l@addto@macro\expandafter\slnc@processnotecolumns |
| 1558 |
\expandafter{\expandafter\@elt\expandafter{\reserved@a}}% |
| 1559 |
\fi |
| 1560 |
}% |
| 1561 |
\fi |
| 1562 |
\stepcounter{slnc@syncpoint}% |
| 1563 |
\def\@elt##1{% |
| 1564 |
\addtocontents{slnc}{% |
| 1565 |
\string\slnc@sync{##1}% |
| 1566 |
{\noexpand\number\value{slncpage}}% |
| 1567 |
{\theslnc@syncpoint}% |
| 1568 |
{}% |
| 1569 |
}% |
| 1570 |
}% |
| 1571 |
\slnc@processnotecolumns |
| 1572 |
\ifvmode |
| 1573 |
\let\slnc@voffset\@empty% |
| 1574 |
\expandafter\@firstofone |
| 1575 |
\else |
| 1576 |
\PackageWarning{scrlayer-notecolumn}{% |
| 1577 |
\string\syncwithnotecolumn\space in hmode.\MessageBreak |
| 1578 |
Using \string\syncwithnotecolumn\space in horizontal\MessageBreak |
| 1579 |
mode may result in unwanted vertical\MessageBreak |
| 1580 |
space inside paragraphs and may lost\MessageBreak |
| 1581 |
colors of text of notes. \space So perhaps you\MessageBreak |
| 1582 |
should move \string\syncwithnotecolumn\space before\MessageBreak |
| 1583 |
or after the paragraph% |
| 1584 |
}% |
| 1585 |
\let\slnc@voffset\@empty%\def\slnc@voffset{-\number\baselineskip}% |
| 1586 |
\expandafter\slnc@vadjust |
| 1587 |
\fi |
| 1588 |
{% |
| 1589 |
\if@filesw |
| 1590 |
\scr@savepos |
| 1591 |
\protected@write\@auxout{}{% |
| 1592 |
\string\newlabel{notecolumn.\[email protected]}{% |
| 1593 |
{% |
| 1594 |
\noexpand\number |
| 1595 |
\numexpr \scr@lastypos\slnc@voffset\relax |
| 1596 |
}{\thepage}% |
| 1597 |
}% |
| 1598 |
}% |
| 1599 |
\fi |
| 1600 |
\@ifundefined{r@notecolumn.\[email protected]}{% |
| 1601 |
\PackageInfo{scrlayer-notecolumn}{% |
| 1602 |
No text label for \string\syncwithnotecolumn.\MessageBreak |
| 1603 |
Need rerun to sync position}% |
| 1604 |
}{% |
| 1605 |
\edef\reserved@a{% |
| 1606 |
\@nameuse{r@notecolumn.\[email protected]}% |
| 1607 |
\@empty\@empty |
| 1608 |
}% |
| 1609 |
\edef\slnc@textpos{\expandafter\slnc@firstof\reserved@a\@nil}% |
| 1610 |
\edef\slnc@textpage{\expandafter\slnc@secondof\reserved@a\@nil}% |
| 1611 |
\let\slnc@notepos\slnc@textpos |
| 1612 |
\let\slnc@notepage\slnc@textpage |
| 1613 |
\def\@elt##1{% |
| 1614 |
\@ifundefined{r@notecolumn.##1.\[email protected]}{% |
| 1615 |
\PackageInfo{scrlayer-notecolumn}{% |
| 1616 |
No note label for sync with note column\MessageBreak |
| 1617 |
`##1'.\MessageBreak |
| 1618 |
Need rerun to sync position}% |
| 1619 |
\G@refundefinedtrue |
| 1620 |
}{% |
| 1621 |
\edef\reserved@a{% |
| 1622 |
\@nameuse{r@notecolumn.##1.\[email protected]}% |
| 1623 |
\@empty\@empty |
| 1624 |
}% |
| 1625 |
\edef\reserved@b{\expandafter\slnc@firstof\reserved@a\@nil}% |
| 1626 |
\edef\reserved@c{\expandafter\slnc@secondof\reserved@a\@nil}% |
| 1627 |
\ifnum \slnc@notepage<\reserved@c\relax |
| 1628 |
\let\slnc@notepos=\reserved@b |
| 1629 |
\let\slnc@notepage=\reserved@c |
| 1630 |
\else |
| 1631 |
\ifnum \slnc@notepage=\reserved@c\relax |
| 1632 |
\ifnum \slnc@notepos>\reserved@b |
| 1633 |
\let\slnc@notepos=\reserved@b |
| 1634 |
\let\slnc@notepage=\reserved@c |
| 1635 |
\fi |
| 1636 |
\fi |
| 1637 |
\fi |
| 1638 |
}% |
| 1639 |
}% |
| 1640 |
\slnc@processnotecolumns |
| 1641 |
\ifnum\slnc@textpage>\slnc@notepage\relax |
| 1642 |
\PackageInfo{scrlayer-notecolumn}{% |
| 1643 |
Last note page before last text page.\MessageBreak |
| 1644 |
Need rerun to sync position}% |
| 1645 |
\else |
| 1646 |
\ifnum\slnc@textpage<\slnc@notepage\relax |
| 1647 |
\@whilenum \slnc@textpage<\slnc@notepage\do {% |
| 1648 |
\newpage\null\vskip-\dimexpr \baselineskip+\parskip\relax |
| 1649 |
\edef\slnc@textpage{\the\numexpr\slnc@textpage+1\relax}% |
| 1650 |
}% |
| 1651 |
% \end{macrocode} |
| 1652 |
% \changes{v0.1}{2015/10/07}{ready for renaming \cs{pdfpageheight} in |
| 1653 |
% luaTeX} |
| 1654 |
% From lua\TeX~0.80.1 \cs{pdfpageheight} will be renamed into |
| 1655 |
% \cs{pageheight}. So we have to do an extra test for the new primitive. |
| 1656 |
% \begin{macrocode} |
| 1657 |
\scr@ifundefinedorrelax{pdfpageheight}{% |
| 1658 |
\scr@ifundefinedorrelax{pageheight}{% |
| 1659 |
\@tempdima=\paperheight |
| 1660 |
}{% |
| 1661 |
\@tempdima=\pageheight |
| 1662 |
}% |
| 1663 |
}{% |
| 1664 |
\@tempdima=\pdfpageheight |
| 1665 |
}% |
| 1666 |
\@tempdima=\dimexpr \@tempdima |
| 1667 |
-\topmargin-1in |
| 1668 |
-\headheight-\headsep |
| 1669 |
-\topskip+\baselineskip |
| 1670 |
\relax |
| 1671 |
\edef\slnc@textpos{\number\@tempdima}% |
| 1672 |
%<*trace> |
| 1673 |
\PackageInfo{scrlayer-notecolumn}{% |
| 1674 |
Top position is \slnc@textpos% |
| 1675 |
}% |
| 1676 |
%</trace> |
| 1677 |
\fi |
| 1678 |
\ifnum\slnc@notepos>\slnc@textpos\relax |
| 1679 |
\PackageInfo{scrlayer-notecolumn}{% |
| 1680 |
Last note position before last text\MessageBreak |
| 1681 |
position.\MessageBreak |
| 1682 |
Need rerun to sync position% |
| 1683 |
}% |
| 1684 |
\else |
| 1685 |
\ifnum\slnc@notepos<\slnc@textpos\relax |
| 1686 |
\@tempdima=\numexpr \slnc@textpos-\slnc@notepos\relax sp |
| 1687 |
\PackageInfo{scrlayer-notecolumn}{% |
| 1688 |
skipping \the\@tempdima\space to sync% |
| 1689 |
}% |
| 1690 |
\vskip\@tempdima |
| 1691 |
\fi |
| 1692 |
\fi |
| 1693 |
\fi |
| 1694 |
}% |
| 1695 |
}% |
| 1696 |
\endgroup |
| 1697 |
} |
| 1698 |
% \end{macrocode} |
| 1699 |
% \end{counter} |
| 1700 |
% \begin{macro}{\slnc@vadjust} |
| 1701 |
% \begin{macrocode} |
| 1702 |
\newcommand{\slnc@vadjust}[1]{% |
| 1703 |
\@bsphack |
| 1704 |
\vadjust{#1}% |
| 1705 |
\@esphack |
| 1706 |
} |
| 1707 |
%</body> |
| 1708 |
% \end{macrocode} |
| 1709 |
% \end{macro}^^A \slnc@vadjust |
| 1710 |
% \end{command}^^A \syncwithnotecolumn,\syncwithnotecolumns |
| 1711 |
% |
| 1712 |
% |
| 1713 |
% \section{Automatic Conversion of Page Styles} |
| 1714 |
% \label{sec:autoconv} |
| 1715 |
% |
| 1716 |
% As explained in the user guide \pkg*{scrlayer-notecolumn} depends on using |
| 1717 |
% page styles, which have been defined using package \pkg{scrlayer}. Because |
| 1718 |
% of this, the package also provides automatic conversion of page styles into |
| 1719 |
% layer page styles. But this can fail and also is optional. |
| 1720 |
% |
| 1721 |
% \begin{option}{autoconvertpagestyles} |
| 1722 |
% \changes{v0.4.4233}{2025/10/31}{added} |
| 1723 |
% \begin{macrocode} |
| 1724 |
%<*options> |
| 1725 |
\KOMA@ifkey{autoconvertpagestyles}{slnc@autoconvertps} |
| 1726 |
\slnc@autoconvertpstrue |
| 1727 |
%</options> |
| 1728 |
% \end{macrocode} |
| 1729 |
% \end{option} |
| 1730 |
% |
| 1731 |
% \begin{macro}{\slnc@LayerizePageStyle} |
| 1732 |
% \changes{v0.4.4233}{2025/10/31}{added} |
| 1733 |
% This macro does the \emph{layerization} of the active page style. Note, |
| 1734 |
% that the new layer page style still needs to be activated. |
| 1735 |
% \begin{macrocode} |
| 1736 |
%<*body> |
| 1737 |
\newcommand*{\slnc@LayerizePageStyle}[1]{% |
| 1738 |
\PackageWarningNoLine{scrlayer-notecolumns}{% |
| 1739 |
Automatic conversion of active page\MessageBreak |
| 1740 |
style into layer page style\MessageBreak |
| 1741 |
#1.\MessageBreak |
| 1742 |
Please note: Automatic conversion can fail\MessageBreak |
| 1743 |
and therefore you should redefine all used\MessageBreak |
| 1744 |
page styles yourself using either scrlayer\MessageBreak |
| 1745 |
command \string\DeclarePageStyleByLayers\space or\MessageBreak |
| 1746 |
\string\RedeclarePageStyleByLayers, or\MessageBreak |
| 1747 |
the commands of package\MessageBreak |
| 1748 |
scrlayer-fancyhdr of scrlayer-scrheading% |
| 1749 |
}% |
| 1750 |
\ExpandArgs{c}\DeclareCommandCopy{slnc@ps@#1@mkboth}\@mkboth |
| 1751 |
\ExpandArgs{c}\DeclareCommandCopy{slnc@ps@#1@mkright}\@mkright |
| 1752 |
\ExpandArgs{c}\DeclareCommandCopy{slnc@ps@#1@mkdouble}\@mkdouble |
| 1753 |
\ExpandArgs{c}\DeclareCommandCopy{slnc@ps@#1@oddhead}\@oddhead |
| 1754 |
\ExpandArgs{c}\DeclareCommandCopy{slnc@ps@#1@evenhead}\@evenhead |
| 1755 |
\ExpandArgs{c}\DeclareCommandCopy{slnc@ps@#1@oddfoot}\@oddfoot |
| 1756 |
\ExpandArgs{c}\DeclareCommandCopy{slnc@ps@#1@evenfoot}\@evenfoot |
| 1757 |
\DeclareNewLayer[% |
| 1758 |
background,oddpage,% |
| 1759 |
head,% |
| 1760 |
contents=\hb@xt@ \linewidth {\UseName{slnc@ps@#1@oddhead}}% |
| 1761 |
]{#1.oddhead}% |
| 1762 |
\DeclareNewLayer[% |
| 1763 |
background,evenpage,% |
| 1764 |
head,% |
| 1765 |
contents=\hb@xt@ \linewidth {\UseName{slnc@ps@#1@evenhead}}% |
| 1766 |
]{#1.evenhead}% |
| 1767 |
\DeclareNewLayer[% |
| 1768 |
foreground,oddpage,% |
| 1769 |
foot,% |
| 1770 |
contents=\hb@xt@ \linewidth {\UseName{slnc@ps@#1@oddfoot}}% |
| 1771 |
]{#1.oddfoot}% |
| 1772 |
\DeclareNewLayer[% |
| 1773 |
foreground,evenpage,% |
| 1774 |
foot,% |
| 1775 |
contents=\hb@xt@ \linewidth {\UseName{slnc@ps@#1@evenfoot}}% |
| 1776 |
]{#1.evenfoot}% |
| 1777 |
\DeclarePageStyleByLayers[% |
| 1778 |
onselect=\ExpandArgs{Nc}\RenewCommandCopy\@mkboth{slnc@ps@#1@mkboth}% |
| 1779 |
\ExpandArgs{Nc}\RenewCommandCopy\@mkright{slnc@ps@#1@mkright}% |
| 1780 |
\ExpandArgs{Nc}\RenewCommandCopy\@mkdouble{slnc@ps@#1@mkdouble}% |
| 1781 |
]{#1}{#1.oddhead,#1.evenhead,#1.oddfoot,#1.evenfoot}% |
| 1782 |
} |
| 1783 |
\AddToHook{begindocument/end}{% |
| 1784 |
\ifslnc@autoconvertps |
| 1785 |
\ifx\currentpagestyle\@empty |
| 1786 |
\slnc@LayerizePageStyle{slnc@default}% |
| 1787 |
\pagestyle{slnc@default}% |
| 1788 |
\else |
| 1789 |
\IfLayerPageStyleExists{\currentpagestyle}{}{% |
| 1790 |
\expandafter\slnc@LayerizePageStyle\expandafter{\currentpagestyle}% |
| 1791 |
\expandafter\pagestyle\expandafter{\currentpagestyle}% |
| 1792 |
}% |
| 1793 |
\fi |
| 1794 |
\fi |
| 1795 |
} |
| 1796 |
\AfterSelectAnyPageStyle{% |
| 1797 |
\ifslnc@autoconvertps |
| 1798 |
\IfLayerPageStyleExists{\currentpagestyle}% |
| 1799 |
{}% |
| 1800 |
{% |
| 1801 |
\expandafter\slnc@LayerizePageStyle\expandafter{\currentpagestyle}% |
| 1802 |
\expandafter\pagestyle\expandafter{\currentpagestyle}% |
| 1803 |
}% |
| 1804 |
\fi |
| 1805 |
} |
| 1806 |
% \end{macrocode} |
| 1807 |
% \changes{v0.4.4254}{2025/12/31}{\pkg{babel} catcode change workaround} |
| 1808 |
% Because generic command hooks are dangerous if catcodes are changed, we |
| 1809 |
% use catcodes suitable for packages. This is only a workaround for packages |
| 1810 |
% like \pkg{babel}, which change catcodes. But it can still fail, e.g., if |
| 1811 |
% a page style is defined using other catcodes. |
| 1812 |
% \begin{macrocode} |
| 1813 |
\ExplSyntaxOn |
| 1814 |
\cctab_new:N \c__scrlayer_notecolumn_cmdhook_cctab |
| 1815 |
\cctab_gsave_current:N \c__scrlayer_notecolumn_cmdhook_cctab |
| 1816 |
\hook_gput_code:nnn { cmd / thispagestyle / after } { . } |
| 1817 |
{ |
| 1818 |
\ifslnc@autoconvertps |
| 1819 |
\if@specialpage |
| 1820 |
\IfLayerPageStyleExists{\@specialstyle}{}{% |
| 1821 |
\cctab_begin:N \c__scrlayer_notecolumn_cmdhook_cctab |
| 1822 |
\hook_gput_code:nnn { cmd / ps@\@specialstyle / after } |
| 1823 |
{ scrlayer-notecolumn } |
| 1824 |
{ |
| 1825 |
\slnc@LayerizePageStyle{\@specialstyle} |
| 1826 |
\@nameuse{ps@\@specialstyle}% |
| 1827 |
} |
| 1828 |
\cctab_end: |
| 1829 |
}% |
| 1830 |
\fi |
| 1831 |
\fi |
| 1832 |
} |
| 1833 |
\ExplSyntaxOff |
| 1834 |
%</body> |
| 1835 |
% \end{macrocode} |
| 1836 |
% \end{macro} |
| 1837 |
% |
| 1838 |
% \begin{macrocode} |
| 1839 |
%</interface> |
| 1840 |
% \end{macrocode} |
| 1841 |
% |
| 1842 |
% \Finale |
| 1843 |
% \PrintChanges |
| 1844 |
% |
| 1845 |
\endinput |
| 1846 |
% Local Variables: |
| 1847 |
% mode: doctex |
| 1848 |
% ispell-local-dictionary: "en_US" |
| 1849 |
% eval: (flyspell-mode 1) |
| 1850 |
% TeX-master: t |
| 1851 |
% TeX-engine: luatex-dev |
| 1852 |
% eval: (setcar (or (cl-member "Index" (setq-local TeX-command-list (copy-alist TeX-command-list)) :key #'car :test #'string-equal) (setq-local TeX-command-list (cons nil TeX-command-list))) '("Index" "mkindex %s" TeX-run-index nil t :help "makeindex for dtx")) |
| 1853 |
% End: |