| 1 |
% \iffalse meta-comment |
| 2 |
% |
| 3 |
% Copyright (C) 2022-2025 by Anton Vrba |
| 4 |
% |
| 5 |
% Home Page: https://github.com/anton-vrba/sidenotesplus |
| 6 |
% Issues: https://github.com/anton-vrba/sidenotesplus/issues |
| 7 |
% |
| 8 |
% |
| 9 |
% LaTeX Package: sidenotesplus |
| 10 |
% |
| 11 |
% |
| 12 |
% This work may be distributed and/or modified under the conditions of |
| 13 |
% the LaTeX Project Public License, either version 1.3c of this license |
| 14 |
% or (at your option) any later version. The latest version of this |
| 15 |
% license is in |
| 16 |
% http://www.latex-project.org/lppl.txt |
| 17 |
% and version 1.3c or later is part of all distributions of LaTeX |
| 18 |
% version 2008-05-04 or later. |
| 19 |
% |
| 20 |
% This work was inspired by: https://ctan.org/pkg/sidenotes by: Andy Thomas |
| 21 |
% |
| 22 |
% |
| 23 |
% This work has the LPPL maintenance status `maintained'. |
| 24 |
% |
| 25 |
% The Current Maintainer of this work is Anton Vrba. |
| 26 |
% |
| 27 |
% This work consists of the files sidenotesplus.dtx and sidenotesplus.ins |
| 28 |
% and the derived filebase sidenotesplus.sty. |
| 29 |
% |
| 30 |
% \fi |
| 31 |
% |
| 32 |
% \iffalse |
| 33 |
%<*driver> |
| 34 |
\ProvidesFile{sidenotesplus.dtx} |
| 35 |
%</driver> |
| 36 |
%<package>\NeedsTeXFormat{LaTeX2e}[2020/10/01] |
| 37 |
%<package>\ProvidesPackage{sidenotesplus} |
| 38 |
%<*package> |
| 39 |
[2025/2/18 1.05 rich text marginal notes, tables and figures ] |
| 40 |
%</package> |
| 41 |
%<package>\RequirePackage{marginnote} % provides an offset option for the marginals instead of a float |
| 42 |
%<package>\RequirePackage{caption} % handles the captions (in the margin) |
| 43 |
%<package>\RequirePackage{xparse} % new LaTeX3 syntax to define macros and environments |
| 44 |
%<package>\RequirePackage{calc} |
| 45 |
%<package>\RequirePackage{etoolbox} % provides \patchcmd |
| 46 |
%<package>\RequirePackage{l3keys2e} |
| 47 |
%<package>\RequirePackage{ifoddpage} |
| 48 |
%<package>\RequirePackage{mparhack} % get marginpar right |
| 49 |
%<package>\RequirePackage{xspace} |
| 50 |
%<package>\RequirePackage[strict]{changepage} |
| 51 |
%<*driver> |
| 52 |
\documentclass{ltxdoc} |
| 53 |
\usepackage{tabularx} |
| 54 |
\usepackage{xspace} |
| 55 |
\setlength{\textheight}{9.25in} |
| 56 |
\setlength{\headsep}{-0.25in} |
| 57 |
\EnableCrossrefs |
| 58 |
%\CodelineIndex |
| 59 |
\RecordChanges |
| 60 |
\begin{document} |
| 61 |
\DocInput{sidenotesplus.dtx} |
| 62 |
% \PrintIndex |
| 63 |
\PrintChanges |
| 64 |
\end{document} |
| 65 |
%</driver> |
| 66 |
% \fi |
| 67 |
% |
| 68 |
% |
| 69 |
% \CharacterTable |
| 70 |
% {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 |
| 71 |
% 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 |
| 72 |
% Digits \0\1\2\3\4\5\6\7\8\9 |
| 73 |
% Exclamation \! Double quote \" Hash (number) \# |
| 74 |
% Dollar \$ Percent \% Ampersand \& |
| 75 |
% Acute accent \' Left paren \( Right paren \) |
| 76 |
% Asterisk \* Plus \+ Comma \, |
| 77 |
% Minus \- Point \. Solidus \/ |
| 78 |
% Colon \: Semicolon \; Less than \< |
| 79 |
% Equals \= Greater than \> Question mark \? |
| 80 |
% Commercial at \@ Left bracket \[ Backslash \\ |
| 81 |
% Right bracket \] Circumflex \^ Underscore \_ |
| 82 |
% Grave accent \` Left brace \{ Vertical bar \| |
| 83 |
% Right brace \} Tilde \~} |
| 84 |
% |
| 85 |
% |
| 86 |
% |
| 87 |
% |
| 88 |
% \GetFileInfo{sidenotesplus.dtx} |
| 89 |
% \title{The \textsf{sidenotesplus} package} |
| 90 |
% \author{Anton Vrba\\\small% |
| 91 |
% Home Page: \url{https://github.com/anton-vrba/sidenotesplus} \\\small |
| 92 |
% Issues: \url{https://github.com/anton-vrba/sidenotesplus/issues }} |
| 93 |
% \date{Version \fileversion\xspace from \filedate} |
| 94 |
% |
| 95 |
% \maketitle |
| 96 |
% |
| 97 |
% \changes{1.0}{2022/05/15}{Initial Release} |
| 98 |
% \changes{1.01}{2022/05/31}{Environment text* improved} |
| 99 |
% \changes{1.02}{2022/07/09}{added Ragged option} |
| 100 |
% \changes{1.03}{2023/10/05}{added commands sidecitebefore, sideciteafter and sidcitemark} |
| 101 |
% \changes{1.04}{2023/12/19}{fixed bug in the sidecite commands (Trailing comma replaced by trailing period} |
| 102 |
% \changes{1.05}{2025/2/18}{resetting sidenote counter per page, section, chapter or none} |
| 103 |
% |
| 104 |
% \begin{abstract} |
| 105 |
% \noindent A package to manage the margin notes, figures, tables and captions. |
| 106 |
% Also body text can be extended into the margin for wide figures, tables and equation. |
| 107 |
% Twoside symmetry is preserved. For biblatex users, routines for side references are |
| 108 |
% included. |
| 109 |
% \end{abstract} |
| 110 |
% |
| 111 |
% \paragraph*{Note:} Margin notes, figures and tables placements require up to |
| 112 |
% three compilations to be as intended. |
| 113 |
%% |
| 114 |
% \paragraph*{Note:} This package is inspired by the package |sidenotes| authored by |
| 115 |
% Andy Thomas and has many features in common. But, compatibility is |
| 116 |
% not maintained between the two. |
| 117 |
% |
| 118 |
% \section{Usage} |
| 119 |
% \subsection{Package options} |
| 120 |
% Below the options that can be passed to the package |sidenotesplus| |
| 121 |
% with the package defaults listed first. |
| 122 |
% |
| 123 |
% ~ |
| 124 |
% |
| 125 |
% \begin{tabularx}{\textwidth}{ r X } |
| 126 |
% |mark=| & |alph, Alph, arabic, roman, Roman, fnsymbol| \\ |
| 127 |
% |font=| & |rm, sf|\\ |
| 128 |
% |size=| & |footnote, normal, small, script| \\ |
| 129 |
% |shape=| & | up, it, sl|\\ |
| 130 |
% |ragged| & switches to ragged outer margins\\ |
| 131 |
% |Ragged| & switches to ragged outer margins but uses ragged2e package\\ |
| 132 |
% |classic| & switches to a classic look\\ |
| 133 |
% |sepdiff=| & |1em|, or a valid length within reason \\ |
| 134 |
% |alerton| & switches on the rendering of the margin alerts \\ |
| 135 |
% |per=| & |page, section, chapter, none| defaults to counter per page \\ |
| 136 |
% \end{tabularx} |
| 137 |
% |
| 138 |
% ~ |
| 139 |
% |
| 140 |
% The normal page style is that margin notes are left-right justified with the |
| 141 |
% last line ragged to the outer edge. The option |ragged| or |Ragged| changes this |
| 142 |
% style to ragged-outer, that is the left page's marginal notes are |\raggedleft| |
| 143 |
% and the right page's are |\raggedright|. |
| 144 |
% If you opt to use |Ragged| the package |ragged2e| is loaded and |RaggedLeft/Right| |
| 145 |
% is used instead of |raggedleft/right|. Load package |ragged2e| with required |
| 146 |
% options before |sidenotesplus| is loaded, otherwise |sidenotesplus| loads |
| 147 |
% |ragged2e| without any options. |
| 148 |
% |
| 149 |
% The marginal note's reference number or mark is placed in the margin separator, |
| 150 |
% that is on the left page the mark is on the right hand side of the note. |
| 151 |
% The option |classic| always places the mark to the left of the marginal note. |
| 152 |
% This requires that the margin separator on the left page is slightly reduced if not |
| 153 |
% enough space is available to the page outer edge. |
| 154 |
% |
| 155 |
% \subsection{Modified \LaTeX\xspace commands} |
| 156 |
% |
| 157 |
% \DescribeMacro{\marginpar} |
| 158 |
% The LaTex command |marginpar{abc}| with only one |
| 159 |
% parameter it is modified to |
| 160 |
% |\marginpar[left styled abc]{right styled abc}| |
| 161 |
% maintaining page symmetry. |
| 162 |
% If called with two parameters nothing is changed |
| 163 |
% |
| 164 |
% \subsection{Marginal note commands} |
| 165 |
% |
| 166 |
% All marginal note commands have five options followed by the side note text |
| 167 |
% enclosed in braces. Each option has its own enclosing symbols. The option |
| 168 |
% sequence is fixed but not used options are omitted entirely, including their |
| 169 |
% enclosing sequence. The option sequence is \verb"*, ||, <>, (), !!" plus |{}|. |
| 170 |
% |
| 171 |
% ~ |
| 172 |
% |
| 173 |
% % \begin{tabularx}{\textwidth}{ r X } |
| 174 |
% |*| & margin note reference labels is omitted \\ |
| 175 |
% \verb+|float offset|+ & floating offset, negative is towards page top\\ |
| 176 |
% |<fixed offsett>| & fixed offset, negative is towards page top \\ |
| 177 |
% |(custom mark)| & any custom mark\\ |
| 178 |
% |!colour!|& any valid colour\\ |
| 179 |
% |{content}|& margin note content |
| 180 |
% \end{tabularx} |
| 181 |
% |
| 182 |
% ~ |
| 183 |
% |
| 184 |
% \noindent Note: All marginals placed with a fixed offset, that is with the |<fixed offset>| |
| 185 |
% option can be overwritten by the marginals that float. |
| 186 |
% |
| 187 |
% ~ |
| 188 |
% |
| 189 |
% |
| 190 |
% \DescribeMacro{\sidenote} |
| 191 |
% The |\sidenote| has five options |
| 192 |
% \verb+*|offset|<offsett>(custom mark)!colour!+ |
| 193 |
% all preceding the note |{content}|. |
| 194 |
% The options are defined by their enclosures \verb+*||,<>,(),!!+ |
| 195 |
% and must be in the order listed above. |
| 196 |
% |
| 197 |
% Example: \verb"\sitenote|10pt|($\bigstar$){text}" is valid |
| 198 |
% |
| 199 |
% but \verb"\sitenote($\bigstar$)|10pt|{text}" will give an error |
| 200 |
% |
| 201 |
% ~ |
| 202 |
% |
| 203 |
% \DescribeMacro{\sidenotetext} |
| 204 |
% \DescribeMacro{\sidenotemark} |
| 205 |
% \DescribeMacro{\sidenotetextbefore} Similar to |\footnotemark| |
| 206 |
% and |\footnotetext| the macros |\sidenotemark|, |\sidenotetext| |
| 207 |
% and |\sidenotetextbefore| are provided, the latter two have the same |
| 208 |
% options as |\sidenote|. This is useful in placing margin notes in |
| 209 |
% environments where the |\sidenote| is not permitted. |
| 210 |
% The margin note is not positioned by the |\sidenotemark|, but rather it |
| 211 |
% is positioned relative to |\sidenotetext| or |\sidenotetextbefore| |
| 212 |
% |
| 213 |
%% ~ |
| 214 |
% |
| 215 |
% \DescribeMacro{\sidealert} |
| 216 |
% These are temporary margin notes rendered in red |
| 217 |
% or by the user's defined |!colour!|. The package option |alerton| needs to be |
| 218 |
% specified in the document preamble. The alert mark has zero width so it does not |
| 219 |
% alter the main text layout and is also rendered in colour. The alert mark is |
| 220 |
% either numeric arabic (default), or alphabetic if the side note mark is set to |
| 221 |
% arabic |
| 222 |
% |
| 223 |
% |
| 224 |
% ~ |
| 225 |
% |
| 226 |
% \DescribeMacro{\sidepar} Starts a new paragraph in the side note, |
| 227 |
% whereas |\\| begins a new line without indentation. |
| 228 |
% |
| 229 |
% ~ |
| 230 |
% |
| 231 |
%\DescribeMacro{\sidecaption} |
| 232 |
% The \verb"\sidecaption*<offset>[short form]{long form}" |
| 233 |
% macro can be used from within figure or table environment and |
| 234 |
% the caption is placed in the margin adjacent to the figure or table |
| 235 |
% The float \verb+||+ is not an option here. Therefore, the caption might |
| 236 |
% overlap with other marginals. Then, these marginals have to be adjusted with |
| 237 |
% offset parameters. The formatting of the caption is done by the \emph{caption} |
| 238 |
% package by defining a \emph{sidecaption} style. Please refer to the |
| 239 |
% documentation of the caption package for information on styles. The macro can |
| 240 |
% be starred, which is analog to the regular starred caption (no numbering, no |
| 241 |
% tof entry). Use |\raggedinner| within the figure, or table, environment |
| 242 |
% to place these near the caption. |
| 243 |
% |
| 244 |
% ~ |
| 245 |
% |
| 246 |
% \DescribeMacro{\raggedinner} |
| 247 |
% \DescribeMacro{\raggedouter} Are raggedleft or raggedright modes depending if |
| 248 |
% document is one or two sided and if the page is even or odd. |
| 249 |
% |
| 250 |
% ~ |
| 251 |
% |
| 252 |
% \DescribeEnv{marginfigure} |
| 253 |
% The |marginfigure| environment puts a figure and its caption in the margin. |
| 254 |
% Instead of |\begin{figure}[htbp]| use \verb"\begin{marginfigure}|offset|<offset>". |
| 255 |
% Again, using an offset value switches the behaviour from float to fixed |
| 256 |
% position. The marginfigure has its own caption style named \emph{marginfigure}. |
| 257 |
% |
| 258 |
% ~ |
| 259 |
% |
| 260 |
% \DescribeEnv{margintable} |
| 261 |
% The |margintable| environment works similar to marginfigure, but with table |
| 262 |
% environments. Use \verb"\begin{marginfigure}|offset|<offset>" instead of |
| 263 |
% |\begin{table}[htbp]|, its caption style is named \emph{margintable}. |
| 264 |
% |
| 265 |
% ~ |
| 266 |
% |
| 267 |
% \DescribeMacro{\margincaption} |
| 268 |
% The |\margincaption| macro is used only in the two above environments |
| 269 |
% (|marginfigure| and |marginfigure|) and it is not to be confused with |\sidecaption|. |
| 270 |
% It as the same options as |\caption| |
| 271 |
% |
| 272 |
% ~ |
| 273 |
% |
| 274 |
% \DescribeEnv{figure*} |
| 275 |
% The |figure*| environment is used to position figures across the full |
| 276 |
% page, i.e. the text width plus the margin. The algorithm has to distinguish |
| 277 |
% between recto and verso (left and right) pages and might need up to three |
| 278 |
% \LaTeX{} runs to provide the desired result. The corresponding caption style |
| 279 |
% is called \emph{widefigure}. |
| 280 |
% \DescribeEnv{table*} |
| 281 |
% The sister environment for tables is |table*|. Use \emph{widetable} to |
| 282 |
% change its caption style. |
| 283 |
% |
| 284 |
% |
| 285 |
% \DescribeEnv{text*} |
| 286 |
% The |text*| environment is used to render text across up to |
| 287 |
% the full page width. Page breaks are not permitted within this environment. |
| 288 |
% This environment is useful when extra width for equations is required. |
| 289 |
% The environment |\begin{text*}[0.5]| extends the text width by |
| 290 |
% |0.5*(\marginparwidth+\marginparsep)|, omitting the option is equivalent |
| 291 |
% to specifying the option |[1]|, |
| 292 |
% |
| 293 |
% |
| 294 |
% \DescribeMacro{\sidecite} |
| 295 |
% \DescribeMacro{\sidecitebefore} |
| 296 |
% % \DescribeMacro{\sidecitemark} |
| 297 |
% \DescribeMacro{\sideciteafter} |
| 298 |
% \DescribeMacro{\sidecitet} |
| 299 |
% \DescribeMacro{\sidecitet*} |
| 300 |
% The |\sidecite|, |\sidecitet| and |\sidecitet*| provide citing |
| 301 |
% references in the margin and uses the package |biblatex| which has to be setup |
| 302 |
% outside the |sitenotesplus| package. |
| 303 |
% Use |sidecitebefore| or |sideciteafter| to place the marginalia reference |
| 304 |
% before or after the |sidenotemark| |
| 305 |
% Example settings in the document preamble: |
| 306 |
% |
| 307 |
% ~~~~|\usepackage[english]{babel}| |
| 308 |
% |
| 309 |
% ~~~~|\usepackage[backend=biber,style=nature]{biblatex}| |
| 310 |
% |
| 311 |
% ~~~~|\addbibresource{mybibfile.bib}| |
| 312 |
% \\The above three cite-commands use the same options as sidenote followed by the two |
| 313 |
% options of the |biblatex|'s |\fullcite| command. Margin citations are always with marks, |
| 314 |
% hence the |*| takes new meaning here. |
| 315 |
% The command |\sidecite{BibReference}| and |\sidecite*{BibReference}| are |
| 316 |
% equivalent, and both place a side note mark |
| 317 |
% and the citation reference in the side margin. |\sidecitet{BibReference}| |
| 318 |
% renders: Author\textsuperscript{a}, where 'a' is side note mark, whereas |\sidecitet*{BibReference}| |
| 319 |
% is the possessive version and renders: Author's\textsuperscript{a}. |
| 320 |
% |
| 321 |
% |
| 322 |
% \subsection{Packages loaded} |
| 323 |
% |
| 324 |
% \begin{description} |
| 325 |
% \item[marginnote] |
| 326 |
% supports an alternative to \verb+\marginpar+ and creates non floating |
| 327 |
% notes in the margin. |
| 328 |
% \item[mparhack] to get \verb+\marginpar+ right |
| 329 |
% \item[caption] |
| 330 |
% allows to set figure and table captions in the margin and allows |
| 331 |
% easier formatting of these captions. Please refer to the |
| 332 |
% \emph{caption} manual for details on styles. |
| 333 |
% \item[xparse] is used to take advantage of the improved \LaTeX3 syntax. |
| 334 |
% All macros and environments are defined using this package. |
| 335 |
% \item[l3keys2e] provides a key/value mechanism |
| 336 |
% \item[xspace] provides the command |\xspace| |
| 337 |
% \item[changepage] is used to correctly shift figure* and table*. It has |
| 338 |
% to use the option [strict] to work properly. This might lead to an |
| 339 |
% option clash, if the same package is loaded without this option. |
| 340 |
% \item[ifoddpage] provides the command |\ifoddpage| |
| 341 |
% \item[etoolbox] provides the command |\patchcmd| |
| 342 |
% \item[calc] provides calculation such as adding lengths |
| 343 |
% \item[ragged2e] if |Ragged| option is used, and provides hyphenation |
| 344 |
% to prevent very short lines |
| 345 |
% |
| 346 |
% \end{description}% |
| 347 |
|
| 348 |
% |
| 349 |
% \StopEventually{} |
| 350 |
% |
| 351 |
% \section{Implementation} |
| 352 |
% |
| 353 |
% \iffalse |
| 354 |
%<*package> |
| 355 |
% \fi |
| 356 |
% |
| 357 |
% \begin{macrocode} |
| 358 |
\newcommand \snptest {{\upshape Figure \thefigure:} And some text\xspace} |
| 359 |
|
| 360 |
\ExplSyntaxOn |
| 361 |
\DeclareExpandableDocumentCommand{\IfNoValueOrEmptyTF}{ m m m } |
| 362 |
{ |
| 363 |
\IfNoValueTF{#1} |
| 364 |
{#2} |
| 365 |
{\tl_if_empty:nTF {#1} {#2} {#3}} |
| 366 |
} |
| 367 |
\setcounter{topnumber}{4} |
| 368 |
\setcounter{bottomnumber}{4} |
| 369 |
\setcounter{totalnumber}{8} |
| 370 |
% \end{macrocode} |
| 371 |
% |
| 372 |
% \begin{macro}{\snp@sidenoteformat} |
| 373 |
% -- |
| 374 |
% |
| 375 |
% \begin{macrocode} |
| 376 |
\NewDocumentCommand \snp@sidenoteformat {} {% |
| 377 |
\snp@size\snp@shape\snp@font\leavevmode% |
| 378 |
\lineskip=0pt \lineskiplimit=0pt % |
| 379 |
\tolerance=2000 \hyphenpenalty=300 \exhyphenpenalty=300% |
| 380 |
\doublehyphendemerits=300% |
| 381 |
\finalhyphendemerits=\doublehyphendemerits |
| 382 |
} |
| 383 |
\NewDocumentCommand \snp@sideformat {} {} |
| 384 |
\NewDocumentCommand \snp@sidecolor {} {} |
| 385 |
|
| 386 |
% \end{macrocode} |
| 387 |
% \end{macro} |
| 388 |
% |
| 389 |
% \begin{macro}{-} |
| 390 |
% -- |
| 391 |
% \begin{macrocode} |
| 392 |
\NewDocumentCommand \snp@symbol {} {\alph} |
| 393 |
\NewDocumentCommand \snp@alertsymbol {} {\arabic} |
| 394 |
\NewDocumentCommand \snp@font {} {} |
| 395 |
\NewDocumentCommand \snp@shape{} {\itshape} |
| 396 |
\NewDocumentCommand \snp@size {} {\footnotesize} |
| 397 |
\NewDocumentCommand \snp@leftmarginstyle{} {} |
| 398 |
\NewDocumentCommand \snp@rightmarginstyle{} {} |
| 399 |
% |
| 400 |
% |
| 401 |
\bool_new:N \l@snp@margincaption |
| 402 |
\bool_new:N \l@snp@alerton |
| 403 |
\bool_new:N \l@snp@alertmarkon |
| 404 |
\bool_new:N \l@snp@ragged |
| 405 |
\bool_new:N \l@snp@Ragged |
| 406 |
\bool_new:N \l@snp@symmetric |
| 407 |
\bool_new:N \l@snp@page |
| 408 |
\bool_new:N \l@snp@counterset |
| 409 |
|
| 410 |
\bool_set_false:N \l@snp@margincaption |
| 411 |
\bool_set_false:N \l@snp@alerton |
| 412 |
\bool_set_false:N \l@snp@alertmarkon |
| 413 |
\bool_set_false:N \l@snp@ragged |
| 414 |
\bool_set_false:N \l@snp@Ragged |
| 415 |
\bool_set_true:N \l@snp@symmetric |
| 416 |
\bool_set_false:N \l@snp@counterset |
| 417 |
|
| 418 |
|
| 419 |
% |
| 420 |
\newlength{\snp@marginsepdiff} |
| 421 |
\setlength{\snp@marginsepdiff}{1ex} |
| 422 |
% \end{macrocode} |
| 423 |
%\end{macro} |
| 424 |
|
| 425 |
% \begin{macrocode} |
| 426 |
\keys_define:nn { sidenoteplus } |
| 427 |
{ |
| 428 |
mark .code:n = \str_case:nn {#1}% |
| 429 |
{ {fnsymbol}{\RenewDocumentCommand \snp@symbol {}{\fnsymbol}}% |
| 430 |
{Alph}{\RenewDocumentCommand \snp@symbol {}{\Alph}}% |
| 431 |
{arabic}{\RenewDocumentCommand \snp@symbol {}{\arabic} |
| 432 |
\RenewDocumentCommand \snp@alertsymbol {} {\alph}}% |
| 433 |
{Roman}{\RenewDocumentCommand \snp@symbol {}{\Roman}}% |
| 434 |
{roman}{\RenewDocumentCommand \snp@symbol {}{\roman}}% |
| 435 |
{Other}{} }, |
| 436 |
font .code:n = \str_case:nn {#1}% |
| 437 |
{ {sf}{\RenewDocumentCommand \snp@font {}{\sffamily}}% |
| 438 |
{Other}{} }, |
| 439 |
size .code:n = \str_case:nn {#1}% |
| 440 |
{ {small}{\RenewDocumentCommand \snp@size {}{\small}}% |
| 441 |
{script}{\RenewDocumentCommand \snp@size {}{\scriptsize}}% |
| 442 |
{normal}{\RenewDocumentCommand \snp@size {}{\normalsize}}% |
| 443 |
{Other}{} }, |
| 444 |
shape .code:n = \str_case:nn {#1}% |
| 445 |
{ {sl}{\RenewDocumentCommand \snp@shape{}{\slshape}}% |
| 446 |
{up}{\RenewDocumentCommand \snp@shape{}{\upshape}}% |
| 447 |
{it}{\RenewDocumentCommand \snp@shape{}{\itshape}}% |
| 448 |
{Other}{} }, |
| 449 |
per .code:n = \str_case:nn {#1}% |
| 450 |
{ {page}{ \newcounter{sidenote}[page] % make a counter% |
| 451 |
\newcounter{sidealert}[page] |
| 452 |
\bool_set_true:N \l@snp@counterset } % init the counter% |
| 453 |
{section}{ \newcounter{sidenote}[section] % |
| 454 |
\newcounter{sidealert}[section] |
| 455 |
\bool_set_true:N \l@snp@counterset }% |
| 456 |
{chapter}{ \newcounter{sidenote}[chapter] % |
| 457 |
\newcounter{sidealert}[chapter] |
| 458 |
\bool_set_true:N \l@snp@counterset } % |
| 459 |
{none}{ \newcounter{sidenote}% |
| 460 |
\newcounter{sidealert} |
| 461 |
\bool_set_true:N \l@snp@counterset } % |
| 462 |
{Other}{} % |
| 463 |
}, |
| 464 |
sepdiff .code:n = \setlength{\snp@marginsepdiff}{#1}, |
| 465 |
classic .code:n = \bool_set_false:N \l@snp@symmetric, |
| 466 |
ragged .code:n = { \RenewDocumentCommand \snp@leftmarginstyle {}{\raggedleft} |
| 467 |
\RenewDocumentCommand \snp@rightmarginstyle {}{\raggedright} |
| 468 |
\bool_set_true:N \l@snp@ragged }, |
| 469 |
Ragged .code:n = { \RenewDocumentCommand \snp@leftmarginstyle {}{\RaggedLeft} |
| 470 |
\RenewDocumentCommand \snp@rightmarginstyle {}{\RaggedRight} |
| 471 |
\bool_set_true:N \l@snp@Ragged |
| 472 |
\bool_set_true:N \l@snp@ragged }, |
| 473 |
alerton .code:n = {\bool_set_true:N \l@snp@alerton}, |
| 474 |
} |
| 475 |
\ProcessKeysOptions { sidenoteplus } |
| 476 |
\bool_if:NTF \l@snp@Ragged |
| 477 |
{ |
| 478 |
\@ifpackageloaded{ragged2e} |
| 479 |
{\relax}{\RequirePackage{ragged2e}} |
| 480 |
} |
| 481 |
{\relax} |
| 482 |
\bool_if:NTF \l@snp@ragged |
| 483 |
{\setlength{\snp@marginsepdiff}{0pt} \bool_set_false:N \l@snp@symmetric} |
| 484 |
{\relax} |
| 485 |
\bool_if:NTF \l@snp@symmetric {\setlength{\snp@marginsepdiff}{0pt}}{\relax} |
| 486 |
|
| 487 |
\bool_if:NTF \l@snp@counterset |
| 488 |
{\relax} |
| 489 |
{\newcounter{sidenote}[page] % make a counter% |
| 490 |
\newcounter{sidealert}[page] |
| 491 |
\bool_set_true:N \l@snp@counterset } |
| 492 |
|
| 493 |
\setcounter{sidenote}{0} % init the counter% |
| 494 |
\setcounter{sidealert}{0} % init the counter |
| 495 |
% \end{macrocode} |
| 496 |
% |
| 497 |
% \begin{macro}{\snp@putmarkintext} |
| 498 |
% -- |
| 499 |
% |
| 500 |
% \begin{macrocode} |
| 501 |
\NewDocumentCommand \snp@putmarkintext { m } |
| 502 |
{ |
| 503 |
\leavevmode |
| 504 |
\ifhmode |
| 505 |
\edef \x@sf {\the \spacefactor } |
| 506 |
\nobreak |
| 507 |
\fi |
| 508 |
\bool_if:NTF \l@snp@alertmarkon |
| 509 |
{\makebox[0pt]{\raisebox{0.3ex}{\textsuperscript {\normalfont \bf ---~{#1}~---\kern-0.6ex }}}} |
| 510 |
{\hbox {\textsuperscript {\normalfont #1 }}} |
| 511 |
\ifhmode |
| 512 |
\spacefactor \x@sf |
| 513 |
\fi |
| 514 |
\relax |
| 515 |
} |
| 516 |
% \end{macrocode} |
| 517 |
% \end{macro} |
| 518 |
% |
| 519 |
% |
| 520 |
% |
| 521 |
% \begin{macro}{\snp@multisign} |
| 522 |
% -- |
| 523 |
% |
| 524 |
% \begin{macrocode} |
| 525 |
\NewDocumentCommand \snp@multisign { } {3sp} |
| 526 |
% \end{macrocode} |
| 527 |
% \end{macro} |
| 528 |
% |
| 529 |
% |
| 530 |
% \begin{macro}{\snp@multimarker} |
| 531 |
% -- |
| 532 |
% |
| 533 |
% \begin{macrocode} |
| 534 |
\NewDocumentCommand \snp@multimarker { } |
| 535 |
{ |
| 536 |
\kern-\snp@multisign |
| 537 |
\kern\snp@multisign\relax |
| 538 |
} |
| 539 |
% \end{macrocode} |
| 540 |
% \end{macro} |
| 541 |
% |
| 542 |
% |
| 543 |
% \begin{macro}{\snp@multichecker} |
| 544 |
% -- |
| 545 |
% |
| 546 |
% \begin{macrocode} |
| 547 |
\NewDocumentCommand \snp@multichecker { } |
| 548 |
{ |
| 549 |
\dim_compare:nNnTF \lastkern = \snp@multisign |
| 550 |
{\snp@putmarkintext{,}} |
| 551 |
{} |
| 552 |
} |
| 553 |
% \end{macrocode} |
| 554 |
% \end{macro} |
| 555 |
% |
| 556 |
% |
| 557 |
% \begin{environment}{@snp@llr} |
| 558 |
% -- |
| 559 |
% |
| 560 |
% \begin{macrocode} |
| 561 |
\NewDocumentEnvironment{@snp@llr} {}% |
| 562 |
{ |
| 563 |
\setlength{\parindent}{0pt} |
| 564 |
\setlength{\leftskip}{0pt plus 1fil} |
| 565 |
\setlength{\rightskip}{0pt plus -1fil} |
| 566 |
}{\par} |
| 567 |
% \end{macrocode} |
| 568 |
% \end{environment} |
| 569 |
% |
| 570 |
% |
| 571 |
% \begin{macro}{\marginpar} |
| 572 |
% \begin{macrocode} |
| 573 |
\let\oldmarginpar\marginpar |
| 574 |
\renewcommand{\marginpar}[2][]{ |
| 575 |
\if\relax\detokenize{#1}\relax |
| 576 |
\oldmarginpar[\snp@leftmarginstyle\snp@sidenoteformat{#2}]% |
| 577 |
{\snp@rightmarginstyle\snp@sidenoteformat{#2}}% |
| 578 |
\else%two parameters, let them use their styling |
| 579 |
\oldmarginpar[{#1}]{#2}% |
| 580 |
\fi% |
| 581 |
} |
| 582 |
% \end{macrocode} |
| 583 |
% \end{macro} |
| 584 |
% |
| 585 |
% |
| 586 |
% \begin{macro}{\snp@placemarginal} |
| 587 |
% -- |
| 588 |
% |
| 589 |
% \begin{macrocode} |
| 590 |
\renewcommand*{\raggedleftmarginnote}{} |
| 591 |
\renewcommand*{\raggedrightmarginnote}{} |
| 592 |
\renewcommand*{\marginfont}{} |
| 593 |
|
| 594 |
\NewDocumentCommand \snp@placemarginal {d!! m m } |
| 595 |
{ |
| 596 |
\IfNoValueOrEmptyTF{#1} |
| 597 |
{ |
| 598 |
\if@twoside |
| 599 |
\snp@isoddpage |
| 600 |
{ |
| 601 |
\IfNoValueOrEmptyTF{#2} |
| 602 |
{\marginpar{ #3 }} |
| 603 |
{\marginnote{\snp@sidenoteformat #3}[#2]} |
| 604 |
} |
| 605 |
{ |
| 606 |
\bool_if:NTF \l@snp@symmetric |
| 607 |
{ |
| 608 |
\IfNoValueOrEmptyTF{#2} |
| 609 |
{\marginpar{\begin{@snp@llr} #3\end{@snp@llr}}} |
| 610 |
{\marginnote{\begin{@snp@llr}\snp@sidenoteformat #3\end{@snp@llr}}[#2]} |
| 611 |
} |
| 612 |
|
| 613 |
{ |
| 614 |
\IfNoValueOrEmptyTF{#2} |
| 615 |
{\marginpar{ #3}} |
| 616 |
{\marginnote{\snp@sidenoteformat #3}[#2]} |
| 617 |
} |
| 618 |
} |
| 619 |
\else |
| 620 |
\IfNoValueOrEmptyTF{#2} |
| 621 |
{\marginpar{ #3}} |
| 622 |
{\marginnote{\snp@sidenoteformat #3}[#2]} |
| 623 |
\fi |
| 624 |
} |
| 625 |
{ |
| 626 |
\if@twoside |
| 627 |
\snp@isoddpage |
| 628 |
{ |
| 629 |
\IfNoValueOrEmptyTF{#2} |
| 630 |
{\marginpar{ \textcolor{#1}{#3} }} |
| 631 |
{\marginnote{\snp@sidenoteformat \textcolor{#1}{#3}}[#2]} |
| 632 |
} |
| 633 |
{ |
| 634 |
\bool_if:NTF \l@snp@symmetric |
| 635 |
{ |
| 636 |
\IfNoValueOrEmptyTF{#2} |
| 637 |
{\marginpar{\begin{@snp@llr} \textcolor{#1}{#3}\end{@snp@llr}}} |
| 638 |
{\marginnote{\begin{@snp@llr}\snp@sidenoteformat \textcolor{#1}{#3}\end{@snp@llr}}[#2]} |
| 639 |
} |
| 640 |
{ |
| 641 |
\IfNoValueOrEmptyTF{#2} |
| 642 |
{\marginpar{\textcolor{#1}{#3}}} |
| 643 |
{\marginnote{ \snp@sidenoteformat \textcolor{#1}{#3}}[#2]} |
| 644 |
} |
| 645 |
} |
| 646 |
\else |
| 647 |
\IfNoValueOrEmptyTF{#2} |
| 648 |
{\marginpar{ \textcolor{#1}{#3}}} |
| 649 |
{\marginnote{ \snp@sidenoteformat \textcolor{#1}{#3}}[#2]} |
| 650 |
\fi |
| 651 |
} |
| 652 |
} |
| 653 |
% \end{macrocode} |
| 654 |
% \end{macro} |
| 655 |
% |
| 656 |
% |
| 657 |
% |
| 658 |
% \begin{macro}{\sidepar} |
| 659 |
% -- |
| 660 |
% \begin{macrocode} |
| 661 |
\NewDocumentCommand \sidepar {} |
| 662 |
{ |
| 663 |
\\\makebox[1em]{} |
| 664 |
} |
| 665 |
% \end{macrocode} |
| 666 |
% \end{macro} |
| 667 |
% |
| 668 |
% \begin{macro}{\sidenote} |
| 669 |
% -- |
| 670 |
% |
| 671 |
% \begin{macrocode} |
| 672 |
\NewDocumentCommand \sidenote {s d|| d<> d() d!! m } |
| 673 |
{ |
| 674 |
\IfBooleanTF{#1} |
| 675 |
{ % starred |
| 676 |
\snp@sidenotemark*(#4) |
| 677 |
\snp@sidenotetext[*]|#2|<#3>(#4)!#5!{#6} |
| 678 |
}{ % unstarred |
| 679 |
\IfNoValueOrEmptyTF{#5} { |
| 680 |
\snp@sidenotemark(#4) |
| 681 |
\snp@sidenotetext[]|#2|<#3>(#4)!#5!{#6} |
| 682 |
\snp@multimarker } |
| 683 |
{ |
| 684 |
\snp@sidenotemark(#4)!#5! |
| 685 |
\snp@sidenotetext[]|#2|<#3>(#4)!#5!{#6} |
| 686 |
\snp@multimarker } |
| 687 |
|
| 688 |
} |
| 689 |
} |
| 690 |
% \end{macrocode} |
| 691 |
% \end{macro} |
| 692 |
% |
| 693 |
% \begin{macro}{\sidealert} |
| 694 |
% -- |
| 695 |
% |
| 696 |
% \begin{macrocode} |
| 697 |
\NewDocumentCommand \sidealert {s d|| d<> d() d!! m } |
| 698 |
{ |
| 699 |
\bool_if:NTF \l@snp@alerton |
| 700 |
{ |
| 701 |
\bool_set_true:N \l@snp@alertmarkon |
| 702 |
\IfNoValueOrEmptyTF{#5} |
| 703 |
{ |
| 704 |
\IfBooleanTF{#1} |
| 705 |
{ % starred |
| 706 |
\snp@sidenotemark*(#4) |
| 707 |
\snp@sidenotetext[*]|#2|<#3>(#4)!Red!{#6} |
| 708 |
}{ % unstarred |
| 709 |
\snp@sidenotemark(#4)!Red!{} |
| 710 |
\snp@sidenotetext[]|#2|<#3>(#4)!Red!{#6} |
| 711 |
\snp@multimarker |
| 712 |
} |
| 713 |
}{ \IfBooleanTF{#1} |
| 714 |
{ % starred |
| 715 |
\snp@sidenotemark*(#4) |
| 716 |
\snp@sidenotetext[*]|#2|<#3>(#4)!#5!{#6} |
| 717 |
}{ % unstarred |
| 718 |
\snp@sidenotemark(#4)!#5!{} |
| 719 |
\snp@sidenotetext[]|#2|<#3>(#4)!#5!{#6} |
| 720 |
\snp@multimarker |
| 721 |
} |
| 722 |
} |
| 723 |
} |
| 724 |
{\relax} |
| 725 |
\bool_set_false:N \l@snp@alertmarkon |
| 726 |
} |
| 727 |
% \end{macrocode} |
| 728 |
% \end{macro} |
| 729 |
% |
| 730 |
% |
| 731 |
% |
| 732 |
% |
| 733 |
% \begin{macro}{\sidenotemark} |
| 734 |
% -- |
| 735 |
% |
| 736 |
% \begin{macrocode} |
| 737 |
\NewDocumentCommand \sidenotemark {s d() d!! } |
| 738 |
{ |
| 739 |
\IfBooleanTF{#1} |
| 740 |
{ % starred |
| 741 |
\relax} |
| 742 |
{% unstarred |
| 743 |
\IfNoValueOrEmptyTF{#3} |
| 744 |
{\snp@sidenotemark (#2)} |
| 745 |
{\snp@sidenotemark !#3!( #2)} |
| 746 |
} |
| 747 |
\xspace |
| 748 |
} |
| 749 |
% \end{macrocode} |
| 750 |
% \end{macro} |
| 751 |
% |
| 752 |
% |
| 753 |
% \begin{macro}{\snp@sidenotemark} |
| 754 |
% -- |
| 755 |
% |
| 756 |
% \begin{macrocode} |
| 757 |
\NewDocumentCommand \snp@symbolnoteoralert {}{} |
| 758 |
\NewDocumentCommand \snp@sidenotemark {s d() d!! } |
| 759 |
{ |
| 760 |
\IfBooleanTF{#1} |
| 761 |
{ % starred |
| 762 |
\relax} |
| 763 |
{% unstarred |
| 764 |
\snp@multichecker |
| 765 |
\bool_if:NTF \l@snp@alertmarkon |
| 766 |
{ \refstepcounter{sidealert} |
| 767 |
\RenewDocumentCommand \snp@symbolnoteoralert {}{\snp@alertsymbol{sidealert}} } |
| 768 |
{ \refstepcounter{sidenote} |
| 769 |
\RenewDocumentCommand \snp@symbolnoteoralert {}{\snp@symbol{sidenote}} } |
| 770 |
\IfNoValueOrEmptyTF{#3} |
| 771 |
{ |
| 772 |
\IfNoValueOrEmptyTF{#2} |
| 773 |
{ \snp@putmarkintext{\snp@symbolnoteoralert } } |
| 774 |
{ \snp@putmarkintext{#2} } |
| 775 |
}{ |
| 776 |
\IfNoValueOrEmptyTF{#2} |
| 777 |
{ \textcolor{#3} {\snp@putmarkintext{\snp@symbolnoteoralert}} } |
| 778 |
{ \textcolor{#3} {\snp@putmarkintext{#2}} } |
| 779 |
} |
| 780 |
\snp@multimarker |
| 781 |
} |
| 782 |
} |
| 783 |
% \end{macrocode} |
| 784 |
% \end{macro} |
| 785 |
% |
| 786 |
% \begin{macro}{\snp@onelineup} |
| 787 |
% -- |
| 788 |
% |
| 789 |
% \begin{macrocode} |
| 790 |
\NewDocumentCommand{\snp@onelineup}{} |
| 791 |
{\par \vspace*{-1\baselineskip}} |
| 792 |
\NewDocumentCommand{\snp@onexlineup}{} |
| 793 |
{\par \vspace*{-1.5\baselineskip}} |
| 794 |
% \end{macrocode} |
| 795 |
% \end{macro} |
| 796 |
% |
| 797 |
% \begin{macro}{\snp@leftnotelabel} |
| 798 |
% -- |
| 799 |
% |
| 800 |
% \begin{macrocode} |
| 801 |
\NewDocumentCommand{\snp@leftnotelabel}{ m } |
| 802 |
{\makebox[0em][l]{\hspace*{0.9ex}#1}} |
| 803 |
% \end{macrocode} |
| 804 |
% \end{macro} |
| 805 |
% |
| 806 |
% \begin{macro}{\snp@rightnotelabel} |
| 807 |
% -- |
| 808 |
% |
| 809 |
% \begin{macrocode} |
| 810 |
\NewDocumentCommand{\snp@rightnotelabel}{ m } |
| 811 |
{\makebox[0em][r]{#1\hspace*{0.9ex}}} |
| 812 |
% \end{macrocode} |
| 813 |
% \end{macro} |
| 814 |
% |
| 815 |
% \begin{macro}{\snp@justifiedleftnotelabel} |
| 816 |
% -- |
| 817 |
% |
| 818 |
% \begin{macrocode} |
| 819 |
\NewDocumentCommand{\snp@justifiedleftnotelabel}{ m } |
| 820 |
{\makebox[0em][l]{\hspace*{\marginparwidth+0.9ex}#1}} |
| 821 |
% \end{macrocode} |
| 822 |
% \end{macro} |
| 823 |
% |
| 824 |
% \begin{macro}{\sidenotetext} |
| 825 |
% -- |
| 826 |
% |
| 827 |
% \begin{macrocode} |
| 828 |
\NewDocumentCommand \sidenotetext {s d|| d<> d() d!! m } { |
| 829 |
\IfBooleanTF{#1} |
| 830 |
{ \snp@sidenotetext[*]|#2|<#3>(#4)!#5!{#6} } |
| 831 |
{ \snp@sidenotetext[]|#2|<#3>(#4)!#5!{#6} } |
| 832 |
} |
| 833 |
% \end{macrocode} |
| 834 |
% \end{macro} |
| 835 |
% |
| 836 |
% |
| 837 |
% \begin{macro}{\sidenotetextbefore} |
| 838 |
% -- |
| 839 |
% |
| 840 |
% \begin{macrocode} |
| 841 |
\NewDocumentCommand \sidenotetextbefore {s d|| d<> d() d!! m } { |
| 842 |
\refstepcounter{sidenote} |
| 843 |
\IfBooleanTF{#1} |
| 844 |
{ \snp@sidenotetext[*]|#2|<#3>(#4)!#5!{#6} } |
| 845 |
{ \snp@sidenotetext[]|#2|<#3>(#4)!#5!{#6} } |
| 846 |
\addtocounter{sidenote}{-1} |
| 847 |
} |
| 848 |
% \end{macrocode} |
| 849 |
% \end{macro} |
| 850 |
% |
| 851 |
% \begin{macrocode} |
| 852 |
\DeclareExpandableDocumentCommand{\IfsTF}{ m m m } |
| 853 |
{ |
| 854 |
\IfNoValueTF{#1} |
| 855 |
{#2} |
| 856 |
{\tl_if_empty:nTF {#1} {#2} {#3}} |
| 857 |
} |
| 858 |
% \end{macrocode} |
| 859 |
% -- |
| 860 |
% |
| 861 |
% \begin{macrocode} |
| 862 |
\newlength{\d@snp@offset} |
| 863 |
% \end{macrocode} |
| 864 |
% |
| 865 |
% \begin{macro}{\snp@sidenotetext} |
| 866 |
% -- |
| 867 |
% |
| 868 |
% \begin{macrocode} |
| 869 |
\NewDocumentCommand \snp@sidenotesymbol {}{} |
| 870 |
\NewDocumentCommand \snp@sidenotetext {o d|| d<> d() d!! m } { |
| 871 |
\bool_if:NTF \l@snp@alertmarkon |
| 872 |
{ |
| 873 |
\IfNoValueOrEmptyTF{#4} |
| 874 |
{\RenewDocumentCommand \snp@sidenotesymbol {}{-~\snp@alertsymbol{sidealert}~-}} |
| 875 |
{\RenewDocumentCommand \snp@sidenotesymbol {}{-~#4~-}} |
| 876 |
} |
| 877 |
{ |
| 878 |
\IfNoValueOrEmptyTF{#4} |
| 879 |
{\RenewDocumentCommand \snp@sidenotesymbol {}{\snp@symbol{sidenote}}} |
| 880 |
{\RenewDocumentCommand \snp@sidenotesymbol {}{#4}} |
| 881 |
} |
| 882 |
\IfNoValueOrEmptyTF{#2} |
| 883 |
{\relax} |
| 884 |
{\setlength{\d@snp@offset}{#2} \vspace*{ \d@snp@offset }} |
| 885 |
\bool_if:NTF \l@snp@ragged |
| 886 |
{ |
| 887 |
\if@twoside |
| 888 |
\snp@isoddpage |
| 889 |
{%odd page |
| 890 |
{ \snp@placemarginal!#5!{#3}%-- |
| 891 |
{\snp@rightnotelabel{% |
| 892 |
\normalfont\IfsTF{#1}{\snp@sidenotesymbol}{\relax}}#6} |
| 893 |
} |
| 894 |
} |
| 895 |
{%even page |
| 896 |
{\snp@placemarginal!#5!{#3}%-- |
| 897 |
{\snp@justifiedleftnotelabel{\normalfont% |
| 898 |
\IfsTF{#1}{\snp@sidenotesymbol}{\relax}} |
| 899 |
\hspace*{\marginparwidth} \snp@onelineup#6} |
| 900 |
} |
| 901 |
} |
| 902 |
\else %not twoside |
| 903 |
{\snp@placemarginal!#5!{#3}%-- |
| 904 |
{\snp@rightnotelabel{\normalfont% |
| 905 |
\IfsTF{#1}{\snp@sidenotesymbol}{\relax}}#6} |
| 906 |
} |
| 907 |
\fi % ends if@twoside |
| 908 |
} |
| 909 |
{ |
| 910 |
\if@twoside |
| 911 |
\snp@isoddpage |
| 912 |
{%odd page |
| 913 |
{\snp@placemarginal!#5!{#3}%-- |
| 914 |
{\snp@rightnotelabel{ |
| 915 |
\normalfont\IfsTF{#1}{\snp@sidenotesymbol}{\relax}}#6} |
| 916 |
} |
| 917 |
} |
| 918 |
{%even page |
| 919 |
\bool_if:NTF \l@snp@symmetric |
| 920 |
{ |
| 921 |
{\snp@placemarginal!#5!{#3}%-- |
| 922 |
{\snp@justifiedleftnotelabel{ |
| 923 |
\normalfont\IfsTF{#1}{\snp@sidenotesymbol}{\relax} } |
| 924 |
\hspace*{\marginparwidth}\snp@onelineup#6 |
| 925 |
} |
| 926 |
} |
| 927 |
} |
| 928 |
{ |
| 929 |
{ \snp@placemarginal!#5!{#3}%-- |
| 930 |
{\snp@rightnotelabel{ |
| 931 |
\normalfont\IfsTF{#1}{\snp@sidenotesymbol}{\relax}}#6 } |
| 932 |
} |
| 933 |
} |
| 934 |
} |
| 935 |
\else |
| 936 |
{ \snp@placemarginal!#5!{#3}%-- |
| 937 |
{\snp@rightnotelabel{ |
| 938 |
\normalfont\IfsTF{#1}{\snp@sidenotesymbol}{\relax}}#6} |
| 939 |
} |
| 940 |
\fi |
| 941 |
} |
| 942 |
\IfNoValueOrEmptyTF{#2} |
| 943 |
{\relax} |
| 944 |
{ \setlength{\d@snp@offset}{#2 *(-1)} \vspace*{{\d@snp@offset}}} |
| 945 |
} |
| 946 |
% \end{macrocode} |
| 947 |
% \end{macro} |
| 948 |
% |
| 949 |
% |
| 950 |
% \begin{macro}{\snp@raggedcaption} |
| 951 |
% -- |
| 952 |
% \begin{macrocode} |
| 953 |
|
| 954 |
\NewDocumentCommand \snp@raggedcaption {m } |
| 955 |
{ |
| 956 |
\if@twoside |
| 957 |
\snp@isoddpage {#1} |
| 958 |
{\bool_if:NTF \l@snp@symmetric {\begin{@snp@llr}#1\end{@snp@llr}} {#1}} |
| 959 |
\else #1 \fi |
| 960 |
} |
| 961 |
% \end{macrocode} |
| 962 |
% \end{macro} |
| 963 |
% |
| 964 |
% |
| 965 |
% |
| 966 |
% \begin{macrocode} |
| 967 |
\DeclareCaptionStyle{sidecaption}{font=footnotesize} |
| 968 |
% \end{macrocode} |
| 969 |
% |
| 970 |
% \begin{macro}{\sidecaption} |
| 971 |
% -- |
| 972 |
% |
| 973 |
% \begin{macrocode} |
| 974 |
\NewDocumentCommand \snp@entrycap {} {} |
| 975 |
\NewDocumentCommand \snp@offsetcap {} {} |
| 976 |
\NewDocumentCommand \sidecaption {s d|| d<> d!! o m} { |
| 977 |
\captionsetup{style=sidecaption} |
| 978 |
\IfBooleanTF{#1} |
| 979 |
{ %starred |
| 980 |
\marginnote{\caption*{\snp@raggedcaption{#6}}} |
| 981 |
[\IfNoValueOrEmptyTF{#3} {0pt} {#3}] |
| 982 |
} |
| 983 |
{ %unstarred |
| 984 |
\marginnote{\caption[\IfNoValueOrEmptyTF{#5} {#6} {#5}] |
| 985 |
{\snp@raggedcaption{#6}}} |
| 986 |
[\IfNoValueOrEmptyTF{#3} {0pt} {#3}] |
| 987 |
} |
| 988 |
} |
| 989 |
% \end{macrocode} |
| 990 |
% \end{macro} |
| 991 |
% |
| 992 |
% |
| 993 |
% \begin{macro}{\istwosided} |
| 994 |
% -- |
| 995 |
% |
| 996 |
% \begin{macrocode} |
| 997 |
\NewDocumentCommand \istwosided {m m} { |
| 998 |
\if@twoside #1 \else #2 \raggedleft \fi |
| 999 |
} |
| 1000 |
% \end{macrocode} |
| 1001 |
% \end{macro} |
| 1002 |
% |
| 1003 |
% |
| 1004 |
% \begin{macro}{\raggedinner} |
| 1005 |
% -- |
| 1006 |
% |
| 1007 |
% \begin{macrocode} |
| 1008 |
\NewDocumentCommand \raggedinner {} { |
| 1009 |
\if@twoside |
| 1010 |
\snp@isoddpage {\raggedleft}{\raggedright} |
| 1011 |
\else |
| 1012 |
\raggedleft |
| 1013 |
\fi |
| 1014 |
} |
| 1015 |
% \end{macrocode} |
| 1016 |
% \end{macro} |
| 1017 |
% |
| 1018 |
% |
| 1019 |
% \begin{macro}{\raggedouter} |
| 1020 |
% -- |
| 1021 |
% |
| 1022 |
% \begin{macrocode} |
| 1023 |
\NewDocumentCommand \raggedouter {} { |
| 1024 |
\if@twoside |
| 1025 |
\snp@isoddpage {\raggedright}{\raggedleft} |
| 1026 |
\else |
| 1027 |
\raggedleft |
| 1028 |
\fi |
| 1029 |
} |
| 1030 |
% \end{macrocode} |
| 1031 |
% \end{macro} |
| 1032 |
% |
| 1033 |
|
| 1034 |
% \begin{macro}{\margincaption} |
| 1035 |
% -- |
| 1036 |
% \begin{macrocode} |
| 1037 |
\newlength \l@snp@belowcaption |
| 1038 |
\NewDocumentCommand \margincaption {s o m } |
| 1039 |
{ |
| 1040 |
\setlength \l@snp@belowcaption \belowcaptionskip |
| 1041 |
\setlength{\belowcaptionskip}{1ex plus 0.3ex minus -0.1ex} |
| 1042 |
\IfBooleanTF{#1} |
| 1043 |
{ %starred |
| 1044 |
\if@twoside |
| 1045 |
\snp@isoddpage |
| 1046 |
{ |
| 1047 |
\IfNoValueOrEmptyTF{#2} {\caption*{#3}} {\caption*[#2]{#3}} |
| 1048 |
} |
| 1049 |
{ |
| 1050 |
\bool_if:NTF \l@snp@symmetric |
| 1051 |
{ |
| 1052 |
\IfNoValueOrEmptyTF{#2} |
| 1053 |
{\caption*[#3]{\begin{@snp@llr}#3\end{@snp@llr}}} |
| 1054 |
{\caption*[#2]{\begin{@snp@llr}#3\end{@snp@llr}}} |
| 1055 |
} |
| 1056 |
{ |
| 1057 |
\IfNoValueOrEmptyTF{#2} {\caption*{#3}} {\caption*[#2]{#3}} |
| 1058 |
} |
| 1059 |
} |
| 1060 |
\else |
| 1061 |
\IfNoValueOrEmptyTF{#2} {\caption*{#3}} {\caption*[#2]{#3}} |
| 1062 |
\fi |
| 1063 |
} |
| 1064 |
{ %unstarred |
| 1065 |
\if@twoside |
| 1066 |
\snp@isoddpage |
| 1067 |
{ |
| 1068 |
\IfNoValueOrEmptyTF{#2} {\caption{#3}} {\caption[#2]{#3}} |
| 1069 |
} |
| 1070 |
{ |
| 1071 |
\bool_if:NTF \l@snp@symmetric |
| 1072 |
{ |
| 1073 |
\IfNoValueOrEmptyTF{#2} |
| 1074 |
{\caption[#3]{\begin{@snp@llr}#3\end{@snp@llr}}} |
| 1075 |
{\caption[#2]{\begin{@snp@llr}#3\end{@snp@llr}}} |
| 1076 |
} |
| 1077 |
{ |
| 1078 |
\IfNoValueOrEmptyTF{#2} {\caption{#3}} {\caption[#2]{#3}} |
| 1079 |
} |
| 1080 |
} |
| 1081 |
\else |
| 1082 |
\IfNoValueOrEmptyTF{#2} {\caption{#3}} {\caption[#2]{#3}} |
| 1083 |
\fi |
| 1084 |
} |
| 1085 |
\setlength \belowcaptionskip \l@snp@belowcaption |
| 1086 |
} |
| 1087 |
% \end{macrocode} |
| 1088 |
% \end{macro} |
| 1089 |
|
| 1090 |
% \begin{macrocode} |
| 1091 |
\newsavebox{\b@snp@marginfigurebox} |
| 1092 |
\DeclareCaptionStyle{marginfigure}{font=footnotesize,skip=1ex} |
| 1093 |
% \end{macrocode} |
| 1094 |
% |
| 1095 |
% \begin{environment}{marginfigure} |
| 1096 |
% -- |
| 1097 |
% |
| 1098 |
% \begin{macrocode} |
| 1099 |
\NewDocumentEnvironment{marginfigure} { d|| d<> } |
| 1100 |
{ % begin{} part |
| 1101 |
\begin{lrbox}{\b@snp@marginfigurebox} |
| 1102 |
\begin{minipage}{\marginparwidth} |
| 1103 |
\captionsetup{type=figure,style=marginfigure} |
| 1104 |
} |
| 1105 |
% \end{macrocode} |
| 1106 |
% \end{environment} |
| 1107 |
% |
| 1108 |
% \begin{macrocode} |
| 1109 |
{ % end{} part |
| 1110 |
\end{minipage}% |
| 1111 |
\end{lrbox}% |
| 1112 |
|
| 1113 |
\IfNoValueOrEmptyTF{#1} |
| 1114 |
{\relax} |
| 1115 |
{\setlength{\d@snp@offset}{#1} \vspace*{ \d@snp@offset }} |
| 1116 |
\snp@placemarginal{#2}{\usebox{\b@snp@marginfigurebox} } |
| 1117 |
%~\snp@onexlineup \snptest } |
| 1118 |
\IfNoValueOrEmptyTF{#1} |
| 1119 |
{\relax} |
| 1120 |
{ \setlength{\d@snp@offset}{#1 *(-1)} \vspace*{{\d@snp@offset}}} |
| 1121 |
} |
| 1122 |
% \end{macrocode} |
| 1123 |
% -- |
| 1124 |
% |
| 1125 |
% \upshape Figure \begin{macrocode} |
| 1126 |
\newsavebox{\b@snp@margintablebox} |
| 1127 |
\DeclareCaptionStyle{margintable}{font=footnotesize} |
| 1128 |
% \end{macrocode} |
| 1129 |
% |
| 1130 |
% \begin{environment}{margintable} |
| 1131 |
% -- |
| 1132 |
% |
| 1133 |
% \begin{macrocode} |
| 1134 |
\NewDocumentEnvironment{margintable} { d|| d<> d() } |
| 1135 |
{ % begin part |
| 1136 |
\begin{lrbox}{\b@snp@margintablebox} |
| 1137 |
\snp@sidenoteformat |
| 1138 |
\begin{minipage}{\marginparwidth} |
| 1139 |
\captionsetup{type=table,style=margintable} |
| 1140 |
} |
| 1141 |
% \end{macrocode} |
| 1142 |
% \end{environment} |
| 1143 |
% |
| 1144 |
% \begin{macrocode} |
| 1145 |
{ % end part |
| 1146 |
\end{minipage} |
| 1147 |
\end{lrbox} |
| 1148 |
\IfNoValueOrEmptyTF{#1} |
| 1149 |
{\relax} |
| 1150 |
{\setlength{\d@snp@offset}{#1} \vspace*{ \d@snp@offset }} |
| 1151 |
\snp@placemarginal{#2}{\usebox{\b@snp@margintablebox} } |
| 1152 |
\IfNoValueOrEmptyTF{#1} |
| 1153 |
{\relax} |
| 1154 |
{\setlength{\d@snp@offset}{#1 *(-1)} \vspace*{{\d@snp@offset}}} |
| 1155 |
% |
| 1156 |
|
| 1157 |
% |
| 1158 |
} |
| 1159 |
% \end{macrocode} |
| 1160 |
% -- |
| 1161 |
% |
| 1162 |
% \begin{macrocode} |
| 1163 |
\AtBeginDocument{% |
| 1164 |
\newlength{\d@snp@extrawidth} |
| 1165 |
\setlength{\d@snp@extrawidth}{\marginparwidth} |
| 1166 |
\addtolength{\d@snp@extrawidth}{\marginparsep} } |
| 1167 |
% \end{macrocode} |
| 1168 |
% |
| 1169 |
% \begin{macro}{\snp@isoddpage} |
| 1170 |
% -- |
| 1171 |
% |
| 1172 |
% \begin{macrocode} |
| 1173 |
\NewDocumentCommand \snp@isoddpage {m m} |
| 1174 |
{ \checkoddpage\ifoddpage #1 \else #2 \fi } |
| 1175 |
% \end{macrocode} |
| 1176 |
% \end{macro} |
| 1177 |
% |
| 1178 |
% \begin{environment}{@snp@autoadjustwidth} |
| 1179 |
% -- |
| 1180 |
% |
| 1181 |
% \begin{macrocode} |
| 1182 |
\NewDocumentEnvironment{@snp@autoadjustwidth}{ m m }% |
| 1183 |
{ % begin part |
| 1184 |
\begin{adjustwidth}{0pt}{0pt} |
| 1185 |
\if@twoside |
| 1186 |
\snp@isoddpage{\begin{adjustwidth}{#1}{-#2}}% |
| 1187 |
{\begin{adjustwidth}{-#2}{#1}} |
| 1188 |
\else |
| 1189 |
\begin{adjustwidth}{#1}{-#2} |
| 1190 |
\fi |
| 1191 |
} |
| 1192 |
% \end{macrocode} |
| 1193 |
% \end{environment} |
| 1194 |
% |
| 1195 |
% \begin{macrocode} |
| 1196 |
{ % end part |
| 1197 |
\end{adjustwidth}\end{adjustwidth} |
| 1198 |
} |
| 1199 |
% \end{macrocode} |
| 1200 |
% |
| 1201 |
% |
| 1202 |
% |
| 1203 |
% \begin{environment}{text*} |
| 1204 |
% -- |
| 1205 |
% |
| 1206 |
% \changes{v1.01}{2022/5/31}{added newsavebox and minipage} |
| 1207 |
% |
| 1208 |
% \begin{macrocode} |
| 1209 |
\newsavebox{\b@snp@textbox} |
| 1210 |
\NewDocumentEnvironment{text*}{ o }% |
| 1211 |
{ % begin part |
| 1212 |
\begin{adjustwidth}{0pt}{0pt} |
| 1213 |
\IfNoValueOrEmptyTF{#1} |
| 1214 |
{ |
| 1215 |
\if@twoside |
| 1216 |
\snp@isoddpage{\begin{adjustwidth}{0pt}{-\d@snp@extrawidth}}% |
| 1217 |
{\begin{adjustwidth}{-\d@snp@extrawidth}{0pt}} |
| 1218 |
\else |
| 1219 |
\begin{adjustwidth}{0pt}{-\d@snp@extrawidth} |
| 1220 |
\fi |
| 1221 |
} |
| 1222 |
{ |
| 1223 |
\if@twoside |
| 1224 |
\snp@isoddpage{\begin{adjustwidth}{0pt}{-#1\d@snp@extrawidth}}% |
| 1225 |
{\begin{adjustwidth}{-#1\d@snp@extrawidth}{0pt}} |
| 1226 |
\else |
| 1227 |
\begin{adjustwidth}{0pt}{-#1\d@snp@extrawidth} |
| 1228 |
\fi |
| 1229 |
} |
| 1230 |
\begin{lrbox}{\b@snp@textbox} |
| 1231 |
\begin{minipage}[]{\linewidth+1ex} |
| 1232 |
} |
| 1233 |
% \end{macrocode} |
| 1234 |
% \end{environment} |
| 1235 |
% |
| 1236 |
% \begin{macrocode} |
| 1237 |
{ % end part |
| 1238 |
\end{minipage} |
| 1239 |
\end{lrbox} |
| 1240 |
\usebox{\b@snp@textbox} |
| 1241 |
\end{adjustwidth}\end{adjustwidth} \snp@placemarginal{}{} |
| 1242 |
} |
| 1243 |
% \end{macrocode} |
| 1244 |
% |
| 1245 |
% \begin{environment}{figure*} |
| 1246 |
% \begin{macrocode} |
| 1247 |
\RenewDocumentEnvironment{figure*}{ O{htbp} } |
| 1248 |
{ |
| 1249 |
\begin{figure}[#1] |
| 1250 |
\begin{@snp@autoadjustwidth}{}{\d@snp@extrawidth} |
| 1251 |
\begin{minipage}[c]{\linewidth} |
| 1252 |
\centering |
| 1253 |
\captionsetup{ margin={\d@snp@extrawidth/2,\d@snp@extrawidth/2}} |
| 1254 |
}{ % end part |
| 1255 |
\end{minipage} |
| 1256 |
\end{@snp@autoadjustwidth} |
| 1257 |
\end{figure} |
| 1258 |
\snp@placemarginal{}{} |
| 1259 |
} |
| 1260 |
% \end{macrocode} |
| 1261 |
% \end{environment} |
| 1262 |
% |
| 1263 |
% \begin{environment}{table*} |
| 1264 |
% \begin{macrocode} |
| 1265 |
\RenewDocumentEnvironment{table*}{O{htbp} } |
| 1266 |
{ |
| 1267 |
\begin{table}[#1] |
| 1268 |
\begin{@snp@autoadjustwidth}{}{\d@snp@extrawidth} |
| 1269 |
\begin{minipage}[c]{\linewidth} |
| 1270 |
\centering |
| 1271 |
\captionsetup{ margin={\d@snp@extrawidth/2,\d@snp@extrawidth/2}} |
| 1272 |
}{ % end part |
| 1273 |
\end{minipage} |
| 1274 |
\end{@snp@autoadjustwidth} |
| 1275 |
\end{table} |
| 1276 |
} |
| 1277 |
% \end{macrocode} |
| 1278 |
% \end{environment} |
| 1279 |
% |
| 1280 |
% \begin{macro}{\sidecite} |
| 1281 |
% -- |
| 1282 |
% |
| 1283 |
% \begin{macrocode} |
| 1284 |
\NewDocumentCommand \snp@before {} {} |
| 1285 |
\NewDocumentCommand \snp@after {} {} |
| 1286 |
\NewDocumentCommand \sidecite {s d|| d<> d() d!! o o m } |
| 1287 |
% \end{macrocode} |
| 1288 |
% \end{macro} |
| 1289 |
% |
| 1290 |
% \begin{macrocode} |
| 1291 |
{ \IfNoValueOrEmptyTF{#6} |
| 1292 |
{\RenewDocumentCommand \snp@before {} {}} |
| 1293 |
{\RenewDocumentCommand \snp@before {} {#6}} |
| 1294 |
\IfNoValueOrEmptyTF{#7} |
| 1295 |
{ \DeclareDelimFormat{postnotedelim}{\addperiod} |
| 1296 |
\RenewDocumentCommand \snp@after {} {}} |
| 1297 |
{ \DeclareDelimFormat{postnotedelim}{\addcomma\space} |
| 1298 |
\RenewDocumentCommand \snp@after {} { #7}} |
| 1299 |
\sidenote|#2|<#3>(#4)!#5!{\kern-2.3pt\upshape\fullcite[\snp@before][\snp@after]{#8}} |
| 1300 |
} |
| 1301 |
% \end{macrocode} |
| 1302 |
% |
| 1303 |
% \begin{macro}{\sidecitet} |
| 1304 |
% -- |
| 1305 |
% |
| 1306 |
% \begin{macrocode} |
| 1307 |
\NewDocumentCommand \sidecitet {s d|| d<> d() d!! o o m } |
| 1308 |
{ \IfNoValueOrEmptyTF{#6} |
| 1309 |
{\RenewDocumentCommand \snp@before {} {}} |
| 1310 |
{\RenewDocumentCommand \snp@before {} {#6}} |
| 1311 |
\IfNoValueOrEmptyTF{#7} |
| 1312 |
{ \DeclareDelimFormat{postnotedelim}{\addperiod} |
| 1313 |
\RenewDocumentCommand \snp@after {} {}} |
| 1314 |
{ \DeclareDelimFormat{postnotedelim}{\addcomma\space} |
| 1315 |
\RenewDocumentCommand \snp@after {} { #7}} |
| 1316 |
\IfBooleanTF{#1} |
| 1317 |
{ |
| 1318 |
\citeauthor{#8}'s\sidenote|#2|<#3>(#4)!#5! |
| 1319 |
{\kern-2.3pt\upshape\fullcite[\snp@before][\snp@after]{#8}} |
| 1320 |
} |
| 1321 |
{ |
| 1322 |
\citeauthor{#8}\sidenote|#2|<#3>(#4)!#5! |
| 1323 |
{\kern-2.3pt\upshape\fullcite[\snp@before][\snp@after]{#8}} |
| 1324 |
} |
| 1325 |
} |
| 1326 |
% \end{macrocode} |
| 1327 |
% \end{macro} |
| 1328 |
% |
| 1329 |
% \begin{macro}{\sidecitebefore} |
| 1330 |
% -- |
| 1331 |
% |
| 1332 |
% \begin{macrocode} |
| 1333 |
\NewDocumentCommand \sidecitebefore {s d|| d<> d() d!! o o m } |
| 1334 |
% \end{macrocode} |
| 1335 |
% \end{macro} |
| 1336 |
% |
| 1337 |
% \begin{macrocode} |
| 1338 |
{ \IfNoValueOrEmptyTF{#6} |
| 1339 |
{\RenewDocumentCommand \snp@before {} {}} |
| 1340 |
{\RenewDocumentCommand \snp@before {} {#6}} |
| 1341 |
\IfNoValueOrEmptyTF{#7} |
| 1342 |
{ \DeclareDelimFormat{postnotedelim}{\addperiod} |
| 1343 |
\RenewDocumentCommand \snp@after {} {}} |
| 1344 |
{ \DeclareDelimFormat{postnotedelim}{\addcomma\space} |
| 1345 |
\RenewDocumentCommand \snp@after {} { #7}} |
| 1346 |
\sidenotetextbefore|#2|<#3>(#4)!#5!{\kern-2.3pt\upshape\fullcite[\snp@before][\snp@after]{#8}} |
| 1347 |
} |
| 1348 |
% \end{macrocode} |
| 1349 |
% |
| 1350 |
% \begin{macro}{\sideciteafter} |
| 1351 |
% -- |
| 1352 |
% |
| 1353 |
% \begin{macrocode} |
| 1354 |
\NewDocumentCommand \sideciteafter {s d|| d<> d() d!! o o m } |
| 1355 |
% \end{macrocode} |
| 1356 |
% \end{macro} |
| 1357 |
% |
| 1358 |
% \begin{macrocode} |
| 1359 |
{ \IfNoValueOrEmptyTF{#6} |
| 1360 |
{\RenewDocumentCommand \snp@before {} {}} |
| 1361 |
{\RenewDocumentCommand \snp@before {} {#6}} |
| 1362 |
\IfNoValueOrEmptyTF{#7} |
| 1363 |
{ \DeclareDelimFormat{postnotedelim}{\addperiod} |
| 1364 |
\RenewDocumentCommand \snp@after {} {}} |
| 1365 |
{ \DeclareDelimFormat{postnotedelim}{\addcomma\space} |
| 1366 |
\RenewDocumentCommand \snp@after {} { #7}} |
| 1367 |
\sidenotetext|#2|<#3>(#4)!#5!{\kern-2.3pt\upshape\fullcite[\snp@before][\snp@after]{#8}} |
| 1368 |
} |
| 1369 |
% \end{macrocode} |
| 1370 |
% |
| 1371 |
% |
| 1372 |
% \begin{macro}{\sidecitemark} |
| 1373 |
% -- |
| 1374 |
% |
| 1375 |
% \begin{macrocode} |
| 1376 |
\NewDocumentCommand \sidecitemark {s d() d!! } |
| 1377 |
{ |
| 1378 |
\IfBooleanTF{#1} |
| 1379 |
{ % starred |
| 1380 |
\relax} |
| 1381 |
{% unstarred |
| 1382 |
\IfNoValueOrEmptyTF{#3} |
| 1383 |
{\snp@sidenotemark (#2)} |
| 1384 |
{\snp@sidenotemark !#3!( #2)} |
| 1385 |
} |
| 1386 |
\xspace |
| 1387 |
} |
| 1388 |
% \end{macrocode} |
| 1389 |
% \end{macro} |
| 1390 |
% |
| 1391 |
% |
| 1392 |
% |
| 1393 |
\ExplSyntaxOff |
| 1394 |
% |
| 1395 |
%% |
| 1396 |
% \begin{macrocode} |
| 1397 |
\newlength\snp@marginparsepodd |
| 1398 |
\newlength\snp@marginparsepeven |
| 1399 |
|
| 1400 |
|
| 1401 |
\setlength{\snp@marginparsepodd}{\marginparsep} |
| 1402 |
\setlength{\snp@marginparsepeven}{\marginparsep-\snp@marginsepdiff} |
| 1403 |
|
| 1404 |
\makeatletter |
| 1405 |
\patchcmd{\@addmarginpar} % In this command |
| 1406 |
{\mph@orig@addmarginpar} % ... replace this... |
| 1407 |
{\if@twoside\ifodd\c@page\relax % ... with this |
| 1408 |
\marginparsep=\snp@marginparsepodd % Page is odd |
| 1409 |
\else |
| 1410 |
\marginparsep=\snp@marginparsepeven % Page is even |
| 1411 |
\fi |
| 1412 |
\else |
| 1413 |
\marginparsep=\snp@marginparsepodd |
| 1414 |
\fi |
| 1415 |
\mph@orig@addmarginpar} |
| 1416 |
{} % success |
| 1417 |
{\message{Error! Couldn't hook into command % failure |
| 1418 |
`\string\@addmarginpar'}} |
| 1419 |
|
| 1420 |
{%% Group to keep patching commands local |
| 1421 |
% |
| 1422 |
% Here we use a little trick to repeatedly patch the \@mn@@@marginnote |
| 1423 |
% command, replacing all instances of \kern\marginparsep with a |
| 1424 |
% conditional. We call \patch recursively each time on success, and stop |
| 1425 |
% when the patch fails (because all instances have been replaced). If the |
| 1426 |
% patch fails the first time, we show an error message. |
| 1427 |
\def\patcherr{% |
| 1428 |
\message{Error! Couldn't hook into command `\string\@mn@@@marginnote'}} |
| 1429 |
\def\patchok{% |
| 1430 |
\let\patcherr\relax % Only display error if first patch fails |
| 1431 |
\patch % Now patch again. |
| 1432 |
} |
| 1433 |
\def\patch{ |
| 1434 |
\patchcmd{\@mn@@@marginnote} % In this command |
| 1435 |
{\kern\marginparsep} % ... replace this... |
| 1436 |
{\ifx\@mn@currpage\relax\else % ... with this |
| 1437 |
\if@twoside\ifodd\@mn@currpage\relax |
| 1438 |
\kern\snp@marginparsepodd |
| 1439 |
\else |
| 1440 |
\kern\snp@marginparsepeven |
| 1441 |
\fi |
| 1442 |
\else |
| 1443 |
\kern\snp@marginparsepodd |
| 1444 |
\fi |
| 1445 |
\fi} |
| 1446 |
{\message{Patched!}\patchok} % success (recurse) |
| 1447 |
{\patcherr} % fail |
| 1448 |
} |
| 1449 |
\message{Patching `\string\@mn@@@marginnote`!} |
| 1450 |
\patch |
| 1451 |
\global\let\@mn@@@marginnote\@mn@@@marginnote % Make patch global |
| 1452 |
} |
| 1453 |
\makeatother |
| 1454 |
\endinput |
| 1455 |
% \end{macrocode} |
| 1456 |
% |
| 1457 |
% \iffalse |
| 1458 |
%</package> |
| 1459 |
% \fi |
| 1460 |
% |
| 1461 |
% \Finale |
| 1462 |
\endinput |