Debian Codegraph @

texmf-dist/source/lualatex/luatodonotes/luatodonotes.dtx

raw
1 % \iffalse meta-comment
2 %
3 % Copyright (C) 2014-2020 by Fabian Lipp <[email protected]>
4 % based on the todonotes package
5 % by Henrik Skov Midtiby <[email protected]>
6 % ------------------------------------------------------------
7 %
8 % This file may be distributed and/or modified under the
9 % conditions of the LaTeX Project Public License, either version 1.2
10 % of this license or (at your option) any later version.
11 % The latest version of this license is in:
12 %
13 % http://www.latex-project.org/lppl.txt
14 %
15 % and version 1.2 or later is part of all distributions of LaTeX
16 % version 1999/12/01 or later.
17 %
18 % \fi
19 %
20 % \iffalse
21 %<*driver>
22 \ProvidesFile{luatodonotes.dtx}
23 %</driver>
24 %<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
25 %<package>\ProvidesPackage{luatodonotes}
26 %<*package>
27 [2025/08/11 v0.5a luatodonotes source and documentation.]
28 %</package>
29 %
30 %<*driver>
31 \documentclass{ltxdoc}
32 \usepackage{wrapfig}
33 \PassOptionsToPackage{colorlinks, urlcolor=blue}{hyperref}
34 \usepackage{hypdoc} % this package loads hyperref among others
35 \usepackage[colorinlistoftodos, shadow]{luatodonotes}[2020/02/16]
36 \usepackage{fontspec}
37 \usepackage{amsmath}
38 \usepackage{setspace}
39 \usepackage{soul}
40 \setcounter{tocdepth}{2}
41 \EnableCrossrefs
42 \CodelineIndex
43 \RecordChanges
44 \begin{document}
45 \DocInput{luatodonotes.dtx}
46 %\iffalse
47 % \PrintChanges
48 % \PrintIndex
49 %\fi
50 \end{document}
51 %</driver>
52 % \fi
53 %
54 % \CheckSum{951}
55 %
56 % \CharacterTable
57 % {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
58 % 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
59 % Digits \0\1\2\3\4\5\6\7\8\9
60 % Exclamation \! Double quote \" Hash (number) \#
61 % Dollar \$ Percent \% Ampersand \&
62 % Acute accent \' Left paren \( Right paren \)
63 % Asterisk \* Plus \+ Comma \,
64 % Minus \- Point \. Solidus \/
65 % Colon \: Semicolon \; Less than \<
66 % Equals \= Greater than \> Question mark \?
67 % Commercial at \@ Left bracket \[ Backslash \\
68 % Right bracket \] Circumflex \^ Underscore \_
69 % Grave accent \` Left brace \{ Vertical bar \|
70 % Right brace \} Tilde \~}
71 %
72 %
73 % \changes{0.1}{2014/08/07}{The first version of the package}
74 % \changes{0.2}{2015/01/13}{Fix wrong linespacing when changing fontsize}
75 % \changes{0.2}{2015/01/13}{Included suggestions from CTAN submission into
76 % documentation}
77 % \changes{0.2}{2015/03/12}{Added troubleshooting section to documentation}
78 % \changes{0.3}{2015/12/03}{Incorporated some changes from todonotes (version
79 % 1.0.4)}
80 % \changes{0.4}{2017/10/01}{Incorporated some changes from todonotes (version
81 % 1.0.5)}
82 % \changes{0.5a}{2025/08/08}{Renamed inspect.lua to luatodonotes-inspect.lua
83 % in order to avoid file conflicts with other packages.}
84 % \GetFileInfo{luatodonotes.dtx}
85 %
86 % \DoNotIndex{\newcommand,\newenvironment}
87 %
88 % \iffalse
89 % A macro for marking things todo before the next relase
90 % (typically update of documentation).
91 % \fi
92 % \newcommand{\donow}[1]{\todo[color=blue]{#1}}
93 %
94 %
95 % \title{The \textsf{luatodonotes} package\thanks{This document
96 % corresponds to \textsf{luatodonotes}~\fileversion, dated \filedate.}}
97 % \author{Fabian Lipp\thanks{This documentation and the whole package is based
98 % on version 1.0.2 of the todonotes package by Henrik Skov Midtiby.} \\
99 % \texttt{[email protected]}}
100 %
101 % \maketitle
102 %
103 % \begin{abstract}
104 % The |luatodonotes| package allows you to insert to--do items in your
105 % document. At any point in the document a list of all the inserted
106 % to--do items can be listed with the |\listoftodos| command.
107 %
108 % It is an extended version of the |todonotes| package and uses more advanced
109 % algorithms to place the to--do notes on the page.
110 % For these algorithms it depends on Lua\TeX.
111 % \end{abstract}
112 %
113 % \pdfbookmark[1]{Contents}{contents}
114 % \tableofcontents
115 %
116 % \newpage
117 % \section{Introduction}
118 %
119 % The |luatodonotes| package makes three commands available to the
120 % user: |\todo[]{}|, |\missingfigure{}| and |\listoftodos|.
121 % |\todo[]{}| and |\missingfigure{}| makes it possible to insert
122 % notes in your document about things that has to be done later
123 % (todonotes \ldots).
124 % This package is based on version 1.0.2 of
125 % |todonotes|\footnote{\url{http://www.ctan.org/pkg/todonotes}} by Henrik Skov
126 % Midtiby.
127 %
128 % The positions of the notes on the page is determined using algorithms
129 % implemented in Lua, so you have to process your documents using Lua\LaTeX.
130 % The package can be used as a drop-in replacement for the original
131 % |todonotes| package, you
132 % only need to modify |\usepackage{todonotes}| to |\usepackage{luatodonotes}|.
133 % Note that |todonotes| and |luatodonotes| must not be loaded inside the same
134 % document.
135 %
136 % Some alternatives for the luatodonotes package are:
137 % \begin{itemize}
138 % \item \href{http://www.ctan.org/pkg/easy-todo}{easy-todo}\\
139 % Depends on |color|, |tocloft| and |ifthen|, small feature set.
140 % \item \href{http://www.ctan.org/pkg/fixmetodonotes}{fixmetodonotes}\\
141 % Depends on |graphicx|, |color|, |transparent|, |watermark|, |fix-cm|, |ulem| and |tocloft|, small feature set.
142 % \item \href{http://www.ctan.org/pkg/todo}{todo}\\
143 % Depends on |amssymb|, medium feature set.
144 % \item \href{http://www.ctan.org/pkg/fixme}{fixme}\\
145 % Large package with a lot of features.
146 % \item \href{http://www.ctan.org/pkg/todonotes}{todonotes}
147 % \end{itemize}
148 %
149 % Compared to the classical todonotes this package has more advanced algorithms
150 % and more configuration options to control the position of the notes on the
151 % page.
152 % Additionally, we are able to place notes at almost every position on the
153 % page, e.\,g., in floating environments or in footnotes.
154 % As a disadvantage luatodonotes requires Lua\LaTeX{} for document processing, so
155 % a standard |pdflatex| won't work.
156 % Depending on the chosen layout for the to--do notes the runtime can be much
157 % higher than with todonotes.
158 % Labels placed by luatodonotes can conflict with text placed with
159 % |\marginpar|.
160 %
161 % The main reason for considering other packages is that the todonotes
162 % package is quite large and relies heavily on tikz.
163 % This can slow down compilation of large documents significantly.
164 % The mentioned alternatives have a different feature set and do not
165 % rely on tikz, which makes them require less ressoureces.
166 %
167 %
168 %
169 % \subsection{Using Lua\LaTeX}
170 % It is quite easy to switch from |pdflatex| to |lualatex|.
171 % You only have to load a few different packages.
172 % A small guide can be found in the Lua\LaTeX{}
173 % guide\footnote{\url{http://mirror.ctan.org/info/luatex/lualatex-doc/lualatex-doc.pdf}}.
174 %
175 % The Lua\TeX{} processor (the |lualatex| executable) should be included in all
176 % modern \TeX{} distributions, so you do not need to install additional
177 % software.
178 % You simply have to run |lualatex| instead of |pdflatex| (or instead of
179 % |latex|, |xelatex|).
180 %
181 %
182 %
183 % \subsection{Usage of luatodonotes}
184 % The package is loaded with |\usepackage|\oarg{options}|{luatodonotes}|.
185 % Valid options are described in Section~\ref{subsecPackageOptions}.
186 % Note that |todonotes| must \emph{not} be loaded.
187 % You have to use |lualatex| to process your document, |pdflatex| will not
188 % work.
189 % The package depends on positions written to the aux-file, so you have to run
190 % |lualatex| twice or even three times to get the labels and leaders for the
191 % notes right.
192 %
193 % \DescribeMacro{\todo}
194 % My \index{\todo}most common usage of the todonotes package, is to
195 % insert an todonotes somewhere in a latex document.
196 % An example of this usage is the command
197 %
198 % |\todo{Make a cake \ldots}|,
199 %
200 % \noindent
201 % which renders like\todo{Make a cake \ldots}.
202 % The |\todo| command has this structure:
203 % |\todo|\oarg{options}\marg{todo text}.
204 % The |todo text| is the text that will be shown in the todonote and
205 % in the list of todos. The optional argument |options|, allows the
206 % user to customize the appearance of the inserted todonotes.
207 % For a description of all the options see section
208 % \ref{subsecTodoOptions}.
209 %
210 % \DescribeMacro{\todoarea}
211 % The |\todoarea| is similiar to |\todo|, but is able to highlight a specified
212 % area in the text, to which the note is connected.
213 % The command has this structure:
214 % |\todoarea|\oarg{options}\marg{note text}\marg{highlighted text}.
215 % This command was not tested extensively until now, so it should be used with
216 % caution.
217 %
218 % \DescribeMacro{\missingfigure}
219 % The |\missingfigure| command inserts an image containing an
220 % attention sign and the given text.
221 % The command takes only one argument
222 % |\missingfigure|\marg{text}, a text string that could
223 % describe what the figure should consist of.
224 % An example of its usage could be
225 %
226 % |\missingfigure{Make a sketch of the structure of a trebuchet.}|
227 %
228 % \noindent
229 % which renders like.
230 %
231 % \missingfigure{Make a sketch of the structure of a trebuchet.}
232 %
233 %
234 % \DescribeMacro{\listoftodos}
235 % The |\listoftodos| command inserts a list of all the todos in the
236 % current document. |\listoftodos| takes no arguments.
237 % For this document the list of to--do's looks like.
238 % \listoftodos
239 % \vspace{0.5cm}
240 %
241 % \DescribeMacro{\todototoc}
242 % The |\todototoc| command adds an entry to the table of contents for
243 % list of todos. The command should be placed right before the
244 % |\listoftodos| command.
245 %
246 % \subsection{Package options}
247 % \label{subsecPackageOptions}
248 % \DescribeMacro{disable}
249 % If the option |disable| is passed to the package, the macros
250 % usually defined by the package (|\todo|, |\todoarea|, |\listoftodos| and
251 % |\missingfigure|) are defined as macros with no effect, and thus
252 % all inserted notes are removed.
253 %
254 % \DescribeMacro{obeyDraft, obeyFinal}
255 % When the option |obeyDraft| is given, the package checks
256 % if the one of the options |draft|, |draftcls| or |draftclsnofoot|
257 % is given (this option is usually given to
258 % the documentclass). If the |draft| option is given, the
259 % functionality of the package is enabled and otherwise the effect
260 % of the package is disabled.
261 % The option |obeyFinal| does something similar, except that the
262 % todonotes package is only disabled if the |final| option given.
263 %
264 % \DescribeMacro{danish, german, ngerman, english, french, swedish}
265 % \DescribeMacro{spanish, catalan, italian}
266 % \DescribeMacro{portuguese, dutch, croatian}
267 % Use translations of the text strings
268 % ''List of todos'' and ''Missing figure''.
269 % The default is to use none of these options, which results in
270 % english text strings.
271 % Currently the following languages are supported:
272 % catalan,
273 % croatian,
274 % danish,
275 % dutch,
276 % english,
277 % french,
278 % german,
279 % ngerman,
280 % italian,
281 % portuguese,
282 % spanish and
283 % swedish.
284 %
285 % \DescribeMacro{colorinlistoftodos}
286 % Adds a small colored square in front of all items in the Todo
287 % list. The color of the square is the same as the fill color of the
288 % inserted todonote.
289 % This can be useful if there are different types of todos
290 % (insert reference, explain in detail, \ldots) where the color of
291 % the inserted todonote marks the type of todo.
292 %
293 % \DescribeMacro{color}
294 % \DescribeMacro{backgroundcolor}
295 % \DescribeMacro{linecolor}
296 % \DescribeMacro{bordercolor}
297 % These options sets the default colors for the todo command.
298 % There is three colors that can be specified. The border color
299 % (default |bordercolor=black|) around the inserted text, the color
300 % behind the inserted text (default |backgroundcolor=orange|) and
301 % the color of the line connecting the inserted textbox with the
302 % current location in the text (default |linecolor=black!30|).
303 % Setting the |color| option to |val| passes this value on to the
304 % background and line color options.
305 % The specified colors must be valid according to the
306 % |xcolor| package.
307 %
308 % \DescribeMacro{textsize}
309 % |textsize=value| sets the default text size of the inserted
310 % todonotes to the given value.
311 % Value is the ''name'' of the used font size, eg. if the desired
312 % fontsize is |\tiny| use |textsize=tiny|. The default value is
313 % |textsize=normalsize|.
314 %
315 % \DescribeMacro{prependcaption}
316 % The |prependcaption| option triggers a special behaviour of the
317 % |caption=val| option for the todo command, where the given value
318 % |val| is inserted in the inserted todonote.
319 %
320 % \DescribeMacro{shadow}
321 % If the |shadow| option is given, the inserted todonotes will be
322 % displayed with a gray shadow.
323 % I expect that the option will trigger problems with tikz versions
324 % prior to 2.0.
325 %
326 % \DescribeMacro{figwidth}
327 % \DescribeMacro{figheight}
328 % The |figwidth=length| option and |figheight=length| option set the default
329 % width and height of the figure
330 % inserted by the |\missingfigure| command.
331 % The default value is |\linewidth| for the width and |4cm| for the height.
332 %
333 % \DescribeMacro{leaderwidth}
334 % The |leaderwidth=length| option specifies the width of the leader lines.
335 % The argument is passed to the |line width| option in TikZ.
336 % The default value is |1.6pt|.
337 %
338 % \DescribeMacro{leadertype}
339 % The |leadertype=type| option specifies the shape of the leaders, which are
340 % drawn between the labels in the margin and the corresponding sites in text.
341 % We use the characterization of the leader types known from boundary labeling:
342 % $p$ denotes a segment parallel to the left/right side of the text area, while
343 % $o$ denotes a orthogonal segment.
344 % $s$ is a straight-line segment.
345 % The following types are available (|opo| is the default value):
346 % \begin{itemize}
347 % \item |s|:
348 % Straight-line connection between site and label.
349 % \item |sBezier|:
350 % Uses the straight-line leaders but transforms them into B\'ezier curves,
351 % which are easier to follow for the reader.
352 % The generated curves don't cross each other when the straight-line leaders
353 % are crossing-free.
354 % \item |opo|:
355 % This is the style used in the original todonotes package.
356 % The leaders start with a horizontal segment at the site in the text,
357 % followed by a vertical segment in the margin beneath the text.
358 % The last segment is a vertical segment, which connects to the label.
359 % \item |os|:
360 % This is the style used in common word processing applications like
361 % LibreOffice.
362 % The leader also starts with a horizontal segment that leads to the margin
363 % and is connected to the label by a straight line.
364 % \item |po|:
365 % The leader starts with a vertical segment at the site in text and is then
366 % connected to the label by a horizontal segment.
367 % \end{itemize}
368 %
369 % \DescribeMacro{positioning}
370 % The |positioning=algorithm| option specifies, which algorithm is used to
371 % determine the positions of the notes on the page.
372 % You should choose the algorithm depending on the leader type you want to use.
373 % You can also use one of the options |s|, |po|, |bezier|, or |opo| to define
374 % the positioning algorithm together with the leadertype.
375 % The default value for this option is |inputOrderStacks|.
376 % The following algorithms are available:
377 % \begin{itemize}
378 % \item |inputOrder|:
379 % Place the labels in the order given by the
380 % y-coordinates of the corresponding sites in text.
381 % Intended for use with $opo$- or $os$-leaders.
382 % \item |inputOrderStacks|:
383 % Like the algorithm before, but the labels are
384 % clustered before they are placed.
385 % Thus the labels are placed nearer to their sites.
386 % Intended for use with $opo$- or $os$-leaders.
387 % \item |sLeaderNorthEast|:
388 % Places labels in a way that they can be connected to their sites by
389 % straight-line leaders without crossings.
390 % The leaders are attached to the upper right or upper left corner of the
391 % label (depending on which site of the text the label is placed).
392 % Intended for use with $s$-leaders or B\'ezier leaders.
393 % \item |sLeaderNorthEastBelow|:
394 % Like the algorithm before, but the leader is attached to a point that is a
395 % constant offset below the corner of the label.
396 % Intended for use with $s$-leaders or B\'ezier leaders.
397 % \item |sLeaderNorthEastBelowStacks|:
398 % Like the algorithm before, but the labels are cluster before they are
399 % placed.
400 % Thus the labels are placed nearer to their sites.
401 % Intended for use with $s$-leaders or B\'ezier leaders.
402 % \item |sLeaderEast|:
403 % Like the algorithms before, but the leader is attached to the center of the
404 % right or left boundary of the label.
405 % Intended for use with $s$-leaders or B\'ezier leaders.
406 % \item |poLeaders|:
407 % Calculates label positions that lead to $po$-leaders with minimum total
408 % length.
409 % This algorithm depends heavily on the number of notes, so the runtime and
410 % memory consumption can get very high.
411 % \item |poLeadersAvoidLines|:
412 % Like the algorithm before, but tries to avoid overlapping of horizontal
413 % leader segments with text.
414 % This algorithm depends heavily on advanced Lua\TeX\ features to manipulate
415 % the data structures of the page, so it possibly could give conflicts with
416 % other packages.
417 % \end{itemize}
418 %
419 % \DescribeMacro{s}
420 % \DescribeMacro{bezier}
421 % \DescribeMacro{opo}
422 % \DescribeMacro{po}
423 % Shorthand options for convenience, which represent common combinations of
424 % leadertypes and postioning algorithms.
425 % |leadertype| or |positioning| options following one of these options override
426 % its settings.
427 % They use the following positioning algorithms:
428 % \begin{itemize}
429 % \item |s|: |sLeaderNorthEastBelowStacks|
430 % \item |bezier|: |sLeaderNorthEastBelowStacks|
431 % \item |opo|: |inputOrderStacks|
432 % \item |po|: |poLeadersAvoidLines|
433 % \end{itemize}
434 %
435 % \DescribeMacro{splitting}
436 % The |splitting=algorithm| option can be used to place the labels on both sides
437 % of the text.
438 % The notes are only separated when there is enough space on both sides (see
439 % |minNoteWidth|.
440 % The default value for this option is |none|.
441 % Available algorithms for this option are:
442 % \begin{itemize}
443 % \item |none|:
444 % Labels are placed in the wider margin only.
445 % \item |middle|:
446 % The text area is split in the middle in a left and a right half.
447 % Labels, whose sites are in the left half of the text, are placed in the
448 % left margin, the others in the right margin.
449 % \item |median|:
450 % The notes are seperated at the median of the sites (sorted by
451 % x-coordinate).
452 % That is, the number of notes in the left and the right margin is equal
453 % (except for one note).
454 % \item |weightedMedian|:
455 % Considers the height of the labels for the median.
456 % So the total height of the labels in the left margin is approximately equal
457 % to that in the right margin.
458 % \end{itemize}
459 %
460 % \DescribeMacro{interNoteSpace}
461 % The |interNoteSpace=length| option specifies the minimum vertical distance
462 % between two notes.
463 % The default value is |5pt|.
464 %
465 % \DescribeMacro{noteInnerSep}
466 % The |noteInnerSep=length| option specifies the |inner sep| used for the TikZ
467 % nodes, i.\,e., the distance between the border of the note and the text inside
468 % it.
469 % The default value is |5pt|.
470 %
471 % \DescribeMacro{routingAreaWidth}
472 % The |routingAreaWidth=length| option specifies the width of the so called
473 % routing area.
474 % This is the area, in which the vertical segment of $opo$-leaders are placed.
475 % The area is also used for $os$-leaders.
476 % The default value is |0.4cm|.
477 %
478 % \DescribeMacro{minNoteWidth}
479 % The |minNoteWidth=length| option specifies the minimum width of the labels.
480 % When there is fewer space in one of the margins, this margin is not considered
481 % for label placement.
482 % If both margins are narrower, no labels are placed and an error message is
483 % printed to the console output.
484 % The default value of this option is |2.0cm|.
485 %
486 % \DescribeMacro{distanceNotesPageBorder}
487 % The |distanceNotesPageBorder=length| option specifies the horizontal distance
488 % from the labels to the borders of the paper.
489 % You can adjust this setting to your printer margins.
490 % The default value of this option is |0.5cm|.
491 %
492 % \DescribeMacro{distanceNotesText}
493 % The |distanceNotesPageBorder=length| option specifies the horizontal distance
494 % between the labels and the text area.
495 % With $opo$- or $os$-leaders the routing area is inserted additionally so the
496 % distance between labels and text area increases.
497 % The default value of this option is |0.2cm|.
498 %
499 % \DescribeMacro{rasterHeight}
500 % The |rasterHeight=length| option is used only for the $po$-leader algorithm.
501 % For this algorithm the page is rasterized and the labels are placed only on
502 % the positions given by this raster.
503 % Decreasing this value can yield better results (i.\,e., smaller total leader
504 % length), but strongly increases the runtime and memory consumption.
505 % The default value of this option is |1cm|.
506 %
507 % \DescribeMacro{additionalMargin}
508 % The |additionalMargin=length| option extends the page margins horizontally.
509 % To achieve this the page width is increased.
510 % The page is extended by the given length on both sides.
511 % The layout of the page stays the same but the paper format is changed: the
512 % height is left unmodified, but the width is increased by the doubled value of
513 % the given length.
514 % This option is useful if you have to adhere to a given layout, whose margins
515 % are not wide enough to accomodate the notes.
516 % You can safely use this option as the final layout of your document does not
517 % change when disabling the |luatodonotes| package.
518 % The default width of |2cm| for the additional margin is used when the option
519 % is given without a length.
520 %
521 % \DescribeMacro{debug}
522 % When the |debug| option is activated the package is more verbose on
523 % the commandline.
524 % Additionally, some markers, which can be used to understand the algorithms,
525 % are drawn on the page (depending on the chosen algorithm).
526 %
527 %
528 %
529 %
530 % \subsection{Options for the \texttt{todo} command}
531 % \label{subsecTodoOptions}
532 % There are several options that can be given to the |\todo|
533 % command. All the options are described here and often I have
534 % included examples of the change in visual appearance.
535 % Default values for these options can be set using the presetkeys
536 % command.
537 % \begin{verbatim}
538 % \presetkeys{todonotes}{fancyline, color=blue!30}{}
539 % \end{verbatim}
540 %
541 % \DescribeMacro{disable}
542 % The |disable| option can be given directly to the todo command.
543 % If given the command has no effect.
544 %
545 % \DescribeMacro{color}
546 % \DescribeMacro{backgroundcolor}
547 % \DescribeMacro{linecolor}
548 % \DescribeMacro{bordercolor}
549 % These options set the color that is used in the current todo
550 % command.
551 % The color classes is the same as used in the color package
552 % options, see section \ref{subsecPackageOptions}.
553 % Default values can be set by the color
554 % options when the todonotes package is loaded.
555 % \todo[color=green!40]{And a green note}
556 % The todo notes inserted in this paragraph is created with the
557 % command
558 % |\todo[color=green!40]{And a green note}|.
559 % The color of the inserted note could be used to mark different
560 % types of tasks (insert references, explain something in detail,
561 % \ldots), this could be streamlined by defining new commands like
562 % below.
563 % \begin{verbatim}
564 % \newcommand{\insertref}[1]{\todo[color=green!40]{#1}}
565 % \newcommand{\explainindetail}[1]{\todo[color=red!40]{#1}}
566 % \end{verbatim}
567 % An example that uses all of the color options is given below
568 % \todo[linecolor=green!70!white, backgroundcolor=blue!20!white,
569 % bordercolor=red]{Anything but default colors}.
570 % \begin{verbatim}
571 % \todo[linecolor=green!70!white, backgroundcolor=blue!20!white,
572 % bordercolor=red]{Anything but default colors}.
573 % \end{verbatim}
574 %
575 %
576 % \DescribeMacro{line / noline}
577 % If you want to get rid of the line connecting the inserted note
578 % with the place in the text where the note occurs in the latex
579 % code, the option |noline| can be used.
580 % \todo[noline]{A note with no line connecting it to the placement
581 % in the original text.}
582 % |\todo[noline]{A note with no line ...}|
583 % \vspace{1.0cm}
584 %
585 %
586 % \DescribeMacro{inline / noinline}
587 % It is possible to place a todonote inside the text instead of
588 % placing it in the margin, this could be desirable if the text in
589 % the note has a considerable length.
590 % |\todo[inline]{A todonote placed in the text}|
591 % \todo[inline]{A todonote placed in the text}
592
593 % \begin{wrapfigure}[1]{r}[20mm]{40mm}
594 % \begin{tikzpicture}
595 % \draw[red] (0, 0) circle(0.45);
596 % \draw[green] (1, 0) circle(0.45);
597 % \draw[blue] (2, 0) circle(0.45);
598 % \end{tikzpicture}
599 % \caption{A text explaining the image.
600 % \todo[inline]{Fill those circles \ldots}}
601 % \end{wrapfigure}
602 % Another usage for the inline option is when you want to add a
603 % todonote to a figure caption.
604 %
605 % \begin{verbatim}
606 % \begin{wrapfigure}{r}[20mm]{40mm}
607 % \begin{tikzpicture}
608 % \draw[red] (0, 0) circle(0.45);
609 % \draw[green] (1, 0) circle(0.45);
610 % \draw[blue] (2, 0) circle(0.45);
611 % \end{tikzpicture}
612 % \caption{A text explaining the image.
613 % \todo[inline]{Fill those circles \ldots}}
614 % \end{wrapfigure}
615 % \end{verbatim}
616 %
617 % \DescribeMacro{size}
618 % |size=val| changes the size of the text inside the todonote.
619 % The commands used to create the notes below are \\ \noindent
620 % |\todo[size=\Large]{A note with a large font size.}|
621 % and \\ \noindent
622 % |\todo[inline, size=\tiny]{Note with very small font size.}|.
623 % \todo[size=\Large]{A note with a large font size.}
624 % \todo[inline, size=\footnotesize]{Note with very small font size.}
625 %
626 % \DescribeMacro{list / nolist}
627 % When the option |nolist| is given, the todo item will not appear in
628 % the list of todos.
629 %
630 % \DescribeMacro{caption}
631 % The |caption| option enables the user to specify a short
632 % description of the todonote that are inserted in the list of
633 % todos instead of the full todonote text.
634 % \todo[caption={Short note}]{A very long and tedious note that
635 % cannot be on one line in the list of todos.}
636 % \begin{verbatim}
637 % \todo[caption={Short note}]{A very long and tedious note that
638 % cannot be on one line in the list of todos.}.
639 % \end{verbatim}
640 % The effect of this option is altered with the package option
641 % |prependcaption| or the |prepend| / |noprepend| option for the
642 % todo command.
643 %
644 % \DescribeMacro{prepend / noprepend}
645 % The options |prepend| and |noprepend| can be used for setting
646 % whether a given caption should be prepended to the todonote or
647 % not.
648 % Globally this can be set using the |prependcaption| option for the
649 % package.~\todo[prepend, caption={Short note with prepend}]{A very
650 % long and tedious note that cannot be on one line in the list of
651 % todos.} Below is the effect of the option shown using the code:
652 % \todo[noprepend, caption={Short note with noprepend}]{A very long
653 % and tedious note that cannot be on one line in the list of
654 % todos.}
655 % \begin{verbatim}
656 % \todo[prepend, caption={Short note with prepend}]{A very long and tedious
657 % note that cannot be on one line in the list of todos.}.
658 % \todo[noprepend, caption={Short note with noprepend}]{A very long and
659 % tedious note that cannot be on one line in the list of todos.}.
660 % \end{verbatim}
661 %
662 % \DescribeMacro{author}
663 % The |author| option takes a parameter, the name of the author.
664 % The given name is inserted in the todonote.
665 % \todo[author=Xavier]{Testing author option.}
666 % \todo[author=Xavier, inline]{Testing author option.}
667 % \begin{verbatim}
668 % \todo[author=Xavier]{Testing author option.}
669 % \todo[author=Xavier, inline]{Testing author option.}
670 % \end{verbatim}
671 %
672 % \subsection{Options for the \texttt{missingfigure} command}
673 %
674 % \DescribeMacro{figwidth}
675 % The |figwidth=length| option sets the width of the figure inserted by the
676 % |\missingfigure| command.
677 % Length values below $6cm$ might trigger some problems with the
678 % visual appearance.
679 % Try to compare the default of the missing figure command, when the
680 % option is given or not.
681 % \begin{verbatim}
682 % \missingfigure[figwidth=6cm]{Testing a long text string}
683 % \end{verbatim}
684 % \missingfigure[figwidth=6cm]{Testing a long text string}
685 % \begin{verbatim}
686 % \missingfigure{Testing a long text string}
687 % \end{verbatim}
688 % \missingfigure{Testing a long text string}
689 % \begin{wrapfigure}{r}[2cm]{6cm}
690 % \missingfigure[figwidth=6cm]{Add a test image \ldots}
691 % \end{wrapfigure}
692 % Another usage of the option is when |\missingfigure| is used in
693 % the wrapfigure environment.
694 % \begin{verbatim}
695 % \begin{wrapfigure}{r}[2cm]{6cm}
696 % \missingfigure[figwidth=6cm]{Add a test image \ldots}
697 % \end{wrapfigure}
698 % \end{verbatim}
699 %
700 % \DescribeMacro{figheight}
701 % The |figheight=length| option changes the height of the inserted
702 % missing figure.
703 % The default height is 4cm and using values lower than this might
704 % cause the warning sign to pop out of the gray area.
705 % \begin{verbatim}
706 % \missingfigure[figheight=6cm]{Testing a long text string}
707 % \end{verbatim}
708 % \missingfigure[figheight=6cm]{Testing}
709 %
710 %
711 % \DescribeMacro{figcolor}
712 % The |figcolor=color| options sets the background color of
713 % inserted missing figures.
714 % The default color is |black!40|.
715 % \begin{verbatim}
716 % \missingfigure[figcolor=white]{Testing figcolor}
717 % \end{verbatim}
718 % \missingfigure[figcolor=white]{Testing figcolor}
719 %
720 %
721 %
722 % \subsection{Options for the \texttt{listoftodos} command}
723 % The |\listoftodos| command takes one optional argument, that
724 % defines the name of the inserted list of todos.
725 % \begin{verbatim}
726 % \listoftodos[I can be called anything]
727 % \end{verbatim}
728 %
729 %
730 % \subsection{Troubleshooting}
731 % \subsubsection{Missing Lua files}
732 % A potential error message when Lua source files are not found, is the
733 % following:
734 % \begin{verbatim}
735 % ! LuaTeX error [\directlua]:1: module 'luatodonotes' not found:
736 % no field package.preload['luatodonotes']
737 % [luatexbase.loader] Search failed
738 % [kpse lua searcher] file not found: 'luatodonotes'
739 % [kpse C searcher] file not found: 'luatodonotes'
740 % [oberdiek.luatex.kpse_module_loader]-eroux Search failed
741 % stack traceback:
742 % [C]: in function 'require'
743 % [\directlua]:1: in main chunk.
744 % l.250 \directlua{require("luatodonotes")}
745 % \end{verbatim}
746 % This means that the file |luatodonotes.lua| cannot be found by Lua\TeX.
747 % It depends on the version of your \TeX{} installation in which directories
748 % Lua\TeX{} is looking for Lua source files.
749 % You can query these paths with the following command:
750 % \begin{verbatim}
751 % kpsewhich -show-path=lua\end{verbatim}
752 % See the |kpathsea|
753 % documentation\footnote{\url{http://tug.org/texinfohtml/kpathsea.html}} for
754 % the interpretation of this path.
755 % The Lua source files of the |luatodonotes| package should be in one of the
756 % searched directories.
757 % You can modify the path in your \TeX{} configuration or using environment
758 % variables.
759 % You can query kpathsea for a file using the default \TeX{} search path with:
760 % \begin{verbatim}
761 % kpsewhich luatodonotes.lua\end{verbatim}
762 % Be sure to run |texhash| (as root if needed) after moving files into the
763 % texmf tree.
764 %
765 % \subsubsection{The \texttt{debug} option}
766 % You can load the package with the option |debug| (see
767 % Section~\ref{subsecPackageOptions}).
768 % It gives some additional information in the console while running Lua\TeX{}
769 % and draws additional information into the output document.
770 % For example, the size of the computed areas, in which the labels are placed,
771 % is shown in the document.
772 % Depending on the chosen layout algorithm some intermediate steps of the
773 % algorithms are given.
774 %
775 %
776 %
777 %
778 %
779 % \subsection{Known issues}
780 % \subsubsection{Package loading order}
781 % The luatodonotes package requires the following packages:
782 % \begin{multicols}{2}
783 % \begin{itemize}
784 % \item ifthen
785 % \item xkeyval
786 % \item xcolor
787 % \item tikz
788 % \item graphicx (is loaded via the tikz package)
789 % \item luacode
790 % \item luatex
791 % \item atbegshi
792 % \item xstring
793 % \item zref-abspage
794 % \item ifoddpage
795 % \item soul
796 % \item soulpos
797 % \end{itemize}
798 % \end{multicols}
799 % \noindent
800 % When luatodonotes are loaded in the preamble, the package checks
801 % if these packages all are loaded. If that is not the case it loads
802 % the missing packages with no options given.
803 % If you want to give some specific options to some of these
804 % packages, you have to load them \emph{before} the luatodonotes
805 % package, otherwise you will get an ''Option clash'' error when
806 % latex works on the document.
807 %
808 % If both the menukeys and the xcolor (with the option \verb!table!)
809 % package should be loaded, the following order must be used.
810 % \begin{verbatim}
811 %\usepackage[table]{xcolor}
812 %\usepackage{todonotes}
813 %\usepackage{menukeys}
814 % \end{verbatim}
815 %
816 % \subsubsection{Spacing around inserted notes}
817 % Inserted todo commands will eat the white space after the command.
818 % \begin{verbatim}
819 %Testing\todo{Does this eat the space?} testing.\end{verbatim}
820 % \noindent
821 % Testing\todo{Does this eat the space?} testing.
822 %
823 % This can be prevented by adding curly parenthesis after the
824 % todo command, like shown below.
825 % \begin{verbatim}
826 %Testing\todo{Does this eat the space?}{} testing.\end{verbatim}
827 % \noindent
828 % Testing\todo{Does this eat the space?}{} testing.
829 %
830 %
831 %
832 % \subsubsection{Conflicts with the amsart documentclass}
833 % The |amsart| document class redefines some internal commands that
834 % is used by the todonotes package, this will cause an malfunctioning
835 % |\listoftodos| command.
836 % The following code to circumvent the problem was given by Dan
837 % Luecking on comp.text.tex
838 % \begin{verbatim}
839 % \makeatletter
840 % \providecommand\@dotsep{5}
841 % \makeatother
842 % \listoftodos\relax
843 % \end{verbatim}
844 %
845 % NOT TESTED
846 % NOT TESTED
847 % NOT TESTED
848 %
849 % Dominique suggests the following workaround.
850 % \begin{verbatim}
851 % \makeatletter
852 % \providecommand\@dotsep{5}
853 % \def\listtodoname{List of Todos}
854 % \def\listoftodos{\@starttoc{tdo}\listtodoname}
855 % \makeatother
856 % \end{verbatim}
857 %
858 %
859 %
860 % \subsubsection{Unknown option ''remember picture''}
861 % If latex throws the error
862 % \begin{verbatim}
863 % Package tikz Error: I do not know what to do with the option ``remember picture''.
864 % \end{verbatim}
865 % It probably means that your latex installation is outdated, as
866 % only newer versions of latex driver for tikz supports the
867 % |remember picture| option.
868 % For additional info consult
869 % ''Section 10.2.2 Producing PDF Output'' in the tikz manual.
870 % \url{http://mirror.ctan.org/graphics/pgf/base/doc/pgfmanual.pdf}
871 %
872 %
873 %
874 % \subsubsection{List of todo heading is not correctly formatted}
875 % If using natbib, the todonotes list title gets screwed up unless
876 % you do something like this:
877 % \begin{verbatim}
878 % \makeatletter\let\chapter\@undefined\makeatother
879 % \end{verbatim}
880 % Suggestion by Richard Stanton.
881 %
882 %
883 %
884 % \subsubsection{Some commands not working inside notes}
885 % Some commands will not work like expected, when used inside of a note.
886 % They will cause errors when processing the document or have simply no effect.
887 % This is caused by the mechanism used to layout the notes:
888 % The content is written into a hbox when a |\todo| is encountered.
889 % The contents of this box are then stored until the note is typeset.
890 % By that time the contents are taken out of the hbox (by |\unhbox|) and put
891 % into a |\parbox| with the width required for the note.
892 % I don't have a solution for this problem yet.
893 %
894 %
895 %
896 %
897 %
898 % \iffalse
899 % \StopEventually{\PrintChanges\PrintIndex}
900 % \fi
901 % \StopEventually{\clearpage\pdfbookmark{Changes}{changes}\PrintChanges}
902 %
903 % \newpage
904 % \section{Implementation}
905 % \begin{environment}{luatodonotes.lua}
906 % In this section only the source code of the LaTeX package file
907 % (|luatodonotes.sty|) is shown.
908 % The Lua code is contained in |luatodonotes.lua| and documented by comments
909 % inside this file.
910 % These comments are primarily describing technical aspects.
911 % Information about the implemented algorithms and some theoretical
912 % considerations can be found in the following documents:
913 % \begin{itemize}
914 % \item Kindermann, P., Lipp, F., and Wolff, A.:
915 % Luatodonotes: Boundary Labeling for Annotations in Texts.
916 % In: Duncan, C. and Symvonis, A. (eds.) Proc. 22nd Int. Sympos. Graph Drawing GD'14.
917 % LNCS, vol. 8871, pp. 76-88. Springer, Heidelberg (2014)
918 % \url{http://dx.doi.org/10.1007/978-3-662-45803-7_7}
919 % \item Lipp, F.:
920 % Boundary Labeling for Annotations in Texts.
921 % Master thesis, 2014.
922 % \url{http://www1.pub.informatik.uni-wuerzburg.de/pub/theses/2014-lipp-master.pdf}
923 % \end{itemize}
924 % \changes{0.2}{2014/09/08}{Compatibility with csquotes package (notes were
925 % displayed multiple times when used in \texttt{\textbackslash blockquote}
926 % command)}
927 % \changes{0.2}{2015/02/28}{Correct height calculation for notes with modified
928 % fontsize}
929 % \changes{0.2}{2015/02/28}{Make Lua variables and functions local or put them
930 % into luatodonotes array (don't pollute global namespace)}
931 % \changes{0.2}{2015/03/03}{Fix problems with recent versions of lualibs}
932 % \changes{0.3}{2015/10/30}{Fix problems with doubled notes when code is read
933 % multiple times (e.g., by tabularx)}
934 % \changes{0.3}{2015/11/16}{Deal with notes without a page number (happens when
935 % placed in \texttt{\textbackslash caption}, e.g.)}
936 % \changes{0.3}{2015/11/30}{Remove two variables from Lua global namespace}
937 % \changes{0.3}{2015/12/02}{Less console output unless debug option is set}
938 % \changes{0.5}{2020/01/19}{Fixed bugs when using \texttt{poLeadersAvoidLines}
939 % as positioning algorithm in newer LuaTeX versions because some APIs have
940 % changed}
941 % \changes{0.5}{2020/01/20}{Bugfix: The line position calculation didn't use
942 % the current page height, which caused an offset on these positions in
943 % documents not using a4paper}
944 % \end{environment}
945 %
946 % \subsection{Dependencies and definitions}
947 % Make sure that the classical |todonotes| package is not loaded as we redefine
948 % its commands.
949 % Additionally we pretend that |todonotes| 1.0.2 is already loaded.
950 % So later attempts to load package |todonotes| are simply ignored.
951 % Loading both packages in the same document would produce errors (like
952 % ``Command already defined'').
953 % \changes{0.3}{2015/12/01}{Ensure that package \texttt{todonotes} is not
954 % loaded}
955 % \begin{macrocode}
956 \@ifpackageloaded{todonotes}{
957 \PackageError{luatodonotes}{%
958 Conflicting packages todonotes and luatodonotes\MessageBreak
959 loaded. Aborting.}{%
960 The package luatodonotes was designed as a replacement for todonotes. So it
961 is not possible (and not reasonable) to include both of them in the same
962 document.%
963 If you want to use luatodonotes you should delete the todonotes
964 package from\MessageBreak
965 your preamble.\MessageBreak}
966 }{}
967 \expandafter\def\csname [email protected]\endcsname{2014/07/14}
968 % \end{macrocode}
969 % Check if Lua\TeX{} is used.
970 % \changes{0.2}{2015/02/23}{Check if LuaTeX is used at begin of package}
971 % \begin{macrocode}
972 \RequirePackage{ifluatex}
973 \ifluatex\else
974 \PackageError{luatodonotes}{LuaTeX is required for this package. Aborting.}{%
975 This package can only be used with the LuaTeX engine\MessageBreak
976 (command `lualatex'). Package loading has been stopped\MessageBreak
977 to prevent additional errors.}
978 \fi
979 % \end{macrocode}
980 % Loads the packages dependencies.
981 % \begin{macrocode}
982 \RequirePackage{ifthen}
983 \RequirePackage{xkeyval}
984 \RequirePackage{xcolor}
985 \RequirePackage{tikz}
986 \usetikzlibrary{positioning}
987 \usetikzlibrary{intersections}
988 \usetikzlibrary{decorations.pathmorphing}
989 \RequirePackage{luacode}
990 \RequirePackage{atbegshi}
991 \RequirePackage{xstring}
992 \RequirePackage{zref-abspage}
993 \RequirePackage{ifoddpage}
994 \RequirePackage{soul}
995 \RequirePackage{soulpos}
996 \RequirePackage{etoolbox}
997 % \end{macrocode}
998 % The package |luatex| must not be loaded in new TeX distributions as the
999 % definition of |\newattribute| in it conflicts with newer versions of
1000 % Lua\LaTeX.
1001 % Older versions of |luatexbase| include the package |luatex| by themselves, for
1002 % newer versions the Lua\LaTeX kernel should include the commands that we need
1003 % (e.\,g., |\newattribute|).
1004 % \changes{0.3}{2015/11/12}{Remove package \texttt{luatex} for current
1005 % versions of Lua\LaTeX (as it caused problems)}
1006 % \begin{macrocode}
1007 \@ifpackagelater{luatexbase}{2013/05/04}{}{
1008 \RequirePackage{luatex}
1009 }
1010 % \end{macrocode}
1011 % Some default values are set
1012 % \begin{macrocode}
1013 \newcommand{\@todonotes@text}{}%
1014 \newcommand{\@todonotes@backgroundcolor}{orange}
1015 \newcommand{\@todonotes@linecolor}{black!30}
1016 \newcommand{\@todonotes@bordercolor}{black}
1017 \newcommand{\@todonotes@leaderwidth}{1.6pt}
1018 \newcommand{\@todonotes@textsize}{\normalsize}
1019 \newcommand{\@todonotes@figwidth}{\linewidth}
1020 \newcommand{\@todonotes@figheight}{4cm}
1021 \newcommand{\@todonotes@figcolor}{black!40}
1022 % \end{macrocode}
1023 % Default values for variables added by luatodonotes
1024 % \begin{macrocode}
1025 \newcommand{\@todonotes@positioning}{inputOrderStacks}
1026 \newcommand{\@todonotes@splitting}{none}
1027 \newcommand{\@todonotes@leadertype}{opo}
1028 \newcommand{\@todonotes@interNoteSpace}{5pt}
1029 \newcommand{\@todonotes@noteInnerSep}{5pt}
1030 \newcommand{\@todonotes@routingAreaWidth}{0.4cm}
1031 \newcommand{\@todonotes@minNoteWidth}{2.0cm}
1032 \newcommand{\@todonotes@distanceNotesPageBorder}{0.5cm}
1033 \newcommand{\@todonotes@distanceNotesText}{0.2cm}
1034 \newcommand{\@todonotes@rasterHeight}{1cm}
1035 \newcommand{\@todonotes@additionalMargin}{2cm}
1036 % \end{macrocode}
1037 % \begin{macrocode}
1038 \AtBeginDocument{
1039 \ifx\undefined\phantomsection
1040 \newcommand{\phantomsection}{}
1041 \fi
1042 }
1043 % \end{macrocode}
1044 %
1045 % \subsection{Declaration of options for the package}
1046 % In this part the various options for
1047 % the package are defined.
1048 %
1049 % Define the default text strings and set localization options for
1050 % the danish and german languages.
1051 % \begin{macrocode}
1052 \newcommand{\@todonotes@todolistname}{Todo list}
1053 \newcommand{\@todonotes@MissingFigureText}{Figure}
1054 \newcommand{\@todonotes@MissingFigureUp}{Missing}
1055 \newcommand{\@todonotes@MissingFigureDown}{figure}
1056 \newcommand{\@todonotes@SetTodoListName}[1]
1057 {\renewcommand{\@todonotes@todolistname}{#1}}
1058 \newcommand{\@todonotes@SetMissingFigureText}[1]
1059 {\renewcommand{\@todonotes@MissingFigureText}{#1}}
1060 \newcommand{\@todonotes@SetMissingFigureUp}[1]
1061 {\renewcommand{\@todonotes@MissingFigureUp}{#1}}
1062 \newcommand{\@todonotes@SetMissingFigureDown}[1]
1063 {\renewcommand{\@todonotes@MissingFigureDown}{#1}}
1064 \newif{\if@todonotes@reverseMissingFigureTriangle}
1065 \DeclareOptionX{catalan}{
1066 \@todonotes@SetTodoListName{Llista de feines pendents}%
1067 \@todonotes@SetMissingFigureText{Figura}%
1068 \@todonotes@SetMissingFigureUp{Figura}%
1069 \@todonotes@SetMissingFigureDown{pendent}%
1070 }
1071 \DeclareOptionX{croatian}{%
1072 \@todonotes@SetTodoListName{Popis obveza}%
1073 \@todonotes@SetMissingFigureText{Slika}%
1074 \@todonotes@SetMissingFigureUp{Nedostaje}%
1075 \@todonotes@SetMissingFigureDown{slika}%
1076 }
1077 \DeclareOptionX{danish}{%
1078 \@todonotes@SetTodoListName{G\o{}rem\aa{}lsliste}%
1079 \@todonotes@SetMissingFigureText{Figur}%
1080 \@todonotes@SetMissingFigureUp{Manglende}%
1081 \@todonotes@SetMissingFigureDown{figur}%
1082 }
1083 \DeclareOptionX{dutch}{%
1084 \@todonotes@SetTodoListName{Lijst van onafgewerkte taken}%
1085 \@todonotes@SetMissingFigureText{Figuur}%
1086 \@todonotes@SetMissingFigureUp{Ontbrekende}%
1087 \@todonotes@SetMissingFigureDown{figuur}%
1088 }
1089 \DeclareOptionX{english}{%
1090 \@todonotes@SetTodoListName{Todo list}%
1091 \@todonotes@SetMissingFigureText{Figure}%
1092 \@todonotes@SetMissingFigureUp{Missing}%
1093 \@todonotes@SetMissingFigureDown{figure}%
1094 }
1095 \DeclareOptionX{french}{%
1096 \@todonotes@SetTodoListName{Liste des points \`a traiter}%
1097 \@todonotes@SetMissingFigureText{Figure}%
1098 \@todonotes@SetMissingFigureUp{Figure}%
1099 \@todonotes@SetMissingFigureDown{manquante}%
1100 \@todonotes@reverseMissingFigureTrianglefalse
1101 }
1102 \DeclareOptionX{german}{%
1103 \@todonotes@SetTodoListName{Liste der noch zu erledigenden Punkte}%
1104 \@todonotes@SetMissingFigureText{Abbildung}%
1105 \@todonotes@SetMissingFigureUp{Fehlende}%
1106 \@todonotes@SetMissingFigureDown{Abbildung}%
1107 }
1108 \DeclareOptionX{italian}{
1109 \@todonotes@SetTodoListName{Elenco delle cose da fare}%
1110 \@todonotes@SetMissingFigureText{Figura}%
1111 \@todonotes@SetMissingFigureUp{Figura}%
1112 \@todonotes@SetMissingFigureDown{mancante}%
1113 }
1114 \DeclareOptionX{ngerman}{%
1115 \@todonotes@SetTodoListName{Liste der noch zu erledigenden Punkte}%
1116 \@todonotes@SetMissingFigureText{Abbildung}%
1117 \@todonotes@SetMissingFigureUp{Fehlende}%
1118 \@todonotes@SetMissingFigureDown{Abbildung}%
1119 }
1120 \DeclareOptionX{portuguese}{
1121 \@todonotes@SetTodoListName{Lista de tarefas pendentes}%
1122 \@todonotes@SetMissingFigureText{Figura}%
1123 \@todonotes@SetMissingFigureUp{Figura}%
1124 \@todonotes@SetMissingFigureDown{pendente}%
1125 }
1126 \DeclareOptionX{spanish}{
1127 \@todonotes@SetTodoListName{Lista de tareas pendientes}%
1128 \@todonotes@SetMissingFigureText{Figura}%
1129 \@todonotes@SetMissingFigureUp{Figura}%
1130 \@todonotes@SetMissingFigureDown{pendiente}%
1131 }
1132 \DeclareOptionX{swedish}{%
1133 \@todonotes@SetTodoListName{Att g\"{o}ra-lista}%
1134 \@todonotes@SetMissingFigureText{Figur}%
1135 \@todonotes@SetMissingFigureUp{Figur}%
1136 \@todonotes@SetMissingFigureDown{saknas}%
1137 }
1138 % \end{macrocode}
1139 % Create a counter, for storing the number of inserted todos.
1140 % \begin{macrocode}
1141 \newcounter{@todonotes@numberoftodonotes}
1142 % \end{macrocode}
1143 % Create a counter, for storing the number of lines in the current todoarea.
1144 % \begin{macrocode}
1145 \newcounter{@todonotes@numberofLinesInArea}
1146 % \end{macrocode}
1147 % Toggle whether the package should obey the global draft option.
1148 % \begin{macrocode}
1149 \newif{\if@todonotes@obeyDraft}
1150 \DeclareOptionX{obeyDraft}{\@todonotes@obeyDrafttrue}
1151 \newif{\if@todonotes@isDraft}
1152 \DeclareOptionX{draft}{\@todonotes@isDrafttrue}
1153 \DeclareOptionX{draftcls}{\@todonotes@isDrafttrue}
1154 \DeclareOptionX{draftclsnofoot}{\@todonotes@isDrafttrue}
1155 \newif{\if@todonotes@obeyFinal}
1156 \DeclareOptionX{obeyFinal}{\@todonotes@obeyFinaltrue}
1157 \newif{\if@todonotes@isFinal}
1158 \DeclareOptionX{final}{\@todonotes@isFinaltrue}
1159 % \end{macrocode}
1160 % Make it possible to disable the functionality
1161 % of the package. If this option is given, the
1162 % commands |\todo{}| and |\listoftodos| are defined
1163 % as commands with no effect. (But you can still
1164 % compile you document with these commands).
1165 % \begin{macrocode}
1166 \newif{\if@todonotes@disabled}
1167 \DeclareOptionX{disable}{\@todonotes@disabledtrue}
1168 % \end{macrocode}
1169 % Show small boxes in the list of todos with the color of the
1170 % inserted todonotes.
1171 % \begin{macrocode}
1172 \newif{\if@todonotes@colorinlistoftodos}
1173 \DeclareOptionX{colorinlistoftodos}{\@todonotes@colorinlistoftodostrue}
1174 % \end{macrocode}
1175 % We only define dvistyle for compatibility with todonotes.
1176 % The option was intented for use with \texttt{tex}, there should be no problems
1177 % using \texttt{luatex}.
1178 % So we ignore this option and issue a warning.
1179 % \begin{macrocode}
1180 \DeclareOptionX{dvistyle}{\PackageWarningNoLine{luatodonotes}
1181 {Parameter dvistyle is not supported by luatodonotes.
1182 Ignoring this option}}
1183 % \end{macrocode}
1184 % Create a color option.
1185 % \begin{macrocode}
1186 \define@key{luatodonotes.sty}%
1187 {color}{
1188 \renewcommand{\@todonotes@backgroundcolor}{#1}
1189 \renewcommand{\@todonotes@linecolor}{#1}}
1190 % \end{macrocode}
1191 % Make the background color of the notes as
1192 % an option.
1193 % \begin{macrocode}
1194 \define@key{luatodonotes.sty}%
1195 {backgroundcolor}{\renewcommand{\@todonotes@backgroundcolor}{#1}}
1196 % \end{macrocode}
1197 % Make the line color of the notes as
1198 % an option.
1199 % \begin{macrocode}
1200 \define@key{luatodonotes.sty}%
1201 {linecolor}{\renewcommand{\@todonotes@linecolor}{#1}}
1202 % \end{macrocode}
1203 % Make the color of the notes box color as
1204 % an option.
1205 % \begin{macrocode}
1206 \define@key{luatodonotes.sty}%
1207 {bordercolor}{\renewcommand{\@todonotes@bordercolor}{#1}}
1208 % \end{macrocode}
1209 % Make the width of the leader line as
1210 % an option.
1211 % It is later set as \texttt{line width} in TikZ.
1212 % \begin{macrocode}
1213 \define@key{luatodonotes.sty}%
1214 {leaderwidth}{\renewcommand{\@todonotes@leaderwidth}{#1}}
1215 % \end{macrocode}
1216 % Set whether short captions given as arguments to the todo command
1217 % should be included in the inserted todonote.
1218 % \begin{macrocode}
1219 \newif{\if@todonotes@prependcaptionglobal}
1220 \@todonotes@prependcaptionglobalfalse
1221 \DeclareOptionX{prependcaption}{\@todonotes@prependcaptionglobaltrue}
1222 % \end{macrocode}
1223 % This option is only there for compatibility with todonotes.
1224 % We ignore it and issue a warning because the width of our labels is
1225 % determined dynamically based on the page layout.
1226 % \begin{macrocode}
1227 \define@key{luatodonotes.sty}%
1228 {textwidth}{\PackageWarningNoLine{luatodonotes}
1229 {Parameter textwidth is not supported by luatodonotes}}
1230 % \end{macrocode}
1231 % Make the text size as an option. It requires some magic with the
1232 % |\csname| and |\endcsname| macros, as commands cannot be taken as
1233 % options for a package.
1234 % \begin{macrocode}
1235 \define@key{luatodonotes.sty}%
1236 {textsize}{\renewcommand{\@todonotes@textsize}{\csname #1\endcsname}}
1237 % \end{macrocode}
1238 % Add option for shadows behind the inserted notes
1239 % \begin{macrocode}
1240 \newif{\if@todonotes@shadowenabled}
1241 \@todonotes@shadowenabledfalse
1242 \DeclareOptionX{shadow}{\@todonotes@shadowenabledtrue
1243 \usetikzlibrary{shadows}}
1244 % \end{macrocode}
1245 % Add option for the default width of the figure inserted with
1246 % |\missingfigure|.
1247 % \begin{macrocode}
1248 \define@key{luatodonotes.sty}%
1249 {figwidth}{\renewcommand{\@todonotes@figwidth}{#1}}
1250 \define@key{luatodonotes.sty}%
1251 {figheight}{\renewcommand{\@todonotes@figheight}{#1}}
1252 \define@key{luatodonotes.sty}%
1253 {figcolor}{\renewcommand{\@todonotes@figcolor}{#1}}
1254 % \end{macrocode}
1255 % \begin{macro}{s,bezier,opo,po}
1256 % Provide shorthand options for the most common leader styles.
1257 % \changes{0.3}{2015/12/03}{Provide shorthand commands for most common leader
1258 % styles}
1259 % \begin{macrocode}
1260 \DeclareOptionX{po}%
1261 {\setkeys{luatodonotes.sty}{leadertype=po,positioning=poLeadersAvoidLines}}
1262 \DeclareOptionX{s}%
1263 {\setkeys{luatodonotes.sty}{leadertype=s,positioning=sLeaderNorthEastBelowStacks}}
1264 \DeclareOptionX{bezier}%
1265 {\setkeys{luatodonotes.sty}{leadertype=sBezier,positioning=sLeaderNorthEastBelowStacks}}
1266 \DeclareOptionX{opo}%
1267 {\setkeys{luatodonotes.sty}{leadertype=opo,positioning=inputOrderStacks}}
1268 % \end{macrocode}
1269 % \end{macro}
1270 % Specify the name of the algorithm used to specify the position of the labels.
1271 % \begin{macrocode}
1272 \define@key{luatodonotes.sty}%
1273 {positioning}{\renewcommand{\@todonotes@positioning}{#1}}
1274 % \end{macrocode}
1275 % Specify the name of the algorithm used to split the notes for left and right side.
1276 % \begin{macrocode}
1277 \define@key{luatodonotes.sty}%
1278 {splitting}{\renewcommand{\@todonotes@splitting}{#1}}
1279 % \end{macrocode}
1280 % Specify the type of leaders that are drawn.
1281 % \begin{macrocode}
1282 \define@key{luatodonotes.sty}%
1283 {leadertype}{\renewcommand{\@todonotes@leadertype}{#1}}
1284 % \end{macrocode}
1285 % Specify the vertical distance between the notes.
1286 % \begin{macrocode}
1287 \define@key{luatodonotes.sty}%
1288 {interNoteSpace}{\renewcommand{\@todonotes@interNoteSpace}{#1}}
1289 % \end{macrocode}
1290 % Specify the distance from the text inside the notes to the border.
1291 % \begin{macrocode}
1292 \define@key{luatodonotes.sty}%
1293 {noteInnerSep}{\renewcommand{\@todonotes@noteInnerSep}{#1}}
1294 % \end{macrocode}
1295 % Specify the width of the routing area used for $opo$- and $os$-leaders.
1296 % \begin{macrocode}
1297 \define@key{luatodonotes.sty}%
1298 {routingAreaWidth}{\renewcommand{\@todonotes@routingAreaWidth}{#1}}
1299 % \end{macrocode}
1300 % Minimum width of notes in one margin beside the text to be considered for
1301 % label placement.
1302 % \begin{macrocode}
1303 \define@key{luatodonotes.sty}%
1304 {minNoteWidth}{\renewcommand{\@todonotes@minNoteWidth}{#1}}
1305 % \end{macrocode}
1306 % Specify horizontal distance from the notes to the borders of the page.
1307 % \begin{macrocode}
1308 \define@key{luatodonotes.sty}%
1309 {distanceNotesPageBorder}%
1310 {\renewcommand{\@todonotes@distanceNotesPageBorder}{#1}}
1311 % \end{macrocode}
1312 % Specify the horizontal distance between the notes and the text area.
1313 % \begin{macrocode}
1314 \define@key{luatodonotes.sty}%
1315 {distanceNotesText}{\renewcommand{\@todonotes@distanceNotesText}{#1}}
1316 % \end{macrocode}
1317 % Specify the height of the raster used for the $po$-leader algorithm.
1318 % \begin{macrocode}
1319 \define@key{luatodonotes.sty}%
1320 {rasterHeight}{\renewcommand{\@todonotes@rasterHeight}{#1}}
1321 % \end{macrocode}
1322 % \begin{macro}{additionalMargin}
1323 % Control whether the margin should be enlarged for the notes and its width.
1324 % \changes{0.3}{2015/12/01}{Introduce package option \texttt{additionalMargin}}
1325 % \changes{0.4}{2016/04/01}{Fixed problems of the \texttt{additionalMargin}
1326 % option with certain documentclasses}
1327 % \changes{0.5}{2017/11/21}{Make \texttt{additionalMargin} compatible with
1328 % \texttt{\textbackslash newgeometry}}
1329 % \changes{0.5}{2020/01/19}{Adapt to new LuaTeX versions, which provide command
1330 % \texttt{\textbackslash pagewidth} instead of
1331 % \texttt{\textbackslash pdfpagewidth} (but stay backwards compatible)}
1332 % \begin{macrocode}
1333 \newif{\if@todonotes@additionalMarginEnabled}
1334 \@todonotes@additionalMarginEnabledfalse
1335 \define@key{luatodonotes.sty}%
1336 {additionalMargin}[\@todonotes@additionalMargin]{%
1337 \@todonotes@additionalMarginEnabledtrue
1338 \renewcommand{\@todonotes@additionalMargin}{#1}}
1339 % \end{macrocode}
1340 % \end{macro}
1341 % This option is used to activate debug mode.
1342 % Luatex prints more verbose output to the commandline in this mode.
1343 % Furthermore, some of the algorithms also print debugging hints onto the
1344 % output page.
1345 % \begin{macrocode}
1346 \newif{\if@todonotes@debugenabled}
1347 \@todonotes@debugenabledfalse
1348 \DeclareOptionX{debug}{\@todonotes@debugenabledtrue}
1349 % \end{macrocode}
1350 % Finally process the given options.
1351 % \begin{macrocode}
1352 \ProcessOptionsX*
1353 % \end{macrocode}
1354 % If the |obeyDraft| is given, check whether one of the |draft|,
1355 % |draftcls| or |draftclsnofoot|
1356 % options are given and enable or disable the functionality of this
1357 % package.
1358 % If the |obeyFinal| option is given together with the |final| option
1359 % the todonotes are disabled.
1360 % The |disable| option will overrule the effect of |obeyDraft|.
1361 % \begin{macrocode}
1362 \if@todonotes@disabled
1363 \else
1364 \if@todonotes@obeyDraft
1365 \@todonotes@disabledtrue
1366 \if@todonotes@isDraft
1367 \@todonotes@disabledfalse
1368 \fi
1369 \fi
1370 \if@todonotes@obeyFinal
1371 \@todonotes@disabledfalse
1372 \if@todonotes@isFinal
1373 \@todonotes@disabledtrue
1374 \fi
1375 \fi
1376 \fi
1377 % \end{macrocode}
1378 % If the option |additionalMargin| is given, we enlarge the margins for the notes.
1379 % \begin{macrocode}
1380 \if@todonotes@additionalMarginEnabled
1381 \newlength{\@todonotes@modpaperwidth}
1382 \AfterEndPreamble{%
1383 \@todonotes@setAdditionalMargin%
1384 % \end{macrocode}
1385 % Additionally, if the |geometry| package is loaded we hook into
1386 % |\Gm@changelayout| to repeat this computation whenever |\newgeometry| is
1387 % called.
1388 % \begin{macrocode}
1389 \ifdefined\Gm@changelayout
1390 \g@addto@macro{\Gm@changelayout}{\@todonotes@setAdditionalMargin}
1391 \fi
1392 }%
1393 \fi%
1394 % \end{macrocode}
1395 % We simply increase the page size by the doubled value of |additionalMargin|
1396 % and move the contents to the right using |\hoffset|.
1397 % \begin{macrocode}
1398 \newcommand{\@todonotes@setAdditionalMargin}{
1399 \setlength{\@todonotes@modpaperwidth}{\paperwidth}%
1400 \addtolength{\@todonotes@modpaperwidth}{\@todonotes@additionalMargin}%
1401 \addtolength{\@todonotes@modpaperwidth}{\@todonotes@additionalMargin}%
1402 \ifdefined\pdfpagewidth\else\let\pdfpagewidth\pagewidth\fi
1403 \pdfpagewidth=\@todonotes@modpaperwidth%
1404 \addtolength{\hoffset}{\@todonotes@additionalMargin}%
1405 }
1406 % \end{macrocode}
1407 % \subsection{Initialisation of our Lua code}
1408 % In this part we define some of the variables used by Lua depending on the
1409 % package options and do some other initialisation tasks.
1410 %
1411 % We first need some temporary dimensions, which are written by \TeX\ and read
1412 % from Lua.
1413 % We use dimensions here because it is easier to access \TeX\ dimensions from
1414 % Lua than \LaTeX\ lengths.
1415 % We use |tex.dimen| in Lua to access dimensions.
1416 % The first dimensions are used when extracting the absolute coordinates of a
1417 % position on the page.
1418 % \begin{macrocode}
1419 \newdimen\@todonotes@extractx
1420 \newdimen\@todonotes@extracty
1421 % \end{macrocode}
1422 % The following savebox and dimensions are used to calculate the height of a
1423 % certain label.
1424 % The box and dimensions are filled by \TeX\ and then read from Lua.
1425 % \begin{macrocode}
1426 \newsavebox\@todonotes@heightcalcbox
1427 \newdimen\@todonotes@heightcalcboxdepth
1428 \newdimen\@todonotes@heightcalcboxheight
1429 % \end{macrocode}
1430 % The following savebox is used to store the contents of a note and is then
1431 % read from Lua.
1432 % \begin{macrocode}
1433 \newsavebox\@todonotes@notetextbox
1434 % \end{macrocode}
1435 % The following dimensions are used to read |\baselineskip|,
1436 % |\normalbaselineskip| and |\f@size| from Lua.
1437 % We need |\normalbaselineskip| as |\baselineskip| is set to 0 inside
1438 % tabular cells.
1439 % Dimension |\@todonotes@currentsidemargin| is set to the left margin,
1440 % i.\,e., to the value of length |\oddsidemargin| or
1441 % |\evensidemargin| depending on the type page.
1442 % \changes{0.3}{2015/10/30}{Fix position of marker in table cells
1443 % (\texttt{\textbackslash baselineskip} is empty inside tables)}
1444 % \begin{macrocode}
1445 \newdimen\@todonotes@baselineskip
1446 \newdimen\@todonotes@normalbaselineskip
1447 \newdimen\@todonotes@fontsize
1448 \newdimen\@todonotes@currentsidemargin
1449 % \end{macrocode}
1450 % Loading our main Lua file.
1451 % \begin{macrocode}
1452 \directlua{require("luatodonotes")}
1453 % \end{macrocode}
1454 % Setting variables to values given by package options.
1455 % \begin{macrocode}
1456 \directlua{luatodonotes.noteInnerSep =
1457 string.todimen("\luatexluaescapestring{\@todonotes@noteInnerSep}")}
1458 \directlua{luatodonotes.noteInterSpace =
1459 string.todimen("\luatexluaescapestring{\@todonotes@interNoteSpace}")}
1460 \directlua{luatodonotes.routingAreaWidth =
1461 string.todimen("\luatexluaescapestring{\@todonotes@routingAreaWidth}")}
1462 \directlua{luatodonotes.minNoteWidth =
1463 string.todimen("\luatexluaescapestring{\@todonotes@minNoteWidth}")}
1464 \directlua{luatodonotes.distanceNotesPageBorder =
1465 string.todimen("\luatexluaescapestring{\@todonotes@distanceNotesPageBorder}")}
1466 \directlua{luatodonotes.distanceNotesText =
1467 string.todimen("\luatexluaescapestring{\@todonotes@distanceNotesText}")}
1468 \directlua{luatodonotes.rasterHeight =
1469 string.todimen("\luatexluaescapestring{\@todonotes@rasterHeight}")}
1470 % \end{macrocode}
1471 % Set the variables for the used algorithms and leader types depending on the
1472 % corresponding package options.
1473 % \begin{macrocode}
1474 \directlua{luatodonotes.setPositioningAlgo("\luatexluaescapestring{\@todonotes@positioning}")}
1475 \directlua{luatodonotes.setSplittingAlgo("\luatexluaescapestring{\@todonotes@splitting}")}
1476 \directlua{luatodonotes.setLeaderType("\luatexluaescapestring{\@todonotes@leadertype}")}
1477 % \end{macrocode}
1478 % The following commands are used to detect the absolute positions of lines on
1479 % the page.
1480 %
1481 % We first need to define a command to be able to insert the position from
1482 % |\pdflastypos| into a write-whatsit in Lua.
1483 % We need this workaround because we cannot insert |\pdflastypos| directly into
1484 % the tokenlist in the Lua callback \texttt{callbackOutputLinePositions()}.
1485 % \begin{macrocode}
1486 \ifdefined\pdflastypos\else\let\pdflastypos\lastypos\fi
1487 \def\@todonotes@pdflastypos{\the\pdflastypos}
1488 % \end{macrocode}
1489 % The following commands are written to the temporary \texttt{lpo}-file.
1490 % When reading this file we call a Lua function for each line in the file and
1491 % thus can collect the line positions in a Lua table.
1492 % \begin{macrocode}
1493 \newcommand{\@todonotes@lineposition}[3]{%
1494 \directlua{luatodonotes.linePositionsAddLine(#1,#2,#3)}%
1495 }
1496 \newcommand{\@todonotes@nextpage}{%
1497 \directlua{luatodonotes.linePositionsNextPage()}%
1498 }%
1499 % \end{macrocode}
1500 % The following macro is used in \texttt{AtBeginShipout} to signal in the
1501 % \texttt{lpo}-file that a new page is started.
1502 % \begin{macrocode}
1503 \newcommand{\@todonotes@writeNextpageToLpo}{%
1504 \ifdefined\tf@lpo%
1505 \immediate\write\tf@lpo{\@backslashchar @todonotes@nextpage}%
1506 \fi
1507 }
1508 % \end{macrocode}
1509 % Depending on the debug-option of the package we set the corresponding Lua
1510 % variable here.
1511 % Additionally, we prepare to print our notes and leaders in foreground when in
1512 % debug mode.
1513 % \begin{macrocode}
1514 \if@todonotes@debugenabled
1515 \directlua{luatodonotes.todonotesDebug = true}
1516 \newcommand{\@todonotes@AtBeginShipoutUpperLeft}
1517 {\AtBeginShipoutUpperLeftForeground}
1518 \else
1519 \directlua{luatodonotes.todonotesDebug = false}
1520 \newcommand{\@todonotes@AtBeginShipoutUpperLeft}
1521 {\AtBeginShipoutUpperLeft}
1522 \fi
1523 % \end{macrocode}
1524 % Define commands that are used for every tikzpicture to disable
1525 % externalization.
1526 % We only call the |\tikzexternaldisable| command if it is defined (i.e., the
1527 % externalization library for TikZ is loaded).
1528 % Externalization is reenabled after the end of the group (if it was enabled
1529 % before).
1530 % \changes{0.5}{2018/04/08}{Disable TikZ externalization for our tikzpictures}
1531 % \begin{macrocode}
1532 \newcommand{\@todonotes@before@tikzpict}{\begingroup%
1533 \ifdefined\tikzexternaldisable\tikzexternaldisable\fi}
1534 \newcommand{\@todonotes@after@tikzpict}{\endgroup}
1535 % \end{macrocode}
1536 % Initialise the script when all Lua variables are set according to the package
1537 % options.
1538 % \begin{macrocode}
1539 \directlua{luatodonotes.initTodonotes()}
1540 % \end{macrocode}
1541 % Some definitions to highlight areas in text.
1542 % The first command is needed to accept control spaces (|\ |) in arguments for
1543 % soul commands.
1544 % After that we define the highlighting command used for todoareas.
1545 % \begin{macrocode}
1546 \soulregister{\ }{0}
1547 \newlength{\todonotes@textmark@width}
1548 \newlength{\todonotes@textmark@fontsize}
1549 \newlength{\todonotes@textmark@linebelow}
1550 \newlength{\todonotes@textmark@lineabove}
1551 \ulposdef{\todonotes@textmark@highlight}{%
1552 \setlength\todonotes@textmark@width\ulwidth%
1553 \setlength\todonotes@textmark@fontsize{\f@size pt}%
1554 \stepcounter{@todonotes@numberofLinesInArea}%
1555 \ifulstarttype{0}%
1556 {% begin of area
1557 \def\todonotes@textmark@decoLeft{}%
1558 \def\todonotes@textmark@shift{-2pt}%
1559 \addtolength\todonotes@textmark@width{2pt}%
1560 \setcounter{@todonotes@numberofLinesInArea}{1}}%
1561 {\def\todonotes@textmark@decoLeft{@todonotes@todoarea}%
1562 \def\todonotes@textmark@shift{-4pt}%
1563 \addtolength\todonotes@textmark@width{4pt}}%
1564 \ifulendtype{0}%
1565 {% last line of area
1566 \def\todonotes@textmark@decoRight{}%
1567 \addtolength\todonotes@textmark@width{2pt}%
1568 \directlua{luatodonotes.processLastLineInTodoArea()}}%
1569 {\def\todonotes@textmark@decoRight{@todonotes@todoarea}%
1570 \addtolength\todonotes@textmark@width{4pt}}%
1571 \newcommand{\@todonotes@nodeNamePrefix}%
1572 {@todonotes@\arabic{@todonotes@numberoftodonotes}%
1573 @\arabic{@todonotes@numberofLinesInArea} }%
1574 \hspace*{\todonotes@textmark@shift}{\smash{%
1575 \@todonotes@before@tikzpict%
1576 \begin{tikzpicture}[overlay,remember picture,
1577 deco/.style={}]%
1578 \setlength\todonotes@textmark@linebelow%
1579 {-0.95\dimexpr\baselineskip-\f@size pt\relax}%
1580 \setlength\todonotes@textmark@lineabove%
1581 {\dimexpr\f@size pt+\todonotes@textmark@linebelow\relax}%
1582 \coordinate
1583 (\@todonotes@nodeNamePrefix areaSW)
1584 at (0,\todonotes@textmark@linebelow);
1585 \coordinate
1586 (\@todonotes@nodeNamePrefix areaSE)
1587 at (\todonotes@textmark@width, \todonotes@textmark@linebelow);
1588 \coordinate
1589 (\@todonotes@nodeNamePrefix areaNE)
1590 at (\todonotes@textmark@width,\todonotes@textmark@lineabove);
1591 \coordinate
1592 (\@todonotes@nodeNamePrefix areaNW)
1593 at (0,\todonotes@textmark@lineabove);
1594 \draw[draw=green!70,fill=green,fill opacity=.2]
1595 (\@todonotes@nodeNamePrefix areaSW)
1596 decorate[\todonotes@textmark@decoLeft] {
1597 -- (\@todonotes@nodeNamePrefix areaNW)
1598 }
1599 -- (\@todonotes@nodeNamePrefix areaNE)
1600 decorate[\todonotes@textmark@decoRight] {
1601 -- (\@todonotes@nodeNamePrefix areaSE)
1602 }
1603 -- cycle;
1604 \end{tikzpicture}%
1605 \@todonotes@after@tikzpict%
1606 }}%
1607 }%
1608 % \end{macrocode}
1609 % \subsection{Options for the todo command}
1610 %
1611 % In this part the various options for
1612 % commands in the package are defined.
1613 % Set an arbitrarily fill color
1614 % \begin{macrocode}
1615 \newcommand{\@todonotes@currentlinecolor}{}%
1616 \newcommand{\@todonotes@currentbackgroundcolor}{}%
1617 \newcommand{\@todonotes@currentbordercolor}{}%
1618 \define@key{todonotes}{color}{%
1619 \renewcommand{\@todonotes@currentlinecolor}{#1}%
1620 \renewcommand{\@todonotes@currentbackgroundcolor}{#1}}%
1621 \define@key{todonotes}{linecolor}{%
1622 \renewcommand{\@todonotes@currentlinecolor}{#1}}%
1623 \define@key{todonotes}{backgroundcolor}{%
1624 \renewcommand{\@todonotes@currentbackgroundcolor}{#1}}%
1625 \define@key{todonotes}{bordercolor}{%
1626 \renewcommand{\@todonotes@currentbordercolor}{#1}}%
1627 \newcommand{\@todonotes@currentleaderwidth}{}%
1628 \define@key{todonotes}{leaderwidth}{%
1629 \renewcommand{\@todonotes@currentleaderwidth}{#1}}%
1630 % \end{macrocode}
1631 % Set a relative font size
1632 % \begin{macrocode}
1633 \newcommand{\@todonotes@sizecommand}{}%
1634 \define@key{todonotes}{size}{\renewcommand{\@todonotes@sizecommand}{#1}}%
1635 % \end{macrocode}
1636 % Should the todo item be disabled?
1637 % \begin{macrocode}
1638 \newif\if@todonotes@localdisable%
1639 \define@key{todonotes}{disable}[]{\@todonotes@localdisabletrue}%
1640 \define@key{todonotes}{nodisable}[]{\@todonotes@localdisablefalse}%
1641 % \end{macrocode}
1642 % Should the todo item be included in the list of todos?
1643 % \begin{macrocode}
1644 \newif\if@todonotes@appendtolistoftodos%
1645 \define@key{todonotes}{list}[]{\@todonotes@appendtolistoftodostrue}%
1646 \define@key{todonotes}{nolist}[]{\@todonotes@appendtolistoftodosfalse}%
1647 % \end{macrocode}
1648 % Should the todo item be displayed inline?
1649 % \begin{macrocode}
1650 \newif\if@todonotes@inlinenote%
1651 \define@key{todonotes}{inline}[]{\@todonotes@inlinenotetrue}%
1652 \define@key{todonotes}{noinline}[]{\@todonotes@inlinenotefalse}%
1653 % \end{macrocode}
1654 % \begin{macrocode}
1655 \newif\if@todonotes@prependcaption%
1656 \define@key{todonotes}{prepend}[]{\@todonotes@prependcaptiontrue}%
1657 \define@key{todonotes}{noprepend}[]{\@todonotes@prependcaptionfalse}%
1658 % \end{macrocode}
1659 % Should the note in the margin be connected to the insertion point
1660 % in the text?
1661 % \begin{macrocode}
1662 \newif\if@todonotes@line%
1663 \define@key{todonotes}{line}[]{\@todonotes@linetrue}%
1664 \define@key{todonotes}{noline}[]{\@todonotes@linefalse}%
1665 % \end{macrocode}
1666 % Only here for compatibility with todonotes.
1667 % We don't need the fancy lines because we have more advanced drawing styles.
1668 % So we ignore this option and issue a warning.
1669 % \begin{macrocode}
1670 \define@key{todonotes}{fancyline}[]{\PackageWarningNoLine{luatodonotes}
1671 {Parameter fancyline is not supported by luatodonotes}}%
1672 \define@key{todonotes}{nofancyline}[]{}%
1673 % \end{macrocode}
1674 % Author option.
1675 % \begin{macrocode}
1676 \newcommand{\@todonotes@author}{}%
1677 \newif\if@todonotes@authorgiven%
1678 \define@key{todonotes}{author}{%
1679 \renewcommand{\@todonotes@author}{#1}%
1680 \@todonotes@authorgiventrue}%
1681 \define@key{todonotes}{noauthor}[]{\@todonotes@authorgivenfalse}%
1682 % \end{macrocode}
1683 % Should the text in the list of todos be different from the text
1684 % in the todonote?
1685 % \begin{macrocode}
1686 \newcommand{\@todonotes@caption}{}%
1687 \newif\if@todonotes@captiongiven%
1688 \define@key{todonotes}{caption}%
1689 {\renewcommand{\@todonotes@caption}{#1}%
1690 \@todonotes@captiongiventrue}%
1691 \define@key{todonotes}{nocaption}[]{\@todonotes@captiongivenfalse}%
1692 % \end{macrocode}
1693 % Change the current figure width and height.
1694 % \begin{macrocode}
1695 \newcommand{\@todonotes@currentfigwidth}{\@todonotes@figwidth}
1696 \define@key{todonotes}%
1697 {figwidth}{\renewcommand{\@todonotes@currentfigwidth}{#1-2pt}}
1698 \newcommand{\@todonotes@currentfigheight}{\@todonotes@figheight}
1699 \define@key{todonotes}%
1700 {figheight}{\renewcommand{\@todonotes@currentfigheight}{#1-2pt}}
1701 \newcommand{\@todonotes@currentfigcolor}{\@todonotes@figcolor}
1702 \define@key{todonotes}%
1703 {figcolor}{\renewcommand{\@todonotes@currentfigcolor}{#1}}
1704 % \end{macrocode}
1705 % Preset values of the options
1706 % \begin{macrocode}
1707 \presetkeys%
1708 {todonotes}%
1709 {linecolor=\@todonotes@linecolor,%
1710 backgroundcolor=\@todonotes@backgroundcolor,%
1711 bordercolor=\@todonotes@bordercolor,%
1712 leaderwidth=\@todonotes@leaderwidth,%
1713 nodisable,%
1714 noinline,%
1715 nocaption,%
1716 noauthor,%
1717 figwidth=\@todonotes@figwidth,%
1718 figheight=\@todonotes@figheight,%
1719 figcolor=\@todonotes@figcolor,%
1720 line, list, size=\@todonotes@textsize}{}%
1721 % \end{macrocode}
1722 % \subsection{The main code part}
1723 % Here are the actual macros defined.
1724 % The following boolean is used to remember if |\todo| or |\todoarea|
1725 % was called.
1726 % \begin{macrocode}
1727 \newif\if@todonotes@areaselected%
1728 % \end{macrocode}
1729 % The following token registers are used to access the data for a note (which
1730 % is stored in macros) from Lua.
1731 % \begin{macrocode}
1732 \newtoks\@todonotes@toks@currentlinecolor%
1733 \newtoks\@todonotes@toks@currentbackgroundcolor%
1734 \newtoks\@todonotes@toks@currentbordercolor%
1735 \newtoks\@todonotes@toks@currentleaderwidth%
1736 \newtoks\@todonotes@toks@sizecommand%
1737 % \end{macrocode}
1738 % If the option "disable" was passed to the package
1739 % define empty commands.
1740 % \begin{macrocode}
1741 \if@todonotes@disabled%
1742 \newcommand{\listoftodos}[1][]{}
1743 \newcommand{\@todo}[2][]{}
1744 \newcommand{\@todoarea}[3][]{}
1745 \newcommand{\missingfigure}[2][]{}
1746 \else % \if@todonotes@disabled
1747 % \end{macrocode}
1748 % \begin{macro}{\listoftodos}
1749 % Define the |\listoftodos| command and define the
1750 % appearance of the list of todos.
1751 % \changes{0.3}{2015/11/16}{\texttt{\textbackslash listoftodos} didn't work
1752 % with documentclass \texttt{llncs}}
1753 % \changes{0.3}{2015/12/03}{Fix for \texttt{\textbackslash listoftodos} causing problems with
1754 % \texttt{hyperref}}
1755 % \begin{macrocode}
1756 \newcounter{todonotes@oldtocdepth}
1757 \newcommand{\listoftodos}[1][\@todonotes@todolistname]{%
1758 \setcounter{todonotes@oldtocdepth}{\value{tocdepth}}%
1759 \setcounter{tocdepth}{1}%
1760 \@ifundefined{chapter}{\section*{#1}}{\chapter*{#1}} \@starttoc{tdo}%
1761 \setcounter{tocdepth}{\value{todonotes@oldtocdepth}}%
1762 }
1763 \newcommand{\l@todo}
1764 {\@dottedtocline{1}{0em}{2.3em}}
1765 % \end{macrocode}
1766 % \end{macro}
1767 % Define styles used by the todo command.
1768 % Colors are set directly when placing the notes.
1769 % \begin{macrocode}
1770 \tikzset{@todonotes@todoarea/.style={
1771 decoration={snake,amplitude=3.5pt,segment length=5pt}}}
1772 \tikzset{@todonotes@notestyleraw/.style={
1773 line width=0.5pt,
1774 inner sep = \@todonotes@noteInnerSep,
1775 rounded corners=4pt}}
1776 % \end{macrocode}
1777 % Add shadows and rounded corners to the inserted todonotes.
1778 % \begin{macrocode}
1779 \if@todonotes@shadowenabled
1780 \tikzset{@todonotes@notestyle/.style={@todonotes@notestyleraw,
1781 general shadow={shadow xshift=.5ex, shadow yshift=-.5ex,
1782 opacity=1,fill=black!50}}}
1783 \else
1784 \tikzset{@todonotes@notestyle/.style={@todonotes@notestyleraw}}
1785 \fi
1786 \tikzset{@todonotes@leader/.style={}}
1787 \tikzset{@todonotes@textmark/.style={rounded corners}}
1788 \tikzset{@todonotes@inlinenote/.style={
1789 @todonotes@notestyle,
1790 draw=\@todonotes@currentbordercolor,
1791 fill=\@todonotes@currentbackgroundcolor,
1792 text width=\linewidth - 1.6 ex - 1 pt}}
1793 % \end{macrocode}
1794 % \begin{macro}{\@todocommon}
1795 % Common macro used from |\@todo| and |\@todoarea|.
1796 % Used to actually draw/save the note.
1797 % \begin{macrocode}
1798 \newcommand{\@todocommon}[2]{%
1799 % \end{macrocode}
1800 % Use the global value for determining the default prepend behavior.
1801 % \begin{macrocode}
1802 \if@todonotes@prependcaptionglobal%
1803 \@todonotes@prependcaptiontrue%
1804 \else%
1805 \@todonotes@prependcaptionfalse%
1806 \fi%
1807 % \end{macrocode}
1808 % Store the original text for later usage and parse the given options.
1809 % \begin{macrocode}
1810 \renewcommand{\@todonotes@text}{#2}%
1811 \renewcommand{\@todonotes@caption}{#2}%
1812 \setkeys{todonotes}{#1}%
1813 % \end{macrocode}
1814 % If the option |disable| is given to the command, no output is generated.
1815 % \begin{macrocode}
1816 \if@todonotes@localdisable%
1817 \else%
1818 % \end{macrocode}
1819 % Add the item to the list of todos. When the option
1820 % |colorinlistoftodos| is given to the package a small colored
1821 % square is added in front of the text.
1822 % \begin{macrocode}
1823 \addtocounter{@todonotes@numberoftodonotes}{1}%
1824 \if@todonotes@appendtolistoftodos%
1825 \phantomsection%
1826 \if@todonotes@captiongiven%
1827 \else%
1828 \renewcommand{\@todonotes@caption}{#2}%
1829 \fi%
1830 \@todonotes@addElementToListOfTodos%
1831 \fi%
1832 % \end{macrocode}
1833 % Prepend the short caption given if it is requested
1834 % \begin{macrocode}
1835 \if@todonotes@captiongiven%
1836 \if@todonotes@prependcaption%
1837 \renewcommand{\@todonotes@text}{\@todonotes@caption: #2}%
1838 \fi%
1839 \fi%
1840 % \end{macrocode}
1841 % Place the todonote as indicated by the options (inline or in a
1842 % marginpar), below is the code for the inline placement.
1843 % \begin{macrocode}
1844 \if@todonotes@inlinenote%
1845 \@todonotes@drawInlineNote%
1846 \else%
1847 \@todonotes@drawMarginNoteWithLine%
1848 \fi%\if@todonotes@inlinenote
1849 \fi%\if@todonotes@localdisable
1850 }%
1851 % \end{macrocode}
1852 % \end{macro}
1853 % \begin{macro}{\@todo}
1854 % Command that draws normal notes.
1855 % \begin{macrocode}
1856 \newcommand{\@todo}[2][]{%
1857 \@todonotes@areaselectedfalse%
1858 \@todocommon{#1}{#2}%
1859 }%
1860 % \end{macrocode}
1861 % \end{macro}
1862 % \begin{macro}{\@todoarea}
1863 % Command that draws notes that highlight a certain area in text.
1864 % \begin{macrocode}
1865 \newcommand{\@todoarea}[3][]{%
1866 \@todonotes@areaselectedtrue%
1867 \@todocommon{#1}{#2}%
1868 \todonotes@textmark@highlight{#3}%
1869 % \end{macrocode}
1870 % Mark the end of the highlighted area with a Tikz coordinate.
1871 % The begin is marked by |\@todocommon|.
1872 % \begin{macrocode}
1873 \@todonotes@before@tikzpict%
1874 \begin{tikzpicture}[remember picture, overlay]%
1875 \node [coordinate] (@todonotes@\arabic{@todonotes@numberoftodonotes} %
1876 inTextEnd) {};%
1877 \end{tikzpicture}%
1878 \@todonotes@after@tikzpict%
1879 \zref@label{@todonotes@\arabic{@todonotes@numberoftodonotes}@end}%
1880 }%
1881 % \end{macrocode}
1882 % \end{macro}
1883 % \begin{macro}{drawMarginNoteWithLine}
1884 % Define helper function |drawMarginNoteWithLine|.
1885 % \begin{macrocode}
1886 \newcommand{\@todonotes@drawMarginNoteWithLine}{%
1887 % \end{macrocode}
1888 % When the todonote should be placed inside a marginpar, the code
1889 % below is applied.
1890 % First is the current location in the document stored, this enables
1891 % us later to connect this point with the inserted todonote.
1892 % \begin{macrocode}
1893 \@todonotes@before@tikzpict%
1894 \begin{tikzpicture}[remember picture, overlay]%
1895 \node [coordinate] (@todonotes@\arabic{@todonotes@numberoftodonotes} %
1896 inText) {};%
1897 \end{tikzpicture}%
1898 \@todonotes@after@tikzpict%
1899 % \end{macrocode}
1900 % Update the dimensions to be accessed by Lua.
1901 % \begin{macrocode}
1902 \@todonotes@baselineskip=\baselineskip%
1903 \@todonotes@normalbaselineskip=\normalbaselineskip%
1904 \@todonotes@fontsize=\f@size pt%
1905 % \end{macrocode}
1906 % Place a label at the site.
1907 % We use this to query the page number, on which the note was placed.
1908 % \begin{macrocode}
1909 \zref@label{@todonotes@\arabic{@todonotes@numberoftodonotes}}%
1910 % \end{macrocode}
1911 % Append author before the note text if one is given.
1912 % \begin{macrocode}
1913 \if@todonotes@authorgiven%
1914 \let\@todonotes@text@old=\@todonotes@text
1915 \renewcommand{\@todonotes@text}{\@todonotes@author: \@todonotes@text@old}%
1916 \fi%
1917 % \end{macrocode}
1918 % We use edef here to get these macros fully expanded.
1919 % After that we write them to a toks register and read them from Lua.
1920 % \begin{macrocode}
1921 \edef\@todonotes@tmp{\@todonotes@currentlinecolor}%
1922 \@todonotes@toks@currentlinecolor=\expandafter{\@todonotes@tmp}%
1923 \edef\@todonotes@tmp{\@todonotes@currentbackgroundcolor}%
1924 \@todonotes@toks@currentbackgroundcolor=\expandafter{\@todonotes@tmp}%
1925 \edef\@todonotes@tmp{\@todonotes@currentbordercolor}%
1926 \@todonotes@toks@currentbordercolor=\expandafter{\@todonotes@tmp}%
1927 \edef\@todonotes@tmp{\@todonotes@currentleaderwidth}%
1928 \@todonotes@toks@currentleaderwidth=\expandafter{\@todonotes@tmp}%
1929 % \end{macrocode}
1930 % We cannot fully expand the size command (using |\edef| causes errors when
1931 % compiling).
1932 % \begin{macrocode}
1933 \@todonotes@toks@sizecommand=\expandafter{\@todonotes@sizecommand}%
1934 % \end{macrocode}
1935 % We store the text that should be shown in this note into a box and copy this
1936 % box to a variable in Lua. The commands |\@parboxrestore|, |\@marginparreset|,
1937 % |\@minipagefalse| and |\outer@nobreak| are copied from the definition of
1938 % |\marginpar| in \LaTeX 2e to reset font settings, for example.
1939 % This is important when a note is placed inside a theorem environment.
1940 % \changes{0.2}{2015/02/20}{Reset font settings at begin of a todo note}
1941 % \begin{macrocode}
1942 \savebox\@todonotes@notetextbox{%
1943 \@parboxrestore
1944 \@marginparreset
1945 \@todonotes@sizecommand\@todonotes@text%
1946 \@minipagefalse
1947 \outer@nobreak
1948 }%
1949 % \end{macrocode}
1950 % Prepare parameters and add the note to the list in Lua.
1951 % \begin{macrocode}
1952 \if@todonotes@line%
1953 \def\@todonotes@param@drawLeader{true}%
1954 \else%
1955 \def\@todonotes@param@drawLeader{false}%
1956 \fi%
1957 \if@todonotes@areaselected%
1958 \def\@todonotes@param@noteType{area}%
1959 \else%
1960 \def\@todonotes@param@noteType{}%
1961 \fi%
1962 \directlua{luatodonotes.addNoteToList(\arabic{@todonotes@numberoftodonotes},%
1963 \@todonotes@param@drawLeader,\luastringO{\@todonotes@param@noteType})}%
1964 }%
1965 % \end{macrocode}
1966 % \end{macro}
1967 % \begin{macro}{addElementToListOfTodos}
1968 % Define helper function |addElementToListOfTodos|.
1969 % \begin{macrocode}
1970 \newcommand{\@todonotes@addElementToListOfTodos}{%
1971 \if@todonotes@colorinlistoftodos%
1972 \addcontentsline{tdo}{todo}{%
1973 \fcolorbox{\@todonotes@currentbordercolor}%
1974 {\@todonotes@currentbackgroundcolor}%
1975 {\textcolor{\@todonotes@currentbackgroundcolor}{o}}%
1976 \ \@todonotes@caption}%
1977 \else%
1978 \addcontentsline{tdo}{todo}{\@todonotes@caption}%
1979 \fi}%
1980 % \end{macrocode}
1981 % \end{macro}
1982 % \begin{macro}{drawInlineNote}
1983 % Define helper function |drawInlineNote|.
1984 % \begin{macrocode}
1985 \newcommand{\@todonotes@drawInlineNote}{%
1986 {\par\noindent%
1987 \@todonotes@before@tikzpict%
1988 \begin{tikzpicture}[remember picture]%
1989 \draw node[@todonotes@inlinenote,font=\@todonotes@sizecommand]{%
1990 \if@todonotes@authorgiven%
1991 {\noindent \@todonotes@sizecommand %
1992 \@todonotes@author:\,\@todonotes@text}%
1993 \else%
1994 {\noindent \@todonotes@sizecommand \@todonotes@text}%
1995 \fi};%
1996 \end{tikzpicture}%
1997 \@todonotes@after@tikzpict%
1998 \par}%
1999 }%
2000 % \end{macrocode}
2001 % \end{macro}
2002 % \begin{macro}{\missingfigure}
2003 % Defines the |\missingfigure| macro.
2004 % \begin{macrocode}
2005 \newcommand{\missingfigure}[2][]{%
2006 \setkeys{todonotes}{#1}%
2007 \addcontentsline{tdo}{todo}{\@todonotes@MissingFigureText: #2}%
2008 \par
2009 \noindent
2010 \@todonotes@before@tikzpict%
2011 \begin{tikzpicture}
2012 \draw[fill=\@todonotes@currentfigcolor, draw = black!40, line width=2pt]
2013 (-2, -2.5) rectangle +(\@todonotes@currentfigwidth, \@todonotes@currentfigheight);
2014 \draw (2, -0.3) node[right, text
2015 width=\@[email protected]] {#2};
2016 \draw[red, fill=white, rounded corners = 5pt, line width=10pt]
2017 (30:2cm) -- (150:2cm) -- (270:2cm) -- cycle;
2018 \draw (0, 0.3) node {\@todonotes@MissingFigureUp};
2019 \draw (0, -0.3) node {\@todonotes@MissingFigureDown};
2020 \end{tikzpicture}\hfill
2021 \@todonotes@after@tikzpict%
2022 }% Ending \missingfigure command
2023 \fi% Ending \@todonotes@ifdisabled
2024 % \end{macrocode}
2025 % \end{macro}
2026 % \begin{macro}{\todototoc}
2027 % Inserts a reference to the list of todos in the table of contents. If |chapter| is defined,
2028 % |chapter| is used as level otherwise will |section| be used.
2029 % The |\todototoc| command respects the disable option.
2030 % \begin{macrocode}
2031 \newcommand{\todototoc}
2032 {
2033 \if@todonotes@disabled
2034 \else
2035 \addcontentsline{toc}{\@ifundefined{chapter}{section}{chapter}}{\@todonotes@todolistname}
2036 \fi
2037 }
2038 % \end{macrocode}
2039 % \end{macro}
2040 %
2041 % \begin{macro}{\todo}
2042 % Define the |\todo| command as a redirection to |\@todo|.
2043 % \begin{macrocode}
2044 \newcommand{\todo}[2][]{\@bsphack\@todo[#1]{#2}\@esphack\ignorespaces}%
2045 % \end{macrocode}
2046 % \end{macro}
2047 % \begin{macro}{\todoarea}
2048 % Define the |\todoarea| command as a redirection to |\@todoarea|.
2049 % We don't want to ignore spaces after this command.
2050 % \begin{macrocode}
2051 \newcommand{\todoarea}[3][]{\@bsphack\@todoarea[#1]{#2}{#3}\@esphack}%
2052 % \end{macrocode}
2053 % \end{macro}
2054 % The following commands are executed when a page is complete and is written to
2055 % the output PDF (shipout in \TeX\ terms).
2056 % The |\AtBeginShipout| command is provided by package atbegshi.
2057 % \begin{macrocode}
2058 \if@todonotes@disabled
2059 \else
2060 \AtBeginShipout{%
2061 % \end{macrocode}
2062 % We draw to the foreground or background of the page (depending if debug option
2063 % is set for the package).
2064 % \begin{macrocode}
2065 \@todonotes@AtBeginShipoutUpperLeft{
2066 \@todonotes@writeNextpageToLpo
2067 % \end{macrocode}
2068 % Determine if we are on a left or on a right side (important for margins) and
2069 % set variables accordingly.
2070 % |\relax| seems to be needed at end to really write new value for
2071 % currentsidemargin.
2072 % \begin{macrocode}
2073 \checkoddpage%
2074 \ifoddpageoroneside%
2075 \@todonotes@currentsidemargin=\the\oddsidemargin%
2076 \else%
2077 \@todonotes@currentsidemargin=\the\evensidemargin%
2078 \fi\relax%
2079 % \end{macrocode}
2080 % We switch to the default catcodes of \LaTeX\ here.
2081 % This is important if catcodes are changed in the main text, e.\,g., by a
2082 % verbatim environment at the end of the page.
2083 % \begin{macrocode}
2084 \BeginCatcodeRegime\CatcodeTableLaTeX
2085 % \end{macrocode}
2086 % Calculates the areas, in which the labels can be placed.
2087 % This calculation depends on currentsidemargin.
2088 % So this has to be done inside |\AtBeginShipoutUpperLeft| (otherwise odd/even
2089 % page detection won't work).
2090 % \begin{macrocode}
2091 \directlua{luatodonotes.calcLabelAreaDimensions()}%
2092 % \end{macrocode}
2093 % Calculates the needed height for every note.
2094 % This has to be outside of the tikzpicture because it uses a savebox to compute
2095 % the height.
2096 % This box does not work in the tikzpicture.
2097 % \begin{macrocode}
2098 \directlua{luatodonotes.calcHeightsForNotes()}% has to be outside of tikzpicture
2099 % \end{macrocode}
2100 % Some classes modify the page margins using |\voffset| and |\hoffset|.
2101 % Our |tikzpicture| would be aligned using this modified page origin.
2102 % So we overrule the offsets using a |raisebox| and a negative |hspace|.
2103 % \changes{0.3}{2015/11/30}{Consider defined values for \texttt{\textbackslash
2104 % voffset} and \texttt{\textbackslash hoffset} to place the notes in the right
2105 % position}
2106 % \begin{macrocode}
2107 \raisebox{\voffset}{%
2108 \hspace{-\hoffset}%
2109 \@todonotes@before@tikzpict%
2110 \begin{tikzpicture}[remember picture,overlay]
2111 % \end{macrocode}
2112 % Reads the absolute coordinates of every note on the page and writes them to
2113 % the Lua objects.
2114 % \begin{macrocode}
2115 \directlua{luatodonotes.getInputCoordinatesForNotes()}
2116 % \end{macrocode}
2117 % Runs the positioning algorithm and actually draws the notes and leaders.
2118 % \begin{macrocode}
2119 \directlua{luatodonotes.printNotes()}
2120 \end{tikzpicture}%
2121 \@todonotes@after@tikzpict%
2122 }%
2123 % \end{macrocode}
2124 % Delete the drawn notes from the Lua lists and prepare for the next page.
2125 % \begin{macrocode}
2126 \directlua{luatodonotes.clearNotes()}%
2127 \EndCatcodeRegime
2128 }%
2129 }
2130 \fi % Ending \@todonotes@ifdisabled
2131 % \end{macrocode}
2132 %
2133 % \newpage
2134 % \Finale
2135 \endinput
2136