summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2015-12-05 23:01:08 +0000
committerKarl Berry <karl@freefriends.org>2015-12-05 23:01:08 +0000
commit5384f92b5a44dd9e84f1bab69420edf32e99c696 (patch)
tree47ce270ba97f34e690da94927a29740d58dcf3d5
parenta3e2c07a7a98d9b5afdd8940333dae4a7e3e6196 (diff)
luatodonotes (5dec15)
git-svn-id: svn://tug.org/texlive/trunk@39019 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r--Master/texmf-dist/doc/lualatex/luatodonotes/README.md5
-rw-r--r--Master/texmf-dist/doc/lualatex/luatodonotes/luatodonotes.pdfbin195338 -> 209764 bytes
-rw-r--r--Master/texmf-dist/source/lualatex/luatodonotes/luatodonotes.dtx234
-rw-r--r--Master/texmf-dist/tex/lualatex/luatodonotes/luatodonotes.lua114
-rw-r--r--Master/texmf-dist/tex/lualatex/luatodonotes/luatodonotes.sty88
5 files changed, 349 insertions, 92 deletions
diff --git a/Master/texmf-dist/doc/lualatex/luatodonotes/README.md b/Master/texmf-dist/doc/lualatex/luatodonotes/README.md
index a3ff72c082a..6036b14d704 100644
--- a/Master/texmf-dist/doc/lualatex/luatodonotes/README.md
+++ b/Master/texmf-dist/doc/lualatex/luatodonotes/README.md
@@ -17,9 +17,12 @@ files into your TEXMF tree.
## Development
-The latest source code is available on Github:
+The latest source code is available on GitHub:
https://github.com/fabianlipp/luatodonotes
+If you want to report bugs or you have suggestions for improvements, you can
+use the issue tracker on GitHub or contact me via email.
+
## License
The luatodonotes package is subject to the LATEX Project Public License.
diff --git a/Master/texmf-dist/doc/lualatex/luatodonotes/luatodonotes.pdf b/Master/texmf-dist/doc/lualatex/luatodonotes/luatodonotes.pdf
index e9291dd8a24..c0cef3babc8 100644
--- a/Master/texmf-dist/doc/lualatex/luatodonotes/luatodonotes.pdf
+++ b/Master/texmf-dist/doc/lualatex/luatodonotes/luatodonotes.pdf
Binary files differ
diff --git a/Master/texmf-dist/source/lualatex/luatodonotes/luatodonotes.dtx b/Master/texmf-dist/source/lualatex/luatodonotes/luatodonotes.dtx
index 79537444e2e..5c3de40b693 100644
--- a/Master/texmf-dist/source/lualatex/luatodonotes/luatodonotes.dtx
+++ b/Master/texmf-dist/source/lualatex/luatodonotes/luatodonotes.dtx
@@ -24,14 +24,15 @@
%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
%<package>\ProvidesPackage{luatodonotes}
%<*package>
- [2015/03/13 v0.2 luatodonotes source and documentation.]
+ [2015/12/03 v0.3 luatodonotes source and documentation.]
%</package>
%
%<*driver>
\documentclass{ltxdoc}
\usepackage{wrapfig}
-\usepackage[colorlinks, linkcolor=black, urlcolor=blue]{hyperref}
-\usepackage[colorinlistoftodos, shadow]{luatodonotes}[2015/03/13]
+\PassOptionsToPackage{colorlinks, urlcolor=blue}{hyperref}
+\usepackage{hypdoc} % this package loads hyperref among others
+\usepackage[colorinlistoftodos, shadow]{luatodonotes}[2015/12/03]
\usepackage{fontspec}
\usepackage{amsmath}
\usepackage{setspace}
@@ -50,7 +51,7 @@
%</driver>
% \fi
%
-% \CheckSum{825}
+% \CheckSum{905}
%
% \CharacterTable
% {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
@@ -70,18 +71,12 @@
%
%
% \changes{0.1}{2014/08/07}{The first version of the package}
-% \changes{0.2}{2014/09/08}{Compatibility with csquotes package (notes were
-% displayed multiple times when used in \texttt{\textbackslash blockquote}
-% command)}
% \changes{0.2}{2015/01/13}{Fix wrong linespacing when changing fontsize}
% \changes{0.2}{2015/01/13}{Included suggestions from CTAN submission into
% documentation}
-% \changes{0.2}{2015/02/28}{Make Lua variables and functions local or put them
-% into luatodonotes array (don't pollute global namespace)}
-% \changes{0.2}{2015/02/28}{Correct height calculation for notes with modified
-% fontsize}
-% \changes{0.2}{2015/03/03}{Fix problems with recent versions of lualibs}
% \changes{0.2}{2015/03/12}{Added troubleshooting section to documentation}
+% \changes{0.3}{2015/12/03}{Incorporated some changes from todonotes (version
+% 1.0.4)}
% \GetFileInfo{luatodonotes.dtx}
%
% \DoNotIndex{\newcommand,\newenvironment}
@@ -264,13 +259,14 @@
%
% \DescribeMacro{danish, german, ngerman, french, swedish}
% \DescribeMacro{spanish, catalan, italian}
-% \DescribeMacro{portuguese, dutch}
+% \DescribeMacro{portuguese, dutch, croatian}
% Use translations of the text strings
% ''List of todos'' and ''Missing figure''.
% The default is to use none of these options, which results in
% english text strings.
% Currently the following languages are supported:
% catalan,
+% croatian,
% danish,
% dutch,
% french,
@@ -327,7 +323,7 @@
% The |figwidth=length| option and |figheight=length| option set the default
% width and height of the figure
% inserted by the |\missingfigure| command.
-% The default value is |\columnwidth| for the width and |4cm| for the height.
+% The default value is |\linewidth| for the width and |4cm| for the height.
%
% \DescribeMacro{leaderwidth}
% The |leaderwidth=length| option specifies the width of the leader lines.
@@ -369,6 +365,8 @@
% The |positioning=algorithm| option specifies, which algorithm is used to
% determine the positions of the notes on the page.
% You should choose the algorithm depending on the leader type you want to use.
+% You can also use one of the options |s|, |po|, |bezier|, or |opo| to define
+% the positioning algorithm together with the leadertype.
% The default value for this option is |inputOrderStacks|.
% The following algorithms are available:
% \begin{itemize}
@@ -413,6 +411,22 @@
% other packages.
% \end{itemize}
%
+% \DescribeMacro{s}
+% \DescribeMacro{bezier}
+% \DescribeMacro{opo}
+% \DescribeMacro{po}
+% Shorthand options for convenience, which represent common combinations of
+% leadertypes and postioning algorithms.
+% |leadertype| or |positioning| options following one of these options override
+% its settings.
+% They use the following positioning algorithms:
+% \begin{itemize}
+% \item |s|: |sLeaderNorthEastBelowStacks|
+% \item |bezier|: |sLeaderNorthEastBelowStacks|
+% \item |opo|: |inputOrderStacks|
+% \item |po|: |poLeadersAvoidLines|
+% \end{itemize}
+%
% \DescribeMacro{splitting}
% The |splitting=algorithm| option can be used to place the labels on both sides
% of the text.
@@ -462,7 +476,7 @@
% for label placement.
% If both margins are narrower, no labels are placed and an error message is
% printed to the console output.
-% The default value of this option is |1.0cm|.
+% The default value of this option is |2.0cm|.
%
% \DescribeMacro{distanceNotesPageBorder}
% The |distanceNotesPageBorder=length| option specifies the horizontal distance
@@ -485,6 +499,20 @@
% length), but strongly increases the runtime and memory consumption.
% The default value of this option is |1cm|.
%
+% \DescribeMacro{additionalMargin}
+% The |additionalMargin=length| option extends the page margins horizontally.
+% To achieve this the page width is increased.
+% The page is extended by the given length on both sides.
+% The layout of the page stays the same but the paper format is changed: the
+% height is left unmodified, but the width is increased by the doubled value of
+% the given length.
+% This option is useful if you have to adhere to a given layout, whose margins
+% are not wide enough to accomodate the notes.
+% You can safely use this option as the final layout of your document does not
+% change when disabling the |luatodonotes| package.
+% The default width of |2cm| for the additional margin is used when the option
+% is given without a length.
+%
% \DescribeMacro{debug}
% When the |debug| option is activated the package is more verbose on
% the commandline.
@@ -675,6 +703,17 @@
% \missingfigure[figheight=6cm]{Testing}
%
%
+% \DescribeMacro{figcolor}
+% The |figcolor=color| options sets the background color of
+% inserted missing figures.
+% The default color is |black!40|.
+% \begin{verbatim}
+% \missingfigure[figcolor=white]{Testing figcolor}
+% \end{verbatim}
+% \missingfigure[figcolor=white]{Testing figcolor}
+%
+%
+%
% \subsection{Options for the \texttt{listoftodos} command}
% The |\listoftodos| command takes one optional argument, that
% defines the name of the inserted list of todos.
@@ -715,7 +754,7 @@
% You can query kpathsea for a file using the default \TeX{} search path with:
% \begin{verbatim}
% kpsewhich luatodonotes.lua\end{verbatim}
-% Be sure to run |texhash| (as root if needed) after moving files inside the
+% Be sure to run |texhash| (as root if needed) after moving files into the
% texmf tree.
%
% \subsubsection{The \texttt{debug} option}
@@ -851,6 +890,7 @@
%
% \newpage
% \section{Implementation}
+% \begin{environment}{luatodonotes.lua}
% In this section only the source code of the LaTeX package file
% (|luatodonotes.sty|) is shown.
% The Lua code is contained in |luatodonotes.lua| and documented by comments
@@ -869,8 +909,45 @@
% Master thesis, 2014.
% \url{http://www1.pub.informatik.uni-wuerzburg.de/pub/theses/2014-lipp-master.pdf}
% \end{itemize}
+% \changes{0.2}{2014/09/08}{Compatibility with csquotes package (notes were
+% displayed multiple times when used in \texttt{\textbackslash blockquote}
+% command)}
+% \changes{0.2}{2015/02/28}{Correct height calculation for notes with modified
+% fontsize}
+% \changes{0.2}{2015/02/28}{Make Lua variables and functions local or put them
+% into luatodonotes array (don't pollute global namespace)}
+% \changes{0.2}{2015/03/03}{Fix problems with recent versions of lualibs}
+% \changes{0.3}{2015/10/30}{Fix problems with doubled notes when code is read
+% multiple times (e.g., by tabularx)}
+% \changes{0.3}{2015/11/16}{Deal with notes without a page number (happens when
+% placed in \texttt{\textbackslash caption}, e.g.)}
+% \changes{0.3}{2015/11/30}{Remove two variables from Lua global namespace}
+% \changes{0.3}{2015/12/02}{Less console output unless debug option is set}
+% \end{environment}
%
% \subsection{Dependencies and definitions}
+% Make sure that the classical |todonotes| package is not loaded as we redefine
+% its commands.
+% Additionally we pretend that |todonotes| 1.0.2 is already loaded.
+% So later attempts to load package |todonotes| are simply ignored.
+% Loading both packages in the same document would produce errors (like
+% ``Command already defined'').
+% \changes{0.3}{2015/12/01}{Ensure that package \texttt{todonotes} is not
+% loaded}
+% \begin{macrocode}
+\@ifpackageloaded{todonotes}{
+ \PackageError{luatodonotes}{%
+ Conflicting packages todonotes and luatodonotes\MessageBreak
+ loaded. Aborting.}{%
+ The package luatodonotes was designed as a replacement for todonotes. So it
+ is not possible (and not reasonable) to include both of them in the same
+ document.%
+ If you want to use luatodonotes you should delete the todonotes
+ package from\MessageBreak
+ your preamble.\MessageBreak}
+}{}
+\expandafter\def\csname ver@todonotes.sty\endcsname{2014/07/14}
+% \end{macrocode}
% Check if Lua\TeX{} is used.
% \changes{0.2}{2015/02/23}{Check if LuaTeX is used at begin of package}
% \begin{macrocode}
@@ -892,7 +969,6 @@
\usetikzlibrary{intersections}
\usetikzlibrary{decorations.pathmorphing}
\RequirePackage{luacode}
-\RequirePackage{luatex}
\RequirePackage{atbegshi}
\RequirePackage{xstring}
\RequirePackage{zref-abspage}
@@ -900,6 +976,19 @@
\RequirePackage{soul}
\RequirePackage{soulpos}
% \end{macrocode}
+% The package |luatex| must not be loaded in new TeX distributions as the
+% definition of |\newattribute| in it conflicts with newer versions of
+% Lua\LaTeX.
+% Older versions of |luatexbase| include the package |luatex| by themselves, for
+% newer versions the Lua\LaTeX kernel should include the commands that we need
+% (e.\,g., |\newattribute|).
+% \changes{0.3}{2015/11/12}{Remove package \texttt{luatex} for current
+% versions of Lua\LaTeX (as it caused problems)}
+% \begin{macrocode}
+\@ifpackagelater{luatexbase}{2013/05/04}{}{
+ \RequirePackage{luatex}
+}
+% \end{macrocode}
% Some default values are set
% \begin{macrocode}
\newcommand{\@todonotes@text}{}%
@@ -908,8 +997,9 @@
\newcommand{\@todonotes@bordercolor}{black}
\newcommand{\@todonotes@leaderwidth}{1.6pt}
\newcommand{\@todonotes@textsize}{\normalsize}
-\newcommand{\@todonotes@figwidth}{\columnwidth}
+\newcommand{\@todonotes@figwidth}{\linewidth}
\newcommand{\@todonotes@figheight}{4cm}
+\newcommand{\@todonotes@figcolor}{black!40}
% \end{macrocode}
% Default values for variables added by luatodonotes
% \begin{macrocode}
@@ -919,10 +1009,11 @@
\newcommand{\@todonotes@interNoteSpace}{5pt}
\newcommand{\@todonotes@noteInnerSep}{5pt}
\newcommand{\@todonotes@routingAreaWidth}{0.4cm}
-\newcommand{\@todonotes@minNoteWidth}{1.0cm}
+\newcommand{\@todonotes@minNoteWidth}{2.0cm}
\newcommand{\@todonotes@distanceNotesPageBorder}{0.5cm}
\newcommand{\@todonotes@distanceNotesText}{0.2cm}
\newcommand{\@todonotes@rasterHeight}{1cm}
+\newcommand{\@todonotes@additionalMargin}{2cm}
% \end{macrocode}
% \begin{macrocode}
\AtBeginDocument{
@@ -958,6 +1049,12 @@
\@todonotes@SetMissingFigureUp{Figura}%
\@todonotes@SetMissingFigureDown{pendent}%
}
+\DeclareOptionX{croatian}{%
+ \@todonotes@SetTodoListName{Popis obveza}%
+ \@todonotes@SetMissingFigureText{Slika}%
+ \@todonotes@SetMissingFigureUp{Nedostaje}%
+ \@todonotes@SetMissingFigureDown{slika}%
+}
\DeclareOptionX{danish}{%
\@todonotes@SetTodoListName{G\o{}rem\aa{}lsliste}%
\@todonotes@SetMissingFigureText{Figur}%
@@ -1133,7 +1230,24 @@
{figwidth}{\renewcommand{\@todonotes@figwidth}{#1}}
\define@key{luatodonotes.sty}%
{figheight}{\renewcommand{\@todonotes@figheight}{#1}}
+\define@key{luatodonotes.sty}%
+ {figcolor}{\renewcommand{\@todonotes@figcolor}{#1}}
+% \end{macrocode}
+% \begin{macro}{s,bezier,opo,po}
+% Provide shorthand options for the most common leader styles.
+% \changes{0.3}{2015/12/03}{Provide shorthand commands for most common leader
+% styles}
+% \begin{macrocode}
+\DeclareOptionX{po}%
+ {\setkeys{luatodonotes.sty}{leadertype=po,positioning=poLeadersAvoidLines}}
+\DeclareOptionX{s}%
+ {\setkeys{luatodonotes.sty}{leadertype=s,positioning=sLeaderNorthEastBelowStacks}}
+\DeclareOptionX{bezier}%
+ {\setkeys{luatodonotes.sty}{leadertype=sBezier,positioning=sLeaderNorthEastBelowStacks}}
+\DeclareOptionX{opo}%
+ {\setkeys{luatodonotes.sty}{leadertype=opo,positioning=inputOrderStacks}}
% \end{macrocode}
+% \end{macro}
% Specify the name of the algorithm used to specify the position of the labels.
% \begin{macrocode}
\define@key{luatodonotes.sty}%
@@ -1186,6 +1300,18 @@
\define@key{luatodonotes.sty}%
{rasterHeight}{\renewcommand{\@todonotes@rasterHeight}{#1}}
% \end{macrocode}
+% \begin{macro}{additionalMargin}
+% Control whether the margin should be enlarged for the notes and its width.
+% \changes{0.3}{2015/12/01}{Introduce package option \texttt{additionalMargin}}
+% \begin{macrocode}
+\newif{\if@todonotes@additionalMarginEnabled}
+\@todonotes@additionalMarginEnabledfalse
+\define@key{luatodonotes.sty}%
+ {additionalMargin}[\@todonotes@additionalMargin]{%
+ \@todonotes@additionalMarginEnabledtrue
+ \renewcommand{\@todonotes@additionalMargin}{#1}}
+% \end{macrocode}
+% \end{macro}
% This option is used to activate debug mode.
% Luatex prints more verbose output to the commandline in this mode.
% Furthermore, some of the algorithms also print debugging hints onto the
@@ -1223,6 +1349,20 @@
\fi
\fi
% \end{macrocode}
+% If the option |additionalMargin| is given, we enlarge the margins for the notes.
+% We simply increase the page size by the doubled value of |additionalMargin| and move the contents to the right using |\hoffset|.
+% \begin{macrocode}
+\if@todonotes@additionalMarginEnabled
+ \newlength{\@todonotes@modpaperwidth}
+ \AtBeginDocument{%
+ \setlength{\@todonotes@modpaperwidth}{\paperwidth}%
+ \addtolength{\@todonotes@modpaperwidth}{\@todonotes@additionalMargin}%
+ \addtolength{\@todonotes@modpaperwidth}{\@todonotes@additionalMargin}%
+ \pdfpagewidth=\@todonotes@modpaperwidth%
+ \addtolength{\hoffset}{\@todonotes@additionalMargin}%
+ }%
+\fi%
+% \end{macrocode}
% \subsection{Initialisation of our Lua code}
% In this part we define some of the variables used by Lua depending on the
% package options and do some other initialisation tasks.
@@ -1251,13 +1391,18 @@
% \begin{macrocode}
\newsavebox\@todonotes@notetextbox
% \end{macrocode}
-% The following dimensions are used to read |\baselineskip| and
-% |\f@size| from Lua.
+% The following dimensions are used to read |\baselineskip|,
+% |\normalbaselineskip| and |\f@size| from Lua.
+% We need |\normalbaselineskip| as |\baselineskip| is set to 0 inside
+% tabular cells.
% Dimension |\@todonotes@currentsidemargin| is set to the left margin,
% i.\,e., to the value of length |\oddsidemargin| or
% |\evensidemargin| depending on the type page.
+% \changes{0.3}{2015/10/30}{Fix position of marker in table cells
+% (\texttt{\textbackslash baselineskip} is empty inside tables)}
% \begin{macrocode}
\newdimen\@todonotes@baselineskip
+\newdimen\@todonotes@normalbaselineskip
\newdimen\@todonotes@fontsize
\newdimen\@todonotes@currentsidemargin
% \end{macrocode}
@@ -1497,6 +1642,9 @@
\newcommand{\@todonotes@currentfigheight}{\@todonotes@figheight}
\define@key{todonotes}%
{figheight}{\renewcommand{\@todonotes@currentfigheight}{#1}}
+\newcommand{\@todonotes@currentfigcolor}{\@todonotes@figcolor}
+\define@key{todonotes}%
+ {figcolor}{\renewcommand{\@todonotes@currentfigcolor}{#1}}
% \end{macrocode}
% Preset values of the options
% \begin{macrocode}
@@ -1512,6 +1660,7 @@
noauthor,%
figwidth=\@todonotes@figwidth,%
figheight=\@todonotes@figheight,%
+ figcolor=\@todonotes@figcolor,%
line, list, size=\@todonotes@textsize}{}%
% \end{macrocode}
% \subsection{The main code part}
@@ -1540,14 +1689,25 @@
\newcommand{\missingfigure}[2][]{}
\else % \if@todonotes@disabled
% \end{macrocode}
+% \begin{macro}{\listoftodos}
% Define the |\listoftodos| command and define the
% appearance of the list of todos.
-% \begin{macrocode}
-\newcommand{\listoftodos}[1][\@todonotes@todolistname]
- {\@ifundefined{chapter}{\section*{#1}}{\chapter*{#1}} \@starttoc{tdo}}
+% \changes{0.3}{2015/11/16}{\texttt{\textbackslash listoftodos} didn't work
+% with documentclass \texttt{llncs}}
+% \changes{0.3}{2015/12/03}{Fix for \texttt{\textbackslash listoftodos} causing problems with
+% \texttt{hyperref}}
+% \begin{macrocode}
+\newcounter{todonotes@oldtocdepth}
+\newcommand{\listoftodos}[1][\@todonotes@todolistname]{%
+ \setcounter{todonotes@oldtocdepth}{\value{tocdepth}}%
+ \setcounter{tocdepth}{1}%
+ \@ifundefined{chapter}{\section*{#1}}{\chapter*{#1}} \@starttoc{tdo}%
+ \setcounter{tocdepth}{\value{todonotes@oldtocdepth}}%
+}
\newcommand{\l@todo}
{\@dottedtocline{1}{0em}{2.3em}}
% \end{macrocode}
+% \end{macro}
% Define styles used by the todo command.
% Colors are set directly when placing the notes.
% \begin{macrocode}
@@ -1680,6 +1840,7 @@
% Update the dimensions to be accessed by Lua.
% \begin{macrocode}
\@todonotes@baselineskip=\baselineskip%
+ \@todonotes@normalbaselineskip=\normalbaselineskip%
\@todonotes@fontsize=\f@size pt%
% \end{macrocode}
% Place a label at the site.
@@ -1783,7 +1944,7 @@
\par
\noindent
\begin{tikzpicture}
-\draw[fill=black!40, draw = white, line width=0pt]
+\draw[fill=\@todonotes@currentfigcolor, draw = black!40, line width=2pt]
(-2, -2.5) rectangle +(\@todonotes@currentfigwidth, \@todonotes@currentfigheight);
\draw (2, -0.3) node[right, text
width=\@todonotes@currentfigwidth-4.5cm] {#2};
@@ -1791,9 +1952,9 @@
(30:2cm) -- (150:2cm) -- (270:2cm) -- cycle;
\draw (0, 0.3) node {\@todonotes@MissingFigureUp};
\draw (0, -0.3) node {\@todonotes@MissingFigureDown};
-\end{tikzpicture}
+\end{tikzpicture}\hfill
}% Ending \missingfigure command
-\fi % Ending \@todonotes@ifdisabled
+\fi% Ending \@todonotes@ifdisabled
% \end{macrocode}
% \end{macro}
% \begin{macro}{\todototoc}
@@ -1869,17 +2030,28 @@
% This box does not work in the tikzpicture.
% \begin{macrocode}
\directlua{luatodonotes.calcHeightsForNotes()}% has to be outside of tikzpicture
- \begin{tikzpicture}[remember picture,overlay]
+% \end{macrocode}
+% Some classes modify the page margins using |\voffset| and |\hoffset|.
+% Our |tikzpicture| would be aligned using this modified page origin.
+% So we overrule the offsets using a |raisebox| and a negative |hspace|.
+% \changes{0.3}{2015/11/30}{Consider defined values for \texttt{\textbackslash
+% voffset} and \texttt{\textbackslash hoffset} to place the notes in the right
+% position}
+% \begin{macrocode}
+ \raisebox{\voffset}{%
+ \hspace{-\hoffset}%
+ \begin{tikzpicture}[remember picture,overlay]
% \end{macrocode}
% Reads the absolute coordinates of every note on the page and writes them to
% the Lua objects.
% \begin{macrocode}
- \directlua{luatodonotes.getInputCoordinatesForNotes()}
+ \directlua{luatodonotes.getInputCoordinatesForNotes()}
% \end{macrocode}
% Runs the positioning algorithm and actually draws the notes and leaders.
% \begin{macrocode}
- \directlua{luatodonotes.printNotes()}
- \end{tikzpicture}%
+ \directlua{luatodonotes.printNotes()}
+ \end{tikzpicture}%
+ }%
% \end{macrocode}
% Delete the drawn notes from the Lua lists and prepare for the next page.
% \begin{macrocode}
diff --git a/Master/texmf-dist/tex/lualatex/luatodonotes/luatodonotes.lua b/Master/texmf-dist/tex/lualatex/luatodonotes/luatodonotes.lua
index f84fc9415de..5ef9b8f03bc 100644
--- a/Master/texmf-dist/tex/lualatex/luatodonotes/luatodonotes.lua
+++ b/Master/texmf-dist/tex/lualatex/luatodonotes/luatodonotes.lua
@@ -91,6 +91,8 @@ end
-- stores the notes for the current page
luatodonotes.notesForPage = {}
local notesForPage = luatodonotes.notesForPage
+luatodonotes.notesForNextPage = {}
+local notesForNextPage = luatodonotes.notesForNextPage
-- Fields for each note:
-- index: numbers notes in whole document
-- indexOnPage: index of the note in the notesForPage array
@@ -106,6 +108,7 @@ local notesForPage = luatodonotes.notesForPage
-- otherwise left side is meant
-- fontsize: fontsize used for paragraph in that the note was defined
-- baselineskip: \baselineskip in the paragraph in that the note was defined
+-- normalbaselineskip: \normalbaselineskip in the paragraph in that the note was defined
-- outputX, outputY: position on which the north west anchor of the note should
-- be placed
-- lineColor: color of line connecting note to text
@@ -311,8 +314,8 @@ end
-- valid values for noteType: nil/"" (for point in text), "area"
function luatodonotes.addNoteToList(index, drawLeader, noteType)
if next(notesForPage) ~= nil
- and index == notesForPage[#notesForPage].index then
- -- Index is the same as for the previous note.
+ and index <= notesForPage[#notesForPage].index then
+ -- Index is the same as for one of the previous note.
-- This can happen when commands are read multiple times
-- => don't add anything to list in this case
return
@@ -321,6 +324,7 @@ function luatodonotes.addNoteToList(index, drawLeader, noteType)
newNote.index = index
newNote.textbox = node.copy_list(tex.box["@todonotes@notetextbox"])
newNote.baselineskip = tex.dimen["@todonotes@baselineskip"]
+ newNote.normalbaselineskip = tex.dimen["@todonotes@normalbaselineskip"]
newNote.fontsize = tex.dimen["@todonotes@fontsize"]
newNote.lineColor = tex.toks["@todonotes@toks@currentlinecolor"]
newNote.backgroundColor = tex.toks["@todonotes@toks@currentbackgroundcolor"]
@@ -495,20 +499,34 @@ end
local inputShiftX = string.todimen("-0.05cm") -- sensible value depends on shape of mark
function luatodonotes.printNotes()
- print("drawing labels for page " .. currentPage)
+ print("Drawing notes for page " .. currentPage)
-- seperate notes that should be placed on another page
-- This can occur when note is in a paragraph which doesn't fit on the
-- current page and is thus moved to the next one. But the \todo-command is
-- still read before the shipout of the current page is done
- notesForNextPage = {}
+ luatodonotes.notesForNextPage = {}
+ notesForNextPage = luatodonotes.notesForNextPage
local k=1
while k <= #notesForPage do
local v = notesForPage[k]
- if v.pageNr ~= currentPage then
+ if v.pageNr == 0 then
+ -- Notes without a page number occur when the zref label is not
+ -- defined correctly. This happens with notes in a
+ -- \caption-command, e.g.
+ -- In this case two version of the note are stored and we drop the
+ -- note that does not have a valid page number (the other note
+ -- seems to have one).
+ table.remove(notesForPage, k)
+ if todonotesDebug then
+ print("deleting note: " .. k .. " (" .. v.index .. ")")
+ end
+ elseif v.pageNr ~= currentPage then
table.insert(notesForNextPage, v)
table.remove(notesForPage, k)
- print("moving " .. k)
+ if todonotesDebug then
+ print("moving note to next page: " .. k .. " (" .. v.index .. ")")
+ end
else
-- update index here (needed if a note was deleted before)
v.indexOnPage = k
@@ -520,7 +538,11 @@ function luatodonotes.printNotes()
for _, v in pairs(notesForPage) do
if v.noteType ~= "area" then
v.inputX = v.origInputX + inputShiftX
- v.inputY = v.origInputY - 1.3 * (v.baselineskip - v.fontsize)
+ local bls = v.baselineskip
+ if v.baselineskip == 0 then
+ bls = v.normalbaselineskip
+ end
+ v.inputY = v.origInputY - 1.3 * (bls - v.fontsize)
else
v.inputX = v.origInputX
v.inputY = v.origInputY
@@ -570,6 +592,7 @@ function luatodonotes.printNotes()
print("rasterSlots: " .. v.rasterSlots)
end
print("baselineskip: " .. outputWithPoints(v.baselineskip))
+ print("nbaselineskip:" .. outputWithPoints(v.normalbaselineskip))
print("fontsize: " .. outputWithPoints(v.fontsize))
print("textbox: " .. inspect(v.textbox))
print("height: " .. outputWithPoints(v:getHeight()))
@@ -1006,7 +1029,7 @@ local function checkCurveApproximation(curve1, curve2)
local sectionsCurve2 = {}
-- get line segments of the first curve
- local numberOfSectionsCurve1 = numberOfCurvePartitions
+ local numberOfSectionsCurve1 = luatodonotes.numberOfCurvePartitions
local temp1X, temp1Y = getPointOnCurve(0, curve1)
local i = 1
while i <= numberOfSectionsCurve1 do
@@ -1023,7 +1046,7 @@ local function checkCurveApproximation(curve1, curve2)
end
-- get line segments of the second curve
- local numberOfSectionsCurve2 = numberOfCurvePartitions
+ local numberOfSectionsCurve2 = luatodonotes.numberOfCurvePartitions
temp1X, temp1Y = getPointOnCurve(0, curve2)
i = 1
while i <= numberOfSectionsCurve2 do
@@ -1220,7 +1243,7 @@ local function drawSBezierLeaders()
v.forceLimitInc = math.huge
end
- numberOfCurvePartitions = #notesForPage * 3
+ luatodonotes.numberOfCurvePartitions = #notesForPage * 3
for _, v in pairs(notesForPage) do
computeOptimalPosition(v)
@@ -1230,9 +1253,9 @@ local function drawSBezierLeaders()
local proceed = true
local loopCounter = 0
while (proceed and loopCounter < maxIterations) do
- --print("")
- --print("--------------------------------------------------")
- print("iteration " .. loopCounter .. ":")
+ if todonotesDebug then
+ print("Iteration " .. loopCounter)
+ end
-- compute forces
computeRepulsiveControlPointForces()
@@ -1250,10 +1273,9 @@ local function drawSBezierLeaders()
loopCounter = loopCounter + 1
end
- print("")
- print("End of Force-directed algo")
- print("number of iterations: " .. loopCounter)
- print("")
+ if todonotesDebug then
+ print("End of Force-directed algo, number of iterations: " .. loopCounter)
+ end
-- draw
for _, v in pairs(notesForPage) do
@@ -1564,7 +1586,6 @@ local function posSLeaderEast(notes, rightSide)
-- build a array with all distinct heights of the notes
-- first create a set and then convert to sorted array
local heights = {}
- print(#heights)
for _, v in pairs(notes) do
heights[notesForPage[v]:getHeight()] = true
end
@@ -1574,7 +1595,9 @@ local function posSLeaderEast(notes, rightSide)
local chosenIndex = -1
local chosenH = -1
for _, h in pairs(heights) do
- print("testing height: " .. h) -- DEBUG
+ if todonotesDebug then
+ print("testing height: " .. h)
+ end
leaderPosY = noteY - noteInnerSep - h/2
-- find point with highest angle
@@ -1584,6 +1607,9 @@ local function posSLeaderEast(notes, rightSide)
if notesForPage[notes[minIndex]]:getHeight() <= h then
chosenIndex = minIndex
chosenH = h
+ if todonotesDebug then
+ print("placed note " .. notesForPage[notes[chosenIndex]].index)
+ end
break
end
end
@@ -1595,8 +1621,7 @@ local function posSLeaderEast(notes, rightSide)
note.outputY = noteY - (chosenH - note:getHeight()) / 2
-- no extraordinary free space below note (even if chosenH ~= note:getHeight())
noteY = note.outputY - note:getHeight() - 2 * noteInnerSep - noteInterSpace
- -- DEBUG
- if chosenH ~= note:getHeight() then
+ if todonotesDebug and chosenH ~= note:getHeight() then
print("Creating free space above note " .. note.index)
end
@@ -1616,8 +1641,7 @@ local function posSLeaderEast(notes, rightSide)
aimedPos = prevNote.outputY - prevNote:getHeight() - 2 * noteInnerSep - noteInterSpace
end
- -- DEBUG
- if aimedPos ~= note.outputY then
+ if todonotesDebug and aimedPos ~= note.outputY then
print("note " .. note.index .. " got moved:")
print("aimed: " .. aimedPos)
print("real: " .. note.outputY)
@@ -1658,7 +1682,9 @@ local function posSLeaderEast(notes, rightSide)
minAngle = otherNoteAngle
minAngleIndex = otherInd
end
- print(otherNote.index .. " is in triangle for " .. note.index) -- DEBUG
+ if todonotesDebug then
+ print(otherNote.index .. " is in triangle for " .. note.index)
+ end
end
end
end
@@ -1714,8 +1740,6 @@ local function getPosBelowLine(linePositionsCurPage, lineInd)
return posBelow
end
local function posPoLeaders(notes, rightSide, avoidLines)
- print("rasterHeight: " .. rasterHeight)
-
local linePositionsCurPage
if avoidLines then
linePositionsCurPage = linePositions[currentPage] or {}
@@ -2025,29 +2049,24 @@ local function posPoLeaders(notes, rightSide, avoidLines)
print("WARNING: could not fit all labels on page")
end
- print("Using result: opt[1][" .. #notes ..
- "][1][" .. totalNumSlots .. "][" .. maxPlaced .. "]")
local res = opt[1][#notes][1][totalNumSlots][maxPlaced]
- local length = res.totalLength
local positions = res.positions
local leaderShiftY = res.leaderShiftY
-
- print("")
- print("----------------")
- print("resulting length: " .. length)
- print("")
- print("resulting positions:")
- print(inspect(positions))
- print("")
- print("resulting leaderShifts:")
- print(inspect(leaderShiftY))
- print("")
- print("")
- print("")
-
-
- -- DEBUG on page
if todonotesDebug then
+ local length = res.totalLength
+ -- in console
+ print("----------------")
+ print("po-leader algorithm: Using result: opt[1][" .. #notes ..
+ "][1][" .. totalNumSlots .. "][" .. maxPlaced .. "]")
+
+ print("resulting length: " .. length)
+ print("resulting positions:")
+ print(inspect(positions))
+ print("resulting leaderShifts:")
+ print(inspect(leaderShiftY))
+ print("----------------")
+
+ -- on page
tex.print("\\node[text=blue,fill=white,rectangle,align=center] at (10.5cm,-27cm) {" ..
"total length: " .. number.tocentimeters(length, "%s%s") .. "\\\\ " ..
"rasterHeight: " .. number.tocentimeters(rasterHeight, "%s%s") ..
@@ -2096,8 +2115,9 @@ local function splitNone()
local rightSideSelected = false
if labelArea.left == nil and labelArea.right == nil then
error("Cannot place labels on any side of text (not enough space). " ..
- "Consider using the minNoteWidth option of the package to " ..
- "decrease the minimum width required")
+ "Consider using the additionalMargin option of the package to " ..
+ "extend the page margins " ..
+ "or minNoteWidth to decrease the minimum width required")
elseif labelArea.left == nil then
rightSideSelected = true
elseif labelArea.right ~= nil and
diff --git a/Master/texmf-dist/tex/lualatex/luatodonotes/luatodonotes.sty b/Master/texmf-dist/tex/lualatex/luatodonotes/luatodonotes.sty
index d300a1ba5ad..8663c610eb8 100644
--- a/Master/texmf-dist/tex/lualatex/luatodonotes/luatodonotes.sty
+++ b/Master/texmf-dist/tex/lualatex/luatodonotes/luatodonotes.sty
@@ -24,8 +24,20 @@
%%
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{luatodonotes}
- [2015/03/13 v0.2 luatodonotes source and documentation.]
+ [2015/12/03 v0.3 luatodonotes source and documentation.]
+\@ifpackageloaded{todonotes}{
+ \PackageError{luatodonotes}{%
+ Conflicting packages todonotes and luatodonotes\MessageBreak
+ loaded. Aborting.}{%
+ The package luatodonotes was designed as a replacement for todonotes. So it
+ is not possible (and not reasonable) to include both of them in the same
+ document.%
+ If you want to use luatodonotes you should delete the todonotes
+ package from\MessageBreak
+ your preamble.\MessageBreak}
+}{}
+\expandafter\def\csname ver@todonotes.sty\endcsname{2014/07/14}
\RequirePackage{ifluatex}
\ifluatex\else
\PackageError{luatodonotes}{LuaTeX is required for this package. Aborting.}{%
@@ -41,31 +53,35 @@
\usetikzlibrary{intersections}
\usetikzlibrary{decorations.pathmorphing}
\RequirePackage{luacode}
-\RequirePackage{luatex}
\RequirePackage{atbegshi}
\RequirePackage{xstring}
\RequirePackage{zref-abspage}
\RequirePackage{ifoddpage}
\RequirePackage{soul}
\RequirePackage{soulpos}
+\@ifpackagelater{luatexbase}{2013/05/04}{}{
+ \RequirePackage{luatex}
+}
\newcommand{\@todonotes@text}{}%
\newcommand{\@todonotes@backgroundcolor}{orange}
\newcommand{\@todonotes@linecolor}{black!30}
\newcommand{\@todonotes@bordercolor}{black}
\newcommand{\@todonotes@leaderwidth}{1.6pt}
\newcommand{\@todonotes@textsize}{\normalsize}
-\newcommand{\@todonotes@figwidth}{\columnwidth}
+\newcommand{\@todonotes@figwidth}{\linewidth}
\newcommand{\@todonotes@figheight}{4cm}
+\newcommand{\@todonotes@figcolor}{black!40}
\newcommand{\@todonotes@positioning}{inputOrderStacks}
\newcommand{\@todonotes@splitting}{none}
\newcommand{\@todonotes@leadertype}{opo}
\newcommand{\@todonotes@interNoteSpace}{5pt}
\newcommand{\@todonotes@noteInnerSep}{5pt}
\newcommand{\@todonotes@routingAreaWidth}{0.4cm}
-\newcommand{\@todonotes@minNoteWidth}{1.0cm}
+\newcommand{\@todonotes@minNoteWidth}{2.0cm}
\newcommand{\@todonotes@distanceNotesPageBorder}{0.5cm}
\newcommand{\@todonotes@distanceNotesText}{0.2cm}
\newcommand{\@todonotes@rasterHeight}{1cm}
+\newcommand{\@todonotes@additionalMargin}{2cm}
\AtBeginDocument{
\ifx\undefined\phantomsection
\newcommand{\phantomsection}{}
@@ -90,6 +106,12 @@
\@todonotes@SetMissingFigureUp{Figura}%
\@todonotes@SetMissingFigureDown{pendent}%
}
+\DeclareOptionX{croatian}{%
+ \@todonotes@SetTodoListName{Popis obveza}%
+ \@todonotes@SetMissingFigureText{Slika}%
+ \@todonotes@SetMissingFigureUp{Nedostaje}%
+ \@todonotes@SetMissingFigureDown{slika}%
+}
\DeclareOptionX{danish}{%
\@todonotes@SetTodoListName{G\o{}rem\aa{}lsliste}%
\@todonotes@SetMissingFigureText{Figur}%
@@ -199,6 +221,16 @@
\define@key{luatodonotes.sty}%
{figheight}{\renewcommand{\@todonotes@figheight}{#1}}
\define@key{luatodonotes.sty}%
+ {figcolor}{\renewcommand{\@todonotes@figcolor}{#1}}
+\DeclareOptionX{po}%
+ {\setkeys{luatodonotes.sty}{leadertype=po,positioning=poLeadersAvoidLines}}
+\DeclareOptionX{s}%
+ {\setkeys{luatodonotes.sty}{leadertype=s,positioning=sLeaderNorthEastBelowStacks}}
+\DeclareOptionX{bezier}%
+ {\setkeys{luatodonotes.sty}{leadertype=sBezier,positioning=sLeaderNorthEastBelowStacks}}
+\DeclareOptionX{opo}%
+ {\setkeys{luatodonotes.sty}{leadertype=opo,positioning=inputOrderStacks}}
+\define@key{luatodonotes.sty}%
{positioning}{\renewcommand{\@todonotes@positioning}{#1}}
\define@key{luatodonotes.sty}%
{splitting}{\renewcommand{\@todonotes@splitting}{#1}}
@@ -219,6 +251,12 @@
{distanceNotesText}{\renewcommand{\@todonotes@distanceNotesText}{#1}}
\define@key{luatodonotes.sty}%
{rasterHeight}{\renewcommand{\@todonotes@rasterHeight}{#1}}
+\newif{\if@todonotes@additionalMarginEnabled}
+\@todonotes@additionalMarginEnabledfalse
+\define@key{luatodonotes.sty}%
+ {additionalMargin}[\@todonotes@additionalMargin]{%
+ \@todonotes@additionalMarginEnabledtrue
+ \renewcommand{\@todonotes@additionalMargin}{#1}}
\newif{\if@todonotes@debugenabled}
\@todonotes@debugenabledfalse
\DeclareOptionX{debug}{\@todonotes@debugenabledtrue}
@@ -238,6 +276,16 @@
\fi
\fi
\fi
+\if@todonotes@additionalMarginEnabled
+ \newlength{\@todonotes@modpaperwidth}
+ \AtBeginDocument{%
+ \setlength{\@todonotes@modpaperwidth}{\paperwidth}%
+ \addtolength{\@todonotes@modpaperwidth}{\@todonotes@additionalMargin}%
+ \addtolength{\@todonotes@modpaperwidth}{\@todonotes@additionalMargin}%
+ \pdfpagewidth=\@todonotes@modpaperwidth%
+ \addtolength{\hoffset}{\@todonotes@additionalMargin}%
+ }%
+\fi%
\newdimen\@todonotes@extractx
\newdimen\@todonotes@extracty
\newsavebox\@todonotes@heightcalcbox
@@ -245,6 +293,7 @@
\newdimen\@todonotes@heightcalcboxheight
\newsavebox\@todonotes@notetextbox
\newdimen\@todonotes@baselineskip
+\newdimen\@todonotes@normalbaselineskip
\newdimen\@todonotes@fontsize
\newdimen\@todonotes@currentsidemargin
\directlua{require("luatodonotes")}
@@ -400,6 +449,9 @@
\newcommand{\@todonotes@currentfigheight}{\@todonotes@figheight}
\define@key{todonotes}%
{figheight}{\renewcommand{\@todonotes@currentfigheight}{#1}}
+\newcommand{\@todonotes@currentfigcolor}{\@todonotes@figcolor}
+\define@key{todonotes}%
+ {figcolor}{\renewcommand{\@todonotes@currentfigcolor}{#1}}
\presetkeys%
{todonotes}%
{linecolor=\@todonotes@linecolor,%
@@ -412,6 +464,7 @@
noauthor,%
figwidth=\@todonotes@figwidth,%
figheight=\@todonotes@figheight,%
+ figcolor=\@todonotes@figcolor,%
line, list, size=\@todonotes@textsize}{}%
\newif\if@todonotes@areaselected%
\newtoks\@todonotes@toks@currentlinecolor%
@@ -425,8 +478,13 @@
\newcommand{\@todoarea}[3][]{}
\newcommand{\missingfigure}[2][]{}
\else % \if@todonotes@disabled
-\newcommand{\listoftodos}[1][\@todonotes@todolistname]
- {\@ifundefined{chapter}{\section*{#1}}{\chapter*{#1}} \@starttoc{tdo}}
+\newcounter{todonotes@oldtocdepth}
+\newcommand{\listoftodos}[1][\@todonotes@todolistname]{%
+ \setcounter{todonotes@oldtocdepth}{\value{tocdepth}}%
+ \setcounter{tocdepth}{1}%
+ \@ifundefined{chapter}{\section*{#1}}{\chapter*{#1}} \@starttoc{tdo}%
+ \setcounter{tocdepth}{\value{todonotes@oldtocdepth}}%
+}
\newcommand{\l@todo}
{\@dottedtocline{1}{0em}{2.3em}}
\tikzset{@todonotes@todoarea/.style={
@@ -501,6 +559,7 @@
inText) {};%
\end{tikzpicture}%
\@todonotes@baselineskip=\baselineskip%
+ \@todonotes@normalbaselineskip=\normalbaselineskip%
\@todonotes@fontsize=\f@size pt%
\zref@label{@todonotes@\arabic{@todonotes@numberoftodonotes}}%
\if@todonotes@authorgiven%
@@ -563,7 +622,7 @@
\par
\noindent
\begin{tikzpicture}
-\draw[fill=black!40, draw = white, line width=0pt]
+\draw[fill=\@todonotes@currentfigcolor, draw = black!40, line width=2pt]
(-2, -2.5) rectangle +(\@todonotes@currentfigwidth, \@todonotes@currentfigheight);
\draw (2, -0.3) node[right, text
width=\@todonotes@currentfigwidth-4.5cm] {#2};
@@ -571,9 +630,9 @@
(30:2cm) -- (150:2cm) -- (270:2cm) -- cycle;
\draw (0, 0.3) node {\@todonotes@MissingFigureUp};
\draw (0, -0.3) node {\@todonotes@MissingFigureDown};
-\end{tikzpicture}
+\end{tikzpicture}\hfill
}% Ending \missingfigure command
-\fi % Ending \@todonotes@ifdisabled
+\fi% Ending \@todonotes@ifdisabled
\newcommand{\todototoc}
{
\if@todonotes@disabled
@@ -597,10 +656,13 @@
\BeginCatcodeRegime\CatcodeTableLaTeX
\directlua{luatodonotes.calcLabelAreaDimensions()}%
\directlua{luatodonotes.calcHeightsForNotes()}% has to be outside of tikzpicture
- \begin{tikzpicture}[remember picture,overlay]
- \directlua{luatodonotes.getInputCoordinatesForNotes()}
- \directlua{luatodonotes.printNotes()}
- \end{tikzpicture}%
+ \raisebox{\voffset}{%
+ \hspace{-\hoffset}%
+ \begin{tikzpicture}[remember picture,overlay]
+ \directlua{luatodonotes.getInputCoordinatesForNotes()}
+ \directlua{luatodonotes.printNotes()}
+ \end{tikzpicture}%
+ }%
\directlua{luatodonotes.clearNotes()}%
\EndCatcodeRegime
}%