| 1 |
% -------------------------------------------------------------------------- |
| 2 |
% the SNOTEZ package |
| 3 |
% |
| 4 |
% Sidenotes for LaTeX2e |
| 5 |
% |
| 6 |
% -------------------------------------------------------------------------- |
| 7 |
% Clemens Niederberger |
| 8 |
% Web: https://github.com/cgnieder/snotez/ |
| 9 |
% E-Mail: [email protected] |
| 10 |
% -------------------------------------------------------------------------- |
| 11 |
% Copyright 2012--2022 Clemens Niederberger |
| 12 |
% |
| 13 |
% This work may be distributed and/or modified under the |
| 14 |
% conditions of the LaTeX Project Public License, either version 1.3c |
| 15 |
% of this license or (at your option) any later version. |
| 16 |
% The latest version of this license is in |
| 17 |
% http://www.latex-project.org/lppl.txt |
| 18 |
% and version 1.3c or later is part of all distributions of LaTeX |
| 19 |
% version 2008/05/04 or later. |
| 20 |
% |
| 21 |
% This work has the LPPL maintenance status `maintained'. |
| 22 |
% |
| 23 |
% The Current Maintainer of this work is Clemens Niederberger. |
| 24 |
% -------------------------------------------------------------------------- |
| 25 |
\documentclass[load-preamble+]{cnltx-doc} |
| 26 |
\setlength\textwidth{\dimexpr\textwidth-1.2\marginparwidth\relax} |
| 27 |
\setlength{\marginparwidth}{2\marginparwidth} |
| 28 |
|
| 29 |
\usepackage[footnote,perpage]{snotez} |
| 30 |
\setcnltx{ |
| 31 |
package = snotez , |
| 32 |
authors = Clemens Niederberger , |
| 33 |
email = [email protected] , |
| 34 |
url = https://github.com/cgnieder/snotez , |
| 35 |
info = sidenote support for \LaTeXe , |
| 36 |
add-cmds = { |
| 37 |
newsnotezfloat , |
| 38 |
setsidenotes , |
| 39 |
sidenote , |
| 40 |
sidenotemark , |
| 41 |
sidenotetext , |
| 42 |
thesidenote , |
| 43 |
} , |
| 44 |
add-silent-cmds = { |
| 45 |
@captype, @car ,@cdr , @currentlabel , @nil , |
| 46 |
@the@snotez@mark , |
| 47 |
@x@sf , |
| 48 |
cnltx@create@generic@message , |
| 49 |
ifltxcounter , |
| 50 |
MakeSorted , MakeSortedPerPage , |
| 51 |
marginnote , |
| 52 |
pgfkeys , pgfqkeys , |
| 53 |
protected@edef , protected@xdef , |
| 54 |
RaggedRight , |
| 55 |
snotez@date , |
| 56 |
snotez@description , |
| 57 |
snotez@error , |
| 58 |
snotez@error@message , |
| 59 |
snotez@format , |
| 60 |
snotez@if@nblskip , |
| 61 |
snotez@marginnote , snotez@marginpar , |
| 62 |
snotez@mark , |
| 63 |
snotez@new@sidefloat , |
| 64 |
snotez@note@mark@format , |
| 65 |
snotez@note@mark@sep , |
| 66 |
snotez@sidefloat@box , |
| 67 |
snotez@sidefloat@format , |
| 68 |
snotez@sidenote@aux , |
| 69 |
snotez@sidenote@dblarg , |
| 70 |
snotez@sidenote@dblarg@aux , |
| 71 |
snotez@sidenote@nodblarg , |
| 72 |
snotez@sidenote@nodblarg@aux , |
| 73 |
snotez@sidenotetext@aux , |
| 74 |
snotez@sidenotetext@dblarg , |
| 75 |
snotez@sidenotetext@dblarg@aux , |
| 76 |
snotez@sidenotetext@nodblarg , |
| 77 |
snotez@sidenotetext@nodblarg@aux , |
| 78 |
snotez@text , |
| 79 |
snotez@text@mark@format , |
| 80 |
snotez@version , |
| 81 |
snotez@write@mark , |
| 82 |
snotez@warning , |
| 83 |
textsu |
| 84 |
} , |
| 85 |
makeindex-setup = {columns=3, columnsep=1em} |
| 86 |
} |
| 87 |
|
| 88 |
\defbibheading{bibliography}[\bibname]{\addsec{References}} |
| 89 |
|
| 90 |
\makeatletter |
| 91 |
\newcommand*\defaultsidenotes{% |
| 92 |
\setsidenotes{ |
| 93 |
note-mark-format = \@textsuperscript{\normalfont\normalcolor##1}, |
| 94 |
text-format = \normalfont\normalcolor\footnotesize |
| 95 |
}} |
| 96 |
\makeatother |
| 97 |
\setsidenotes{ |
| 98 |
note-mark-format=#1., |
| 99 |
text-mark-format=\textsu{\hspace*{.04em}#1}, |
| 100 |
text-format+=\RaggedRight |
| 101 |
} |
| 102 |
|
| 103 |
\renewrobustcmd*\sinceversion[1]{% |
| 104 |
\sidenote{\GetTranslation{cnltx-introduced}~#1}% |
| 105 |
} |
| 106 |
\renewrobustcmd*\changedversion[1]{% |
| 107 |
\sidenote{\GetTranslation{cnltx-changed}~#1}% |
| 108 |
} |
| 109 |
|
| 110 |
\newname\kohm{Markus Kohm} |
| 111 |
\newname\tennent{Bob Tennent} |
| 112 |
\newname\thomas{Andy Thomas} |
| 113 |
|
| 114 |
\begin{document} |
| 115 |
|
| 116 |
\section{License and Requirements}\label{sec:license} |
| 117 |
\license |
| 118 |
|
| 119 |
\section{Motivation}\label{sec:motivation} |
| 120 |
This has just been an exercise on a lazy |
| 121 |
afternoon\sidenote{\url{https://www.youtube.com/watch?v=OU6EyXcFBxA}}. Well, |
| 122 |
in the beginning at least. Since there already is \thomas' \pkg{sidenotes} |
| 123 |
package\sidenote{\textcite{pkg:sidenotes}} there is probably no real need for |
| 124 |
\snotez. Moreover, the tufte classes\sidenote{\textcite{cls:tufte}} as well |
| 125 |
as \cls{memoir}\sidenote{\textcite{cls:memoir}} also provide corresponding |
| 126 |
mechanisms. Besides the fun I had my motivation was also based on the fact |
| 127 |
that I didn't like some things done by the \pkg{sidenotes} package such as |
| 128 |
inserting kerns and superscripted commas for multiple marks. I prefer to let |
| 129 |
my \pkg{fnpct}\sidenote{\textcite{pkg:fnpct}} package handle these things. |
| 130 |
Anyways, here it is and it seems to be working as intended so I don't see a |
| 131 |
reason why it shouldn't be available for use. |
| 132 |
|
| 133 |
By the way: the \pkg{fnpct} package~v0.2k and later knows about \snotez\ and |
| 134 |
automatically adapts the note commands! |
| 135 |
|
| 136 |
\section{Introduction}\label{sec:introduction} |
| 137 |
The \snotez\ package introduces a \cs{sidenote} command% |
| 138 |
\begingroup\defaultsidenotes |
| 139 |
\sidenote{This is an example demonstrating the default appearance.} |
| 140 |
\endgroup |
| 141 |
that typesets sidenotes the same way \cs*{footnote} typesets footnotes. It |
| 142 |
provides some options that allow formatting the appearance of the |
| 143 |
sidenotes\sidenote{In all sidenotes in this document the mark is typeset |
| 144 |
on the baseline and the text is set ragged right.}. As a default sidenotes |
| 145 |
are typeset in a \cs*{marginpar} but there are possibilities using \kohm's |
| 146 |
\pkg{marginnote}~\cite{pkg:marginnote} package as well. |
| 147 |
|
| 148 |
As with footnotes it is possible to set mark and text separately using the |
| 149 |
equivalent commands \cs{sidenotemark} and \cs{sidenotetext}, respectively. |
| 150 |
Instead of lots of code examples this documentation will use the \cs{sidenote} |
| 151 |
macro itself extensively. It is assumend you know how to use \cs*{footnote} |
| 152 |
and are able to transfer your knowledge. |
| 153 |
|
| 154 |
\section{Usage}\label{sec:usage} |
| 155 |
The basic usage is the very same as with \LaTeX's \cs*{footnote}, |
| 156 |
\cs*{footnotemark} and \cs*{footnotetext}. Unsurprisingly the presented |
| 157 |
commands are these: |
| 158 |
\begin{commands} |
| 159 |
\command{sidenote}[\oarg{mark}\marg{text}] |
| 160 |
The basic command. The syntax is the very same as for \cs*{footnote}. |
| 161 |
\command{sidenote}[\darg{offset}\oarg{mark}\marg{text}] |
| 162 |
Actually I lied: \cs{sidenote} has a second option that smuggles itself |
| 163 |
before the \meta{mark} option if you use it: an argument for a vertical |
| 164 |
offset that takes a length. An empty second option assumes you want the |
| 165 |
automatic mark. If you use this argument the note is set with the |
| 166 |
\cs*{marginnote} command\sidenote(*-1){From the \pkg{marginnote} |
| 167 |
package}. Please see its documentation\sidenote{For example with |
| 168 |
\code{texdoc marginnote} on your command line.}~\cite{pkg:marginnote} |
| 169 |
for the \meta{offset} argument. \snotez\ only passes the value on. |
| 170 |
|
| 171 |
Actually, this is only part of the truth: while typing this documentation |
| 172 |
I repeatedly found myself shifting notes by multiples of |
| 173 |
\cs*{baselineskip} so the argument accepts a shortcut for this. A star |
| 174 |
\code{*} followed by a (positive or negative) number denotes a multiple of |
| 175 |
\cs*{baselineskip}. By the way: a positive value shifts the note |
| 176 |
\emph{down}. |
| 177 |
|
| 178 |
When you're using the \keyis{dblarg}{true} option the \meta{offset} |
| 179 |
argument has square brackets instead of parentheses! |
| 180 |
\command{sidenotemark}[\oarg{marg}] |
| 181 |
This command has the same purpose as \cs*{footnotemark} but for |
| 182 |
sidenotes. |
| 183 |
\command{sidenotetext}[\oarg{mark}\marg{text}] |
| 184 |
The same as \cs*{footnotetext} but for sidenotes. Beware where you place |
| 185 |
it: it calls \cs*{marginpar} or \cs*{marginnote} and thus determines where |
| 186 |
the actual note is placed. |
| 187 |
\command{sidenotetext}[\darg{offset}\oarg{mark}\marg{text}] |
| 188 |
I lied again: \cs{sidenotetext} also has the second optional argument |
| 189 |
\meta{offset} that again smuggles itself before the \meta{mark} option if |
| 190 |
you use it. For details see the second description of the \cs{sidenote} |
| 191 |
command. |
| 192 |
\end{commands} |
| 193 |
|
| 194 |
Here is one short example of the usage. |
| 195 |
|
| 196 |
\begin{sourcecode} |
| 197 |
% produces a sidenote with automatic number in a |
| 198 |
% \marginpar: |
| 199 |
\sidenote{A note} |
| 200 |
|
| 201 |
% produces a sidenote with mark `a' in a |
| 202 |
% \marginpar: |
| 203 |
\sidenote[a]{A note} |
| 204 |
|
| 205 |
% produces a sidenote with automatic number in a |
| 206 |
% \marginnote: |
| 207 |
\sidenote(){A note} |
| 208 |
% alternative syntax (dblarg=true): |
| 209 |
\sidenote[][]{A note} |
| 210 |
|
| 211 |
% produces a sidenote with automatic number in a |
| 212 |
% \marginnote shifted down by \baselineskip: |
| 213 |
\sidenote(*){A note} |
| 214 |
% alternative syntax (dblarg=true): |
| 215 |
\sidenote[*][]{A note} |
| 216 |
|
| 217 |
% produces a sidenote with automatic number in a |
| 218 |
% \marginnote shifted up by 2ex: |
| 219 |
\sidenote(-2ex){A note} |
| 220 |
% alternative syntax (dblarg=true): |
| 221 |
\sidenote[-2ex][]{A note} |
| 222 |
|
| 223 |
% produces a sidenote with mark `a' in a |
| 224 |
% \marginnote shifted down by 2\baselineskip: |
| 225 |
\sidenote(*2)[a]{A note} |
| 226 |
% alternative syntax (dblarg=true): |
| 227 |
\sidenote[*2][a]{A note} |
| 228 |
\end{sourcecode} |
| 229 |
|
| 230 |
\section{Figures in the Margin}\label{sec:figures-margin} |
| 231 |
In the case of small figures or tables one might want to place them in the |
| 232 |
margin, too. Especially in a document with a larger margin than it is in the |
| 233 |
standard classes. |
| 234 |
|
| 235 |
For these cases \snotez\ provides\sinceversion{0.5} these environments: |
| 236 |
\begin{environments} |
| 237 |
\environment{sidefigure} |
| 238 |
Places a figure in the margin within a \cs*{marginpar}. \cs*{caption} can |
| 239 |
be used in the usual way. |
| 240 |
\environment{sidetable} |
| 241 |
Places a table in the margin within a \cs*{marginpar}. \cs*{caption} can |
| 242 |
be used in the usual way. |
| 243 |
\end{environments} |
| 244 |
\begin{sidefigure} |
| 245 |
\includegraphics[width=\marginparwidth]{example-image} |
| 246 |
\caption{An example for a figure in the margin.} |
| 247 |
\end{sidefigure} |
| 248 |
|
| 249 |
In order to be able to place other floats in the margin, too, \snotez\ |
| 250 |
provides the following command: |
| 251 |
\begin{commands} |
| 252 |
\command{newsnotezfloat}[\oarg{code}\marg{name}] |
| 253 |
This defines a new environment \code{side}\meta{name}. \meta{code} would |
| 254 |
be placed after the formatting from \option{sidefloat-format} but before |
| 255 |
the environment's contents. |
| 256 |
\end{commands} |
| 257 |
Both existing environments have been defined with this command. |
| 258 |
\begin{sourcecode} |
| 259 |
\newsnotezfloat{figure} |
| 260 |
\newsnotezfloat{table} |
| 261 |
\end{sourcecode} |
| 262 |
|
| 263 |
\section{Options}\label{sec:options} |
| 264 |
Although all options can be used as package option you can also set all options |
| 265 |
(locally) with a setup command: |
| 266 |
\begin{commands} |
| 267 |
\command{setsidenotes}[\marg{options}] |
| 268 |
Set options as a comma-separated list of key/value pairs. |
| 269 |
\end{commands} |
| 270 |
Available options are these: |
| 271 |
\begin{options} |
| 272 |
\keybool{dblarg}\Default{false}\label{key:dblarg}% |
| 273 |
Prior to version~0.3 \snotez' \cs{sidenote} and \cs{sidenotetext} had both |
| 274 |
their optional arguments with square brackets where the use of one argument |
| 275 |
referred to the mark but when both were used the first argument referred |
| 276 |
to the offset and the second to the mark. This syntax is kept with this |
| 277 |
option. Setting it to \code{true} changes the \darg{offset} argument |
| 278 |
syntax into \oarg{offset}. |
| 279 |
\keybool{marginnote}\Default{false} |
| 280 |
Use \pkg{marginnote}'s \cs*{marginnote}~\cite{pkg:marginnote} for all |
| 281 |
\cs{sidenote}s. In the default setting \cs{sidenote} uses |
| 282 |
\cs*{marginpar}s to set the sidenote unless you use the \meta{offset} |
| 283 |
argument. If you use this option \emph{all} sidenotes are set with |
| 284 |
\cs*{marginnote}. \emph{This option can only be used in the preamble}. |
| 285 |
\keyval{text-format}{code}\Default{\cs*{normalfont}\cs*{footnotesize}} |
| 286 |
The format of the sidenote text. |
| 287 |
\keyval{text-format+}{code}\Default |
| 288 |
Code to be appended to the format set with |
| 289 |
\option{text-format}\sidenote{This document, for example, appends |
| 290 |
\pkg{ragged2e}'s \cs*{RaggedRight}~\cite{pkg:ragged2e} to the |
| 291 |
sidenote's format.}. |
| 292 |
\keybool{perpage}\Default{false} |
| 293 |
\emph{This option can only be set in the preamble}. Make sidenotes |
| 294 |
counter per page. It uses package \pkg{zref-perpage}'s~\cite{bnd:zref} |
| 295 |
for the task. This documentation is an example for the use of the option. |
| 296 |
\keybool{perchapter}\Default{false} |
| 297 |
\emph{This option can only be set in the preamble}.\sinceversion{0.6} If |
| 298 |
your document class has defined a counter \code{chapter} and if you set |
| 299 |
this to \code{true} the \code{sidenote} counter will be added to the reset |
| 300 |
list of the \code{chapter} counter. |
| 301 |
\keyval{note-mark-sep}{code}\Default{\cs*{space}} |
| 302 |
The separator between sidenote mark and sidenote text in the sidenote. |
| 303 |
\keyval{note-mark-format}{code}\Default{\cs*{@textsuperscript}\Marg{\cs*{normalfont}\#1}} |
| 304 |
The format of the sidenote mark in the sidenote. Please refer to the |
| 305 |
actual mark with \code{\#1}. |
| 306 |
\keyval{text-mark-format}{code}\Default{\cs*{@textsuperscript}\Marg{\cs*{normalfont}\#1}} |
| 307 |
The format of the sidenote mark in the text\sidenote(*-1){This document |
| 308 |
uses \tennent's \pkg{libertine} package~\cite{pkg:libertine} and |
| 309 |
redefines the mark formats to use its \cs*{textsu} command.}. Please |
| 310 |
refer to the actual mark with \code{\#1}. |
| 311 |
\keybool{footnote}\Default{false} |
| 312 |
\emph{This option can only be used in the preamble}. Let\sidenote{In |
| 313 |
the sense of \cs*{let}} \cs*{footnote} to be \cs{sidenote}, |
| 314 |
\cs*{footnotemark} to be \cs{sidenotemark} and \cs*{footnotetext} to be |
| 315 |
\cs{sidenotetext}. |
| 316 |
\keyval{sidefloat-format}{code}\Default{\cs*{raggedright}} |
| 317 |
The format of the contents of a sidefloat environment |
| 318 |
text\sinceversion{0.5}. |
| 319 |
\keyval{sidefloat-format+}{code} |
| 320 |
Code to be appended to the format set with |
| 321 |
\option{sidefloat-format}\sinceversion{0.5}. |
| 322 |
\end{options} |
| 323 |
|
| 324 |
\clearpage |
| 325 |
As a short example this is how the sidenotes for this document are formatted: |
| 326 |
\begin{sourcecode} |
| 327 |
\setsidenotes{ |
| 328 |
note-mark-format=#1., |
| 329 |
text-mark-format=\textsu{\hspace*{.04em}#1}, |
| 330 |
text-format+=\RaggedRight, |
| 331 |
perpage=true |
| 332 |
} |
| 333 |
\end{sourcecode} |
| 334 |
|
| 335 |
|
| 336 |
\section{Implementation} |
| 337 |
In the following code the lines 1--24 have been omitted. They only repeat the |
| 338 |
license statement which has already been mentioned in section~\ref{sec:license}. |
| 339 |
|
| 340 |
\implementation[ |
| 341 |
linerange={25-344}, |
| 342 |
firstnumber=25, |
| 343 |
basicstyle=\ttfamily\footnotesize |
| 344 |
]{snotez.sty} |
| 345 |
|
| 346 |
\indexprologue{\noindent Package names are indicated {\packageformat sans |
| 347 |
serif}, commands \code{\textbackslash\textcolor{cs}{brown}} and options |
| 348 |
\textcolor{option}{\code{yellow}}.\par\bigskip} |
| 349 |
|
| 350 |
% \printindex |
| 351 |
|
| 352 |
\end{document} |