summaryrefslogtreecommitdiff
path: root/Master/texmf-dist
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2015-03-13 23:23:22 +0000
committerKarl Berry <karl@freefriends.org>2015-03-13 23:23:22 +0000
commit3e4facabd7e33e78ece63d391d6fc6c94842873d (patch)
tree6774944cbbd3246b1f8bf37f20927ad03355ada8 /Master/texmf-dist
parent92c0eccd62a3eb57e56ee44400ebe63fec446bf6 (diff)
luatodonotes (13mar15)
git-svn-id: svn://tug.org/texlive/trunk@36505 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist')
-rw-r--r--Master/texmf-dist/doc/lualatex/luatodonotes/README25
-rw-r--r--Master/texmf-dist/doc/lualatex/luatodonotes/README.md32
-rw-r--r--Master/texmf-dist/doc/lualatex/luatodonotes/luatodonotes.pdfbin186868 -> 195338 bytes
-rw-r--r--Master/texmf-dist/source/lualatex/luatodonotes/luatodonotes.dtx263
-rw-r--r--Master/texmf-dist/source/lualatex/luatodonotes/luatodonotes.ins16
-rw-r--r--Master/texmf-dist/tex/lualatex/luatodonotes/luatodonotes.lua447
-rw-r--r--Master/texmf-dist/tex/lualatex/luatodonotes/luatodonotes.sty101
7 files changed, 501 insertions, 383 deletions
diff --git a/Master/texmf-dist/doc/lualatex/luatodonotes/README b/Master/texmf-dist/doc/lualatex/luatodonotes/README
deleted file mode 100644
index cd40a3995b4..00000000000
--- a/Master/texmf-dist/doc/lualatex/luatodonotes/README
+++ /dev/null
@@ -1,25 +0,0 @@
-This package allows you to insert comments for further editing in your document.
-The comments are shown in the margins besides the text.
-Different styles for the comments can be used, which can be configured using
-package options.
-This package depends heavily on Lua, so it can only be used with LuaLaTeX.
-
-luatodonotes is based on the todonotes package by Henrik Skov Midtiby
-(http://www.ctan.org/pkg/todonotes).
-
-Installation
-------------
-Run 'latex luatodonotes.ins' to generate the package files and copy the listed
-files into your TEXMF tree.
-
-License
--------
-The luatodonotes package is subject to the LATEX Project Public License.
-The following external lua libraries are used:
-
-- path_line.lua and path_point.lua
- taken from luapower.com (Public domain)
-
-- inspect.lua
- by Enrique García Cota
- MIT License
diff --git a/Master/texmf-dist/doc/lualatex/luatodonotes/README.md b/Master/texmf-dist/doc/lualatex/luatodonotes/README.md
new file mode 100644
index 00000000000..a3ff72c082a
--- /dev/null
+++ b/Master/texmf-dist/doc/lualatex/luatodonotes/README.md
@@ -0,0 +1,32 @@
+# luatodonotes
+The package allows the user to insert comments into a document that
+suggest (for example) further editing that may be needed.
+
+The comments are shown in the margins alongside the text; different styles
+for the comments may be used; the styles are selected using package
+options.
+
+The package is based on the package todonotes by Henrik Skov Midtiby
+(http://www.ctan.org/pkg/todonotes), and depends heavily on Lua,
+so it can only be used with LuaLaTeX.
+
+
+## Installation
+Run `latex luatodonotes.ins` to generate the package files and copy the listed
+files into your TEXMF tree.
+
+
+## Development
+The latest source code is available on Github:
+https://github.com/fabianlipp/luatodonotes
+
+
+## License
+The luatodonotes package is subject to the LATEX Project Public License.
+The following external lua libraries are used:
+
+* `path_line.lua` and `path_point.lua`:
+ taken from luapower.com (Public domain)
+
+* `inspect.lua`:
+ by Enrique García Cota (MIT License)
diff --git a/Master/texmf-dist/doc/lualatex/luatodonotes/luatodonotes.pdf b/Master/texmf-dist/doc/lualatex/luatodonotes/luatodonotes.pdf
index d6ebf3dae39..e9291dd8a24 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 3188307f4c5..79537444e2e 100644
--- a/Master/texmf-dist/source/lualatex/luatodonotes/luatodonotes.dtx
+++ b/Master/texmf-dist/source/lualatex/luatodonotes/luatodonotes.dtx
@@ -1,9 +1,9 @@
% \iffalse meta-comment
%
-% Copyright (C) 2014 by Fabian Lipp <fabian.lipp@gmx.de>
+% Copyright (C) 2014-2015 by Fabian Lipp <fabian.lipp@gmx.de>
% based on the todonotes package
% by Henrik Skov Midtiby <henrikmidtiby@gmail.com>
-% -------------------------------------------------------
+% ------------------------------------------------------------
%
% This file may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.2
@@ -24,20 +24,20 @@
%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
%<package>\ProvidesPackage{luatodonotes}
%<*package>
- [2014/08/07 v0.1 luatodonotes source and documentation.]
+ [2015/03/13 v0.2 luatodonotes source and documentation.]
%</package>
%
%<*driver>
\documentclass{ltxdoc}
\usepackage{wrapfig}
\usepackage[colorlinks, linkcolor=black, urlcolor=blue]{hyperref}
-\usepackage[colorinlistoftodos, shadow]{luatodonotes}[2014/06/08]
+\usepackage[colorinlistoftodos, shadow]{luatodonotes}[2015/03/13]
\usepackage{fontspec}
\usepackage{amsmath}
\usepackage{setspace}
\usepackage{soul}
\setcounter{tocdepth}{2}
-\EnableCrossrefs
+\EnableCrossrefs
\CodelineIndex
\RecordChanges
\begin{document}
@@ -50,7 +50,7 @@
%</driver>
% \fi
%
-% \CheckSum{841}
+% \CheckSum{825}
%
% \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,7 +70,19 @@
%
%
% \changes{0.1}{2014/08/07}{The first version of the package}
-% \GetFileInfo{luatodonotes.dtx}
+% \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}
+% \GetFileInfo{luatodonotes.dtx}
%
% \DoNotIndex{\newcommand,\newenvironment}
%
@@ -95,10 +107,11 @@
% to--do items can be listed with the |\listoftodos| command.
%
% It is an extended version of the |todonotes| package and uses more advanced
-% algorithms to place the to--do notes notes on the page.
+% algorithms to place the to--do notes on the page.
% For this algorithms it depends on Lua\TeX.
% \end{abstract}
%
+% \pdfbookmark[1]{Contents}{contents}
% \tableofcontents
%
% \newpage
@@ -123,13 +136,13 @@
%
% Some alternatives for the luatodonotes package are:
% \begin{itemize}
-% \item \href{http://www.ctan.org/tex-archive/macros/latex/contrib/easy-todo}{easy-todo}\\
+% \item \href{http://www.ctan.org/pkg/easy-todo}{easy-todo}\\
% Depends on |color|, |tocloft| and |ifthen|, small feature set.
% \item \href{http://www.ctan.org/pkg/fixmetodonotes}{fixmetodonotes}\\
% Depends on |graphicx|, |color|, |transparent|, |watermark|, |fix-cm|, |ulem| and |tocloft|, small feature set.
-% \item \href{http://www.ctan.org/tex-archive/macros/latex/contrib/todo}{todo}\\
+% \item \href{http://www.ctan.org/pkg/todo}{todo}\\
% Depends on |amssymb|, medium feature set.
-% \item \href{http://www.ctan.org/tex-archive/macros/latex/contrib/fixme}{fixme}\\
+% \item \href{http://www.ctan.org/pkg/fixme}{fixme}\\
% Large package with a lot of features.
% \item \href{http://www.ctan.org/pkg/todonotes}{todonotes}
% \end{itemize}
@@ -139,7 +152,7 @@
% page.
% Additionally, we are able to place notes at almost every position on the
% page, e.\,g., in floating environments or in footnotes.
-% As a disadvantage luatodonotes requires Lua\LaTeX for document processing, so
+% As a disadvantage luatodonotes requires Lua\LaTeX{} for document processing, so
% a standard |pdflatex| won't work.
% Depending on the chosen layout for the to--do notes the runtime can be much
% higher than with todonotes.
@@ -147,13 +160,28 @@
% |\marginpar|.
%
% The main reason for considering other packages is that the todonotes
-% package is quire large and relies heavily on tikz.
+% package is quite large and relies heavily on tikz.
% This can slow down compilation of large documents significantly.
-% The mentioned alternatives have a different feature set and does not
+% The mentioned alternatives have a different feature set and do not
% rely on tikz, which makes them require less ressoureces.
%
%
-% \subsection{Usage}
+%
+% \subsection{Using Lua\LaTeX}
+% It is quite easy to switch from |pdflatex| to |lualatex|.
+% You only have to load a few different packages.
+% A small guide can be found in the Lua\LaTeX{}
+% guide\footnote{\url{http://mirror.ctan.org/info/luatex/lualatex-doc/lualatex-doc.pdf}}.
+%
+% The Lua\TeX{} processor (the |lualatex| executable) should be included in all
+% modern \TeX{} distributions, so you do not need to install additional
+% software.
+% You simply have to run |lualatex| instead of |pdflatex| (or instead of
+% |latex|, |xelatex|).
+%
+%
+%
+% \subsection{Usage of luatodonotes}
% The package is loaded with |\usepackage|\oarg{options}|{luatodonotes}|.
% Valid options are described in Section~\ref{subsecPackageOptions}.
% Note that |todonotes| must \emph{not} be loaded.
@@ -434,7 +462,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 |2.0cm|.
+% The default value of this option is |1.0cm|.
%
% \DescribeMacro{distanceNotesPageBorder}
% The |distanceNotesPageBorder=length| option specifies the horizontal distance
@@ -466,7 +494,7 @@
%
%
%
-% \subsection{Options for the todo command}
+% \subsection{Options for the \texttt{todo} command}
% \label{subsecTodoOptions}
% There are several options that can be given to the |\todo|
% command. All the options are described here and often I have
@@ -608,7 +636,7 @@
% \todo[author=Xavier, inline]{Testing author option.}
% \end{verbatim}
%
-% \subsection{Options for the missingfigure command}
+% \subsection{Options for the \texttt{missingfigure} command}
%
% \DescribeMacro{figwidth}
% The |figwidth=length| option sets the width of the figure inserted by the
@@ -647,7 +675,7 @@
% \missingfigure[figheight=6cm]{Testing}
%
%
-% \subsection{Options for the listoftodos command}
+% \subsection{Options for the \texttt{listoftodos} command}
% The |\listoftodos| command takes one optional argument, that
% defines the name of the inserted list of todos.
% \begin{verbatim}
@@ -655,6 +683,54 @@
% \end{verbatim}
%
%
+% \subsection{Troubleshooting}
+% \subsubsection{Missing Lua files}
+% A potential error message when Lua source files are not found, is the
+% following:
+% \begin{verbatim}
+% ! LuaTeX error [\directlua]:1: module 'luatodonotes' not found:
+% no field package.preload['luatodonotes']
+% [luatexbase.loader] Search failed
+% [kpse lua searcher] file not found: 'luatodonotes'
+% [kpse C searcher] file not found: 'luatodonotes'
+% [oberdiek.luatex.kpse_module_loader]-eroux Search failed
+% stack traceback:
+% [C]: in function 'require'
+% [\directlua]:1: in main chunk.
+% l.250 \directlua{require("luatodonotes")}
+% \end{verbatim}
+% This means that the file |luatodonotes.lua| cannot be found by Lua\TeX.
+% It depends on the version of your \TeX{} installation. in which directories
+% Lua\TeX{} is looking for Lua source files.
+% You can query these paths with the following command:
+% \begin{verbatim}
+% kpsewhich -show-path=lua\end{verbatim}
+% See the |kpathsea|
+% documentation\footnote{\url{http://tug.org/texinfohtml/kpathsea.html}} for
+% the interpretation of this path.
+% The Lua source files of the |luatodonotes| package should be in one of the
+% searched directories.
+% You can modify the path in your \TeX{} configuration or using environment
+% variables.
+% 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
+% texmf tree.
+%
+% \subsubsection{The \texttt{debug} option}
+% You can load the package with the option |debug| (see
+% Section~\ref{subsecPackageOptions}).
+% It gives some additional information in the console while running Lua\TeX{}
+% and draws additional information into the output document.
+% For example, the size of the computed areas, in which the labels are placed,
+% is shown in the document.
+% Depending on the chosen layout algorithm some intermediate steps of the
+% algorithms are given.
+%
+%
+%
+%
%
% \subsection{Known issues}
% \subsubsection{Package loading order}
@@ -739,8 +815,8 @@
% only newer versions of latex driver for tikz supports the
% |remember picture| option.
% For additional info consult
-% ''Section 9.2.2 Producing PDF Output'' in the tikz manual.
-% \url{http://www.ctan.org/tex-archive/graphics/pgf/base/doc/generic/pgf/pgfmanual.pdf}
+% ''Section 10.2.2 Producing PDF Output'' in the tikz manual.
+% \url{http://mirror.ctan.org/graphics/pgf/base/doc/pgfmanual.pdf}
%
%
%
@@ -771,14 +847,43 @@
% \iffalse
% \StopEventually{\PrintChanges\PrintIndex}
% \fi
-% \StopEventually{\PrintChanges}
+% \StopEventually{\clearpage\pdfbookmark{Changes}{changes}\PrintChanges}
%
% \newpage
% \section{Implementation}
+% 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
+% inside this file.
+% These comments are primarily describing technical aspects.
+% Information about the implemented algorithms and some theoretical
+% considerations can be found in the following documents:
+% \begin{itemize}
+% \item Kindermann, P., Lipp, F., and Wolff, A.:
+% Luatodonotes: Boundary Labeling for Annotations in Texts.
+% In: Duncan, C. and Symvonis, A. (eds.) Proc. 22nd Int. Sympos. Graph Drawing GD'14.
+% LNCS, vol. 8871, pp. 76-88. Springer, Heidelberg (2014)
+% \url{http://dx.doi.org/10.1007/978-3-662-45803-7_7}
+% \item Lipp, F.:
+% Boundary Labeling for Annotations in Texts.
+% Master thesis, 2014.
+% \url{http://www1.pub.informatik.uni-wuerzburg.de/pub/theses/2014-lipp-master.pdf}
+% \end{itemize}
%
-% Identifies the package and loads the packages dependences.
+% \subsection{Dependencies and definitions}
+% Check if Lua\TeX{} is used.
+% \changes{0.2}{2015/02/23}{Check if LuaTeX is used at begin of package}
+% \begin{macrocode}
+\RequirePackage{ifluatex}
+\ifluatex\else
+ \PackageError{luatodonotes}{LuaTeX is required for this package. Aborting.}{%
+ This package can only be used with the LuaTeX engine\MessageBreak
+ (command `lualatex'). Package loading has been stopped\MessageBreak
+ to prevent additional errors.}
+\fi
+% \end{macrocode}
+% Loads the packages dependencies.
% \begin{macrocode}
-\ProvidesPackage{luatodonotes}[2014/06/08]
\RequirePackage{ifthen}
\RequirePackage{xkeyval}
\RequirePackage{xcolor}
@@ -814,7 +919,7 @@
\newcommand{\@todonotes@interNoteSpace}{5pt}
\newcommand{\@todonotes@noteInnerSep}{5pt}
\newcommand{\@todonotes@routingAreaWidth}{0.4cm}
-\newcommand{\@todonotes@minNoteWidth}{2.0cm}
+\newcommand{\@todonotes@minNoteWidth}{1.0cm}
\newcommand{\@todonotes@distanceNotesPageBorder}{0.5cm}
\newcommand{\@todonotes@distanceNotesText}{0.2cm}
\newcommand{\@todonotes@rasterHeight}{1cm}
@@ -1162,67 +1267,27 @@
% \end{macrocode}
% Setting variables to values given by package options.
% \begin{macrocode}
-\directlua{noteInnerSep =
+\directlua{luatodonotes.noteInnerSep =
string.todimen("\luatexluaescapestring{\@todonotes@noteInnerSep}")}
-\directlua{noteInterSpace =
+\directlua{luatodonotes.noteInterSpace =
string.todimen("\luatexluaescapestring{\@todonotes@interNoteSpace}")}
-\directlua{routingAreaWidth =
+\directlua{luatodonotes.routingAreaWidth =
string.todimen("\luatexluaescapestring{\@todonotes@routingAreaWidth}")}
-\directlua{minNoteWidth =
+\directlua{luatodonotes.minNoteWidth =
string.todimen("\luatexluaescapestring{\@todonotes@minNoteWidth}")}
-\directlua{distanceNotesPageBorder =
+\directlua{luatodonotes.distanceNotesPageBorder =
string.todimen("\luatexluaescapestring{\@todonotes@distanceNotesPageBorder}")}
-\directlua{distanceNotesText =
+\directlua{luatodonotes.distanceNotesText =
string.todimen("\luatexluaescapestring{\@todonotes@distanceNotesText}")}
-\directlua{rasterHeight =
+\directlua{luatodonotes.rasterHeight =
string.todimen("\luatexluaescapestring{\@todonotes@rasterHeight}")}
% \end{macrocode}
-% Set the variable for the positioning algorithm depending on the corresponding
-% package option.
-% \begin{macrocode}
-\IfStrEqCase{\@todonotes@positioning}{%
- {inText}{\directlua{positioning = positioningAlgos["inText"]}}%
- {inputOrder}{\directlua{positioning = positioningAlgos["inputOrder"]}}%
- {inputOrderStacks}{\directlua{positioning =
- positioningAlgos["inputOrderStacks"]}}%
- {sLeaderNorthEast}{\directlua{positioning =
- positioningAlgos["sLeaderNorthEast"]}}%
- {sLeaderNorthEastBelow}{\directlua{positioning =
- positioningAlgos["sLeaderNorthEastBelow"]}}%
- {sLeaderEast}{\directlua{positioning =
- positioningAlgos["sLeaderEast"]}}%
- {poLeaders}{\directlua{positioning = positioningAlgos["poLeaders"]}}%
- {poLeadersAvoidLines}{\directlua{positioning =
- positioningAlgos["poLeadersAvoidLines"]}}%
- {sLeaderNorthEastBelowStacks}{\directlua{positioning =
- positioningAlgos["sLeaderNorthEastBelowStacks"]}}}%
- [\directlua{positioning = positioningAlgos["inputOrderStacks"]}
- \PackageWarningNoLine{luatodonotes}
- {Invalid value for parameter positioning: \@todonotes@positioning}]
-% \end{macrocode}
-% Set the variable for the splitting algorithm depending on the corresponding
-% package option.
-% \begin{macrocode}
-\IfStrEqCase{\@todonotes@splitting}{%
- {none}{\directlua{splitting = splittingAlgos["none"]}}%
- {middle}{\directlua{splitting = splittingAlgos["middle"]}}%
- {median}{\directlua{splitting = splittingAlgos["median"]}}%
- {weightedMedian}{\directlua{splitting = splittingAlgos["weightedMedian"]}}}%
- [\directlua{splitting = splittingAlgos["none"]}
- \PackageWarningNoLine{luatodonotes}
- {Invalid value for parameter split: \@todonotes@splitting}]
-% \end{macrocode}
-% Specify the requested leader type.
-% \begin{macrocode}
-\IfStrEqCase{\@todonotes@leadertype}{%
- {s}{\directlua{leaderType = leaderTypes["s"]}}%
- {opo}{\directlua{leaderType = leaderTypes["opo"]}}%
- {po}{\directlua{leaderType = leaderTypes["po"]}}%
- {sBezier}{\directlua{leaderType = leaderTypes["sBezier"]}}%
- {os}{\directlua{leaderType = leaderTypes["os"]}}}%
- [\directlua{leaderType = leaderTypes["opo"]}
- \PackageWarningNoLine{luatodonotes}
- {Invalid value for parameter leadertype: \@todonotes@leadertype}]
+% Set the variables for the used algorithms and leader types depending on the
+% corresponding package options.
+% \begin{macrocode}
+\directlua{luatodonotes.setPositioningAlgo("\luatexluaescapestring{\@todonotes@positioning}")}
+\directlua{luatodonotes.setSplittingAlgo("\luatexluaescapestring{\@todonotes@splitting}")}
+\directlua{luatodonotes.setLeaderType("\luatexluaescapestring{\@todonotes@leadertype}")}
% \end{macrocode}
% The following commands are used to detect the absolute positions of lines on
% the page.
@@ -1239,10 +1304,10 @@
% thus can collect the line positions in a Lua table.
% \begin{macrocode}
\newcommand{\@todonotes@lineposition}[3]{%
- \directlua{linePositionsAddLine(#1,#2,#3)}%
+ \directlua{luatodonotes.linePositionsAddLine(#1,#2,#3)}%
}
\newcommand{\@todonotes@nextpage}{%
- \directlua{linePositionsNextPage()}%
+ \directlua{luatodonotes.linePositionsNextPage()}%
}%
% \end{macrocode}
% The following macro is used in \texttt{AtBeginShipout} to signal in the
@@ -1260,11 +1325,11 @@
% debug mode.
% \begin{macrocode}
\if@todonotes@debugenabled
- \directlua{todonotesDebug = true}
+ \directlua{luatodonotes.todonotesDebug = true}
\newcommand{\@todonotes@AtBeginShipoutUpperLeft}
{\AtBeginShipoutUpperLeftForeground}
\else
- \directlua{todonotesDebug = false}
+ \directlua{luatodonotes.todonotesDebug = false}
\newcommand{\@todonotes@AtBeginShipoutUpperLeft}
{\AtBeginShipoutUpperLeft}
\fi
@@ -1272,7 +1337,7 @@
% Initialise the script when all Lua variables are set according to the package
% options.
% \begin{macrocode}
-\directlua{initTodonotes()}
+\directlua{luatodonotes.initTodonotes()}
% \end{macrocode}
% Some definitions to highlight areas in text.
% The first command is needed to accept control spaces (|\ |) in arguments for
@@ -1301,7 +1366,7 @@
{% last line of area
\def\todonotes@textmark@decoRight{}%
\addtolength\todonotes@textmark@width{2pt}%
- \directlua{processLastLineInTodoArea()}}%
+ \directlua{luatodonotes.processLastLineInTodoArea()}}%
{\def\todonotes@textmark@decoRight{@todonotes@todoarea}%
\addtolength\todonotes@textmark@width{4pt}}%
\newcommand{\@todonotes@nodeNamePrefix}%
@@ -1647,9 +1712,19 @@
\@todonotes@toks@sizecommand=\expandafter{\@todonotes@sizecommand}%
% \end{macrocode}
% We store the text that should be shown in this note into a box and copy this
-% box to a variable in Lua.
-% \begin{macrocode}
- \savebox\@todonotes@notetextbox{\@todonotes@sizecommand\@todonotes@text}%
+% box to a variable in Lua. The commands |\@parboxrestore|, |\@marginparreset|,
+% |\@minipagefalse| and |\outer@nobreak| are copied from the definition of
+% |\marginpar| in \LaTeX 2e to reset font settings, for example.
+% This is important when a note is placed inside a theorem environment.
+% \changes{0.2}{2015/02/20}{Reset font settings at begin of a todo note}
+% \begin{macrocode}
+ \savebox\@todonotes@notetextbox{%
+ \@parboxrestore
+ \@marginparreset
+ \@todonotes@sizecommand\@todonotes@text%
+ \@minipagefalse
+ \outer@nobreak
+ }%
% \end{macrocode}
% Prepare parameters and add the note to the list in Lua.
% \begin{macrocode}
@@ -1663,7 +1738,7 @@
\else%
\def\@todonotes@param@noteType{}%
\fi%
- \directlua{addNoteToList(\arabic{@todonotes@numberoftodonotes},%
+ \directlua{luatodonotes.addNoteToList(\arabic{@todonotes@numberoftodonotes},%
\@todonotes@param@drawLeader,\luastringO{\@todonotes@param@noteType})}%
}%
% \end{macrocode}
@@ -1771,10 +1846,8 @@
\checkoddpage%
\ifoddpageoroneside%
\@todonotes@currentsidemargin=\the\oddsidemargin%
- \directlua{currentPageOdd = true}%
\else%
\@todonotes@currentsidemargin=\the\evensidemargin%
- \directlua{currentPageOdd = false}%
\fi\relax%
% \end{macrocode}
% We switch to the default catcodes of \LaTeX\ here.
@@ -1788,29 +1861,29 @@
% So this has to be done inside |\AtBeginShipoutUpperLeft| (otherwise odd/even
% page detection won't work).
% \begin{macrocode}
- \directlua{calcLabelAreaDimensions()}%
+ \directlua{luatodonotes.calcLabelAreaDimensions()}%
% \end{macrocode}
% Calculates the needed height for every note.
% This has to be outside of the tikzpicture because it uses a savebox to compute
% the height.
% This box does not work in the tikzpicture.
% \begin{macrocode}
- \directlua{calcHeightsForNotes()}% has to be outside of tikzpicture
+ \directlua{luatodonotes.calcHeightsForNotes()}% has to be outside of tikzpicture
\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{getInputCoordinatesForNotes()}
+ \directlua{luatodonotes.getInputCoordinatesForNotes()}
% \end{macrocode}
% Runs the positioning algorithm and actually draws the notes and leaders.
% \begin{macrocode}
- \directlua{printNotes()}
+ \directlua{luatodonotes.printNotes()}
\end{tikzpicture}%
% \end{macrocode}
% Delete the drawn notes from the Lua lists and prepare for the next page.
% \begin{macrocode}
- \directlua{clearNotes()}%
+ \directlua{luatodonotes.clearNotes()}%
\EndCatcodeRegime
}%
}
diff --git a/Master/texmf-dist/source/lualatex/luatodonotes/luatodonotes.ins b/Master/texmf-dist/source/lualatex/luatodonotes/luatodonotes.ins
index 779664abf56..1fc75094df2 100644
--- a/Master/texmf-dist/source/lualatex/luatodonotes/luatodonotes.ins
+++ b/Master/texmf-dist/source/lualatex/luatodonotes/luatodonotes.ins
@@ -1,5 +1,5 @@
%%
-%% Copyright (C) 2014 by Fabian Lipp <fabian.lipp@gmx.de>
+%% Copyright (C) 2014-2015 by Fabian Lipp <fabian.lipp@gmx.de>
%% based on the todonotes package by
%% Henrik Skov Midtiby <henrikmidtiby@gmail.com>
%%
@@ -17,13 +17,13 @@
\input docstrip.tex
\keepsilent
-\usedir{tex/latex/luatodonotes}
+\usedir{tex/lualatex/luatodonotes}
\preamble
This is a generated file.
-Copyright (C) 2014 by Fabian Lipp <fabian.lipp@gmx.de>
+Copyright (C) 2014-2015 by Fabian Lipp <fabian.lipp@gmx.de>
based on the todonotes package by
Henrik Skov Midtiby <henrikmidtiby@gmail.com>
@@ -41,6 +41,7 @@ and version 1.2 or later is part of all distributions of LaTeX version
\generate{\file{luatodonotes.sty}{\from{luatodonotes.dtx}{package}}}
+\catcode`~=11\relax % needed to write ~ in the following message
\obeyspaces
\Msg{*************************************************************}
\Msg{* *}
@@ -53,6 +54,15 @@ and version 1.2 or later is part of all distributions of LaTeX version
\Msg{* path_point.lua *}
\Msg{* inspect.lua *}
\Msg{* *}
+\Msg{* A suitable directory would be *}
+\Msg{* texmf/tex/lualatex/luatodonotes *}
+\Msg{* in your local texmf-tree. For example, on a Linux system *}
+\Msg{* with TeX Live you can find the texmf-directory in your *}
+\Msg{* home directory under ~/texmf or system-wide under *}
+\Msg{* /usr/share/texmf. *}
+\Msg{* Don't forget to run texhash after copying the files (as *}
+\Msg{* root if installed system-wide). *}
+\Msg{* *}
\Msg{* To produce the documentation run the file todonotes.dtx *}
\Msg{* through LaTeX. *}
\Msg{* *}
diff --git a/Master/texmf-dist/tex/lualatex/luatodonotes/luatodonotes.lua b/Master/texmf-dist/tex/lualatex/luatodonotes/luatodonotes.lua
index 61175bbbf68..f84fc9415de 100644
--- a/Master/texmf-dist/tex/lualatex/luatodonotes/luatodonotes.lua
+++ b/Master/texmf-dist/tex/lualatex/luatodonotes/luatodonotes.lua
@@ -1,6 +1,6 @@
--
--- Copyright (C) 2014 by Fabian Lipp <fabian.lipp@gmx.de>
--- -------------------------------------------------------
+-- Copyright (C) 2014-2015 by Fabian Lipp <fabian.lipp@gmx.de>
+-- ------------------------------------------------------------
--
-- This file may be distributed and/or modified under the
-- conditions of the LaTeX Project Public License, either version 1.2
@@ -21,7 +21,7 @@ local point = require'path_point'
local pathLine = require'path_line'
--local bezier3 = require'path_bezier3'
--- TODO Funktionen/Variablen in Namespace o. Ä. packen
+luatodonotes = {}
-- strings used to switch to standard catcodes for LaTeX packages
local catcodeStart = "\\makeatletter"
@@ -40,16 +40,57 @@ local const1In = string.todimen("1in") -- needed for calculations of page border
-- + distanceNotesPageBorder (distance from the page borders to the outmost point
-- of the labels)
-- + distanceNotesText (horizontal distance between the labels and the text area)
+-- + rasterHeight (height of raster for po leader algorithm)
-- + todonotesDebug (activate debug outputs when true)
+--
+-- values are filled into local variables in function initTodonotes (from
+-- corresponding fields luatodonotes.*)
+local noteInnerSep = nil
+local noteInterSpace = nil
+local routingAreaWidth = nil
+local minNoteWidth = nil
+local distanceNotesPageBorder = nil
+local distanceNotesText = nil
+local rasterHeight = nil
+local todonotesDebug = nil
-- stores information about available algorithms
-positioningAlgos = {}
-splittingAlgos = {}
-leaderTypes = {}
+local positioningAlgos = {}
+local splittingAlgos = {}
+local leaderTypes = {}
+
+local positioning = nil
+local splitting = nil
+local leaderType = nil
+function luatodonotes.setPositioningAlgo(algo)
+ if positioningAlgos[algo] ~= nil then
+ positioning = positioningAlgos[algo]
+ else
+ positioning = positioningAlgos["inputOrderStacks"]
+ tex.print("\\PackageWarningNoLine{luatodonotes}{Invalid value for parameter positioning: " .. algo .. "}")
+ end
+end
+function luatodonotes.setSplittingAlgo(algo)
+ if splittingAlgos[algo] ~= nil then
+ splitting = splittingAlgos[algo]
+ else
+ splitting = splittingAlgos["none"]
+ tex.print("\\PackageWarningNoLine{luatodonotes}{Invalid value for parameter split: " .. algo .. "}")
+ end
+end
+function luatodonotes.setLeaderType(typ)
+ if leaderTypes[typ] ~= nil then
+ leaderType = leaderTypes[typ]
+ else
+ leaderType = leaderTypes["opo"]
+ tex.print("\\PackageWarningNoLine{luatodonotes}{Invalid value for parameter leadertype: " .. typ .. "}")
+ end
+end
-- stores the notes for the current page
-notesForPage = {}
+luatodonotes.notesForPage = {}
+local notesForPage = luatodonotes.notesForPage
-- Fields for each note:
-- index: numbers notes in whole document
-- indexOnPage: index of the note in the notesForPage array
@@ -71,6 +112,7 @@ notesForPage = {}
-- backgroundColor: color of background of note
-- borderColor: color of border of note
-- leaderWidth: width of leader (used as argument for tikz line width)
+-- sizeCommand: fontsize command given as parameter for this note
--
-- Additional fields for text area:
-- noteType: constant string "area"
@@ -149,7 +191,7 @@ function noteMt:boxForNoteText(rightSide)
noteWidth = area.noteWidth - 2*noteInnerSep
end
local retval = "\\directlua{tex.box[\"@todonotes@notetextbox\"] = " ..
- "node.copy_list(notesForPage[" .. self.indexOnPage .. "].textbox)}"
+ "node.copy_list(luatodonotes.notesForPage[" .. self.indexOnPage .. "].textbox)}"
retval = retval .. "\\parbox{" .. noteWidth .. "sp}" ..
"{\\raggedright\\unhbox\\@todonotes@notetextbox}"
return retval
@@ -229,10 +271,37 @@ end
+-- divides notes in two lists (for left and right side)
+-- side must be stored in note.rightSide for every note before using this function
+local function segmentNotes(notes)
+ local availableNotesLeft = {}
+ local availableNotesRight = {}
+ for k, v in pairs(notes) do
+ if v.rightSide == true then
+ table.insert(availableNotesRight, k)
+ else
+ table.insert(availableNotesLeft, k)
+ end
+ end
+ return availableNotesLeft, availableNotesRight
+end
+
+
+
-- is called by the sty-file when all settings (algorithms etc.) are made
-function initTodonotes()
+function luatodonotes.initTodonotes()
+ -- fill local variables (defined at begin of file) with package options
+ noteInnerSep = luatodonotes.noteInnerSep
+ noteInterSpace = luatodonotes.noteInterSpace
+ routingAreaWidth = luatodonotes.routingAreaWidth
+ minNoteWidth = luatodonotes.minNoteWidth
+ distanceNotesPageBorder = luatodonotes.distanceNotesPageBorder
+ distanceNotesText = luatodonotes.distanceNotesText
+ rasterHeight = luatodonotes.rasterHeight
+ todonotesDebug = luatodonotes.todonotesDebug
+
if positioning.needLinePositions then
- luatexbase.add_to_callback("post_linebreak_filter", callbackOutputLinePositions, "outputLinePositions")
+ luatexbase.add_to_callback("post_linebreak_filter", luatodonotes.callbackOutputLinePositions, "outputLinePositions")
tex.print("\\@starttoc{lpo}")
tex.print("\\directlua{lpoFileStream = \\the\\tf@lpo}")
end
@@ -240,7 +309,14 @@ end
-- valid values for noteType: nil/"" (for point in text), "area"
-function addNoteToList(index, drawLeader, noteType)
+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.
+ -- This can happen when commands are read multiple times
+ -- => don't add anything to list in this case
+ return
+ end
local newNote = {}
newNote.index = index
newNote.textbox = node.copy_list(tex.box["@todonotes@notetextbox"])
@@ -250,6 +326,7 @@ function addNoteToList(index, drawLeader, noteType)
newNote.backgroundColor = tex.toks["@todonotes@toks@currentbackgroundcolor"]
newNote.borderColor = tex.toks["@todonotes@toks@currentbordercolor"]
newNote.leaderWidth = tex.toks["@todonotes@toks@currentleaderwidth"]
+ newNote.sizeCommand = tex.toks["@todonotes@toks@sizecommand"]
newNote.drawLeader = drawLeader
if noteType == "area" then
newNote.noteType = "area"
@@ -261,13 +338,14 @@ function addNoteToList(index, drawLeader, noteType)
notesForPage[newNote.indexOnPage] = newNote
end
-function clearNotes()
+function luatodonotes.clearNotes()
-- delete the texts for the notes on this page from memory
-- (garbage collection does not work for nodes)
for _, v in pairs(notesForPage) do
node.free(v.textbox)
end
- notesForPage = notesForNextPage
+ luatodonotes.notesForPage = notesForNextPage
+ notesForPage = luatodonotes.notesForPage
-- update indexOnPage for the new notes
for k, v in pairs(notesForPage) do
v.indexOnPage = k
@@ -276,7 +354,7 @@ function clearNotes()
currentPage = currentPage + 1
end
-function processLastLineInTodoArea()
+function luatodonotes.processLastLineInTodoArea()
-- LaTeX counter is accessed as TeX count by prefixing c@
ind = tex.count["c@@todonotes@numberoftodonotes"]
val = tex.count["c@@todonotes@numberofLinesInArea"]
@@ -285,35 +363,19 @@ end
-- *** constructing the linePositions list ***
-function linePositionsNextPage()
+function luatodonotes.linePositionsNextPage()
linePositionsPageNr = linePositionsPageNr + 1
linePositionsCurPage = {}
linePositions[linePositionsPageNr] = linePositionsCurPage
end
-function linePositionsAddLine(ycoord, lineheight, linedepth)
+function luatodonotes.linePositionsAddLine(ycoord, lineheight, linedepth)
local baseline = ycoord - tex.pageheight
linePositionsCurPage[#linePositionsCurPage + 1] = {baseline, baseline + lineheight, baseline - linedepth}
end
--- DEBUG
-function markLines()
- print("marking lines for page " .. currentPage)
- if linePositions[currentPage] ~= nil then
- for _, v in pairs(linePositions[currentPage]) do
- --local yPos = - (tex.pageheight - v[1])
- local yPos = v[3]
- local yTop = v[2]
- tex.print("\\draw[red] (10cm," .. yPos .."sp) circle(3pt);")
- tex.print("\\fill[red] (10cm," .. yPos .."sp) circle(1pt);")
- tex.print("\\draw[green] (2cm," .. yTop .."sp) -- ++(17cm,0);")
- tex.print("\\draw[blue] (2cm," .. yPos .."sp) -- ++(17cm,0);")
- end
- end
-end
-
-function getInputCoordinatesForNotes()
+function luatodonotes.getInputCoordinatesForNotes()
tex.sprint(catcodeStart)
for k, v in ipairs(notesForPage) do
local nodename = "@todonotes@" .. v.index .. " inText"
@@ -322,9 +384,9 @@ function getInputCoordinatesForNotes()
nodename .. "}{center}}")
tex.sprint("\\pgfextracty{\\@todonotes@extracty}{\\pgfpointanchor{" ..
nodename .. "}{center}}")
- tex.print("\\directlua{notesForPage[" .. k .. "].origInputX = " ..
+ tex.print("\\directlua{luatodonotes.notesForPage[" .. k .. "].origInputX = " ..
"tex.dimen[\"@todonotes@extractx\"]}")
- tex.print("\\directlua{notesForPage[" .. k .. "].origInputY = " ..
+ tex.print("\\directlua{luatodonotes.notesForPage[" .. k .. "].origInputY = " ..
"tex.dimen[\"@todonotes@extracty\"]}")
if v.noteType == "area" then
@@ -333,9 +395,9 @@ function getInputCoordinatesForNotes()
nodename .. "}{center}}")
tex.sprint("\\pgfextracty{\\@todonotes@extracty}{\\pgfpointanchor{" ..
nodename .. "}{center}}")
- tex.print("\\directlua{notesForPage[" .. k .. "].origInputEndX = " ..
+ tex.print("\\directlua{luatodonotes.notesForPage[" .. k .. "].origInputEndX = " ..
"tex.dimen[\"@todonotes@extractx\"]}")
- tex.print("\\directlua{notesForPage[" .. k .. "].origInputEndY = " ..
+ tex.print("\\directlua{luatodonotes.notesForPage[" .. k .. "].origInputEndY = " ..
"tex.dimen[\"@todonotes@extracty\"]}")
notesForPage[k].linesInArea = {}
@@ -343,7 +405,7 @@ function getInputCoordinatesForNotes()
nodename = "@todonotes@" .. v.index .. "@" .. i .. " areaSW"
tex.sprint("\\pgfextracty{\\@todonotes@extracty}{\\pgfpointanchor{" ..
nodename .. "}{center}}")
- tex.print("\\directlua{notesForPage[" .. k .. "].linesInArea[" ..
+ tex.print("\\directlua{luatodonotes.notesForPage[" .. k .. "].linesInArea[" ..
i .. "] = " .. "tex.dimen[\"@todonotes@extracty\"]}")
end
end
@@ -351,7 +413,7 @@ function getInputCoordinatesForNotes()
tex.sprint(catcodeEnd)
end
-function calcLabelAreaDimensions()
+function luatodonotes.calcLabelAreaDimensions()
local routingAreaSpace = 0
if leaderType.needRoutingArea then
routingAreaSpace = routingAreaWidth
@@ -394,7 +456,7 @@ function calcLabelAreaDimensions()
labelArea.text = text
end
-function calcHeightsForNotes()
+function luatodonotes.calcHeightsForNotes()
-- function has to be called outside of a tikzpicture-environment
tex.sprint(catcodeStart)
for k, v in ipairs(notesForPage) do
@@ -403,28 +465,28 @@ function calcHeightsForNotes()
-- left side
tex.sprint("\\savebox{\\@todonotes@heightcalcbox}" ..
- "{" .. v:boxForNoteText(false) .. "}")
+ "{" .. v.sizeCommand .. v:boxForNoteText(false) .. "}")
tex.sprint("\\@todonotes@heightcalcboxdepth=\\dp\\@todonotes@heightcalcbox")
tex.sprint("\\@todonotes@heightcalcboxheight=\\ht\\@todonotes@heightcalcbox")
- tex.sprint("\\directlua{notesForPage[" .. k .. "].heightLeft = " ..
+ tex.sprint("\\directlua{luatodonotes.notesForPage[" .. k .. "].heightLeft = " ..
"tex.dimen[\"@todonotes@heightcalcboxheight\"]" ..
" + tex.dimen[\"@todonotes@heightcalcboxdepth\"]}")
-- right side
tex.sprint("\\savebox{\\@todonotes@heightcalcbox}" ..
- "{" .. v:boxForNoteText(true) .. "}")
+ "{" .. v.sizeCommand .. v:boxForNoteText(true) .. "}")
tex.sprint("\\@todonotes@heightcalcboxdepth=\\dp\\@todonotes@heightcalcbox")
tex.sprint("\\@todonotes@heightcalcboxheight=\\ht\\@todonotes@heightcalcbox")
- tex.sprint("\\directlua{notesForPage[" .. k .. "].heightRight = " ..
+ tex.sprint("\\directlua{luatodonotes.notesForPage[" .. k .. "].heightRight = " ..
"tex.dimen[\"@todonotes@heightcalcboxheight\"]" ..
" + tex.dimen[\"@todonotes@heightcalcboxdepth\"]}")
-- store pageNr for note
-- (is determined as reference to a label)
- tex.sprint("\\directlua{notesForPage[" .. k .. "].pageNr = " ..
+ tex.sprint("\\directlua{luatodonotes.notesForPage[" .. k .. "].pageNr = " ..
"\\zref@extract{@todonotes@" .. v.index .. "}{abspage}}")
if v.noteType == "area" then
- tex.sprint("\\directlua{notesForPage[" .. k .. "].pageNrEnd = " ..
+ tex.sprint("\\directlua{luatodonotes.notesForPage[" .. k .. "].pageNrEnd = " ..
"\\zref@extract{@todonotes@" .. v.index .. "@end}{abspage}}")
end
end
@@ -432,7 +494,7 @@ function calcHeightsForNotes()
end
local inputShiftX = string.todimen("-0.05cm") -- sensible value depends on shape of mark
-function printNotes()
+function luatodonotes.printNotes()
print("drawing labels for page " .. currentPage)
-- seperate notes that should be placed on another page
@@ -481,7 +543,7 @@ function printNotes()
if todonotesDebug then
local function outputWithPoints(val)
if val ~= nil then
- return val .. " (" .. number.topoints(val) .. ")"
+ return val .. " (" .. number.topoints(val, "%s%s") .. ")"
else
return ""
end
@@ -521,13 +583,15 @@ function printNotes()
print("backgroundColor:" .. v.backgroundColor)
print("borderColor: " .. v.borderColor)
print("leaderWidth: " .. v.leaderWidth)
+ print("sizeCommand: " .. v.sizeCommand)
print("drawLeader: " .. tostring(v.drawLeader))
end
-- print note
tex.print(catcodeStart)
tex.print("\\node[@todonotes@notestyle,anchor=north west," ..
- "fill=" .. v.backgroundColor .. ",draw=" .. v.borderColor .. "] " ..
+ "fill=" .. v.backgroundColor .. ",draw=" .. v.borderColor .. "," ..
+ "font=" .. v.sizeCommand .. "] " ..
"(@todonotes@" .. v.index ..
" note) at (" .. v.outputX .. "sp," .. v.outputY .. "sp) {" ..
v:boxForNoteText(v.rightSide) .. "};")
@@ -593,25 +657,25 @@ end
-- * comparators for table.sort() *
-- (yields true if first parameter should be placed before second parameter in
-- sorted table)
-function compareNoteInputXAsc(note1, note2)
+local function compareNoteInputXAsc(note1, note2)
if note1.inputX < note2.inputX then
return true
end
end
-function compareNoteIndInputXAsc(key1, key2)
+local function compareNoteIndInputXAsc(key1, key2)
if notesForPage[key1].inputX < notesForPage[key2].inputX then
return true
end
end
-function compareNoteIndInputXDesc(key1, key2)
+local function compareNoteIndInputXDesc(key1, key2)
if notesForPage[key1].inputX > notesForPage[key2].inputX then
return true
end
end
-function compareNoteIndInputYDesc(key1, key2)
+local function compareNoteIndInputYDesc(key1, key2)
local v1 = notesForPage[key1]
local v2 = notesForPage[key2]
if v1.inputY > v2.inputY then
@@ -624,7 +688,7 @@ function compareNoteIndInputYDesc(key1, key2)
end
-- * callbacks for Luatex *
-function appendStrToTokenlist(tokenlist, str)
+local function appendStrToTokenlist(tokenlist, str)
str:gsub(".", function(c)
tokenlist[#tokenlist + 1] = {12, c:byte(), 0}
end)
@@ -633,9 +697,11 @@ end
-- page to the output file (streamId is taken from lpoFileStream) at the
-- beginning of every line
-- should be called as post_linebreak_filter
-function callbackOutputLinePositions(head)
+local ID_GLYPH_NODE = node.id("glyph")
+local ID_HLIST_NODE = node.id("hlist")
+function luatodonotes.callbackOutputLinePositions(head)
while head do
- if head.id == 0 then -- id 0 is a hlist
+ if head.id == ID_HLIST_NODE then
-- check if we are in the main text area (hlists in, e.g.,
-- tikz nodes should have other widths)
if head.width == tex.dimen.textwidth then
@@ -644,7 +710,7 @@ function callbackOutputLinePositions(head)
local foundGlyph = false
local glyphTest = head.head
while glyphTest do
- if glyphTest.id == 37 then -- glyph
+ if glyphTest.id == ID_GLYPH_NODE then
foundGlyph = true
break
end
@@ -709,7 +775,7 @@ end
-- ********** Leader Drawing Algorithms **********
-function drawLeaderPath(note, path)
+local function drawLeaderPath(note, path)
if note.drawLeader == false then
return
end
@@ -725,14 +791,14 @@ function drawLeaderPath(note, path)
",line width=" .. note.leaderWidth .. ",name path=leader] " .. path .. ";")
if note.noteType == "area" then
tex.print("\\path[name path=clipping] " .. clipPath .. ";")
- tex.print("\\fill[@todonotes@leader,name intersections={of=leader and clipping, by=x,sort by=leader}] (x) circle(3pt);")
+ tex.print("\\fill[@todonotes@leader,name intersections={of=leader and clipping, by=x,sort by=leader},fill=" .. note.lineColor .. "] (x) circle(3pt);")
tex.print("\\end{scope}")
end
end
-- ** leader drawing: s-leaders
-function drawSLeaders()
+local function drawSLeaders()
for k, v in ipairs(notesForPage) do
drawLeaderPath(v, v:getLabelAnchorTikz() ..
" -- " .. v:getInTextAnchorTikz())
@@ -743,14 +809,14 @@ leaderTypes["s"] = {algo = drawSLeaders}
-- ** leader drawing: opo-leaders
-function drawOpoLeader(v, opoShift, rightSide)
+local function drawOpoLeader(v, opoShift, rightSide)
if rightSide then
opoShift = - opoShift
end
drawLeaderPath(v, v:getLabelAnchorTikz() .. " -- +(" .. opoShift .. "sp,0) " ..
"|- " .. v:getInTextAnchorTikz())
end
-function drawOpoGroup(group, directionDown, rightSide)
+local function drawOpoGroup(group, directionDown, rightSide)
if directionDown == nil then
for _, v2 in ipairs(group) do
drawOpoLeader(notesForPage[v2], 0, rightSide)
@@ -781,7 +847,7 @@ function drawOpoGroup(group, directionDown, rightSide)
end
end
end
-function drawOpoLeadersSide(notes, rightSide)
+local function drawOpoLeadersSide(notes, rightSide)
table.sort(notes, compareNoteIndInputYDesc)
local lastDirectionDown = nil
@@ -820,7 +886,7 @@ function drawOpoLeadersSide(notes, rightSide)
end
drawOpoGroup(group, lastDirectionDown, rightSide)
end
-function drawOpoLeaders()
+local function drawOpoLeaders()
local notesLeft, notesRight = segmentNotes(notesForPage)
if #notesLeft > 0 then
drawOpoLeadersSide(notesLeft, false)
@@ -835,7 +901,7 @@ leaderTypes["opo"] = {algo = drawOpoLeaders,
-- ** leader drawing: po-leaders
-function drawPoLeaders()
+local function drawPoLeaders()
for _, v in ipairs(notesForPage) do
drawLeaderPath(v, v:getLabelAnchorTikz() .. " -| " .. v:getInTextAnchorTikz())
end
@@ -845,7 +911,7 @@ leaderTypes["po"] = {algo = drawPoLeaders}
-- ** leader drawing: os-leaders
-function drawOsLeaders()
+local function drawOsLeaders()
for _, v in ipairs(notesForPage) do
local cornerX
if v.rightSide then
@@ -873,12 +939,12 @@ leaderTypes["os"] = {algo = drawOsLeaders,
-- forceLimitInc
-- settings for algorithm
-maxIterations = 1000
-factorRepulsiveControlPoint = 1
-factorAttractingControlPoint = 1
-stopCondition = 65536 -- corresponds to 1pt
+local maxIterations = 1000
+local factorRepulsiveControlPoint = 1
+local factorAttractingControlPoint = 1
+local stopCondition = 65536 -- corresponds to 1pt
-function constructCurve(l)
+local function constructCurve(l)
local curve = {}
-- site
@@ -903,60 +969,7 @@ function constructCurve(l)
return curve
end
-function computeRepulsiveControlPointForces()
- for k1, l1 in pairs(notesForPage) do
- for k2, l2 in pairs(notesForPage) do
- if k1 ~= k2 then
- -- curves of the leaders
- local curve1 = constructCurve(l1)
- local curve2 = constructCurve(l2)
-
- local distance = checkCurveApproximation(curve1, curve2);
-
- -- check if R1 has to be increased or decreased to increase the distance of the 2 curves
- -- if curve1 is bent into the direction of curve2, R1 has to be decreased
- local actualR = math.abs(labelArea:getXTextSide(l1.rightSide) - l1.movableControlPointX)
- if ((l1.inputY < l1.leaderArmY and
- l2.leaderArmY < l1.leaderArmY) or
- (l1.inputY > l1.leaderArmY and
- l2.leaderArmY > l1.leaderArmY)) then
- -- R1 has to be increased
- local desiredR = math.abs(labelArea:getXTextSide(l1.rightSide) - l1.optimalPositionX)
- local diff = math.abs(desiredR - actualR)
- if distance == 0 then
- distance = 0.01
- end
- local force = diff / distance
- local newForce = force * factorRepulsiveControlPoint
- l1.currentForce = l1.currentForce + newForce
- l1.forceLimitDec = math.min(l1.forceLimitDec, distance * 0.45)
- else
- -- R1 has to be decreased
- if distance == 0 then
- distance = 0.01
- end
- local force = actualR / distance
- local newForce = -force * factorRepulsiveControlPoint
- l1.currentForce = l1.currentForce + newForce
- local oldLim = l1.forceLimitInc
- l1.forceLimitInc = math.min(l1.forceLimitInc, distance * 0.45)
- --if oldLim ~= l1.forceLimitInc then
- --print(k1 .. ": Reduced forceLimitInc from " .. oldLim .. " to " .. l1.forceLimitInc .. " because of " .. k2 .. " (distance: " .. distance .. ")")
- --end
- end
- end
- end
- end
-end
-function computeAttractingControlPointForces()
- for _, l in pairs(notesForPage) do
- local desiredR = math.abs(labelArea:getXTextSide(l.rightSide) - l.optimalPositionX)
- local actualR = math.abs(labelArea:getXTextSide(l.rightSide) - l.movableControlPointX)
- local newForce = (desiredR - actualR) * factorAttractingControlPoint
- l.currentForce = l.currentForce + newForce
- end
-end
-function getPointOnCurve(t, curve)
+local function getPointOnCurve(t, curve)
if #curve ~= 4 then
error("4 points needed for a Bezier-curve. Given size was: " .. #curve)
end
@@ -973,7 +986,21 @@ function getPointOnCurve(t, curve)
return x, y
end
-function checkCurveApproximation(curve1, curve2)
+local function getDistance(line1, line2)
+ local t1, t2 = pathLine.line_line_intersection(line1.x1, line1.y1, line1.x2, line1.y2,
+ line2.x1, line2.y1, line2.x2, line2.y2)
+ if 0 <= t1 and t1 <= 1 and 0 <= t2 and t2 <= 1 then
+ -- the lines do intersect
+ return 0
+ end
+
+ local d1 = pathLine.hit(line2.x1, line2.y1, line1.x1, line1.y1, line1.x2, line1.y2)
+ local d2 = pathLine.hit(line2.x2, line2.y2, line1.x1, line1.y1, line1.x2, line1.y2)
+ local d3 = pathLine.hit(line1.x1, line1.y1, line2.x1, line2.y1, line2.x2, line2.y2)
+ local d4 = pathLine.hit(line1.x2, line1.y2, line2.x1, line2.y1, line2.x2, line2.y2)
+ return math.sqrt(math.min(d1, d2, d3, d4))
+end
+local function checkCurveApproximation(curve1, curve2)
-- these lists will contain the sections of the approximation of the two curves
local sectionsCurve1 = {}
local sectionsCurve2 = {}
@@ -1025,21 +1052,60 @@ function checkCurveApproximation(curve1, curve2)
return minDistance
end
-function getDistance(line1, line2)
- local t1, t2 = pathLine.line_line_intersection(line1.x1, line1.y1, line1.x2, line1.y2,
- line2.x1, line2.y1, line2.x2, line2.y2)
- if 0 <= t1 and t1 <= 1 and 0 <= t2 and t2 <= 1 then
- -- the lines do intersect
- return 0
- end
+local function computeRepulsiveControlPointForces()
+ for k1, l1 in pairs(notesForPage) do
+ for k2, l2 in pairs(notesForPage) do
+ if k1 ~= k2 then
+ -- curves of the leaders
+ local curve1 = constructCurve(l1)
+ local curve2 = constructCurve(l2)
- local d1 = pathLine.hit(line2.x1, line2.y1, line1.x1, line1.y1, line1.x2, line1.y2)
- local d2 = pathLine.hit(line2.x2, line2.y2, line1.x1, line1.y1, line1.x2, line1.y2)
- local d3 = pathLine.hit(line1.x1, line1.y1, line2.x1, line2.y1, line2.x2, line2.y2)
- local d4 = pathLine.hit(line1.x2, line1.y2, line2.x1, line2.y1, line2.x2, line2.y2)
- return math.sqrt(math.min(d1, d2, d3, d4))
+ local distance = checkCurveApproximation(curve1, curve2);
+
+ -- check if R1 has to be increased or decreased to increase the distance of the 2 curves
+ -- if curve1 is bent into the direction of curve2, R1 has to be decreased
+ local actualR = math.abs(labelArea:getXTextSide(l1.rightSide) - l1.movableControlPointX)
+ if ((l1.inputY < l1.leaderArmY and
+ l2.leaderArmY < l1.leaderArmY) or
+ (l1.inputY > l1.leaderArmY and
+ l2.leaderArmY > l1.leaderArmY)) then
+ -- R1 has to be increased
+ local desiredR = math.abs(labelArea:getXTextSide(l1.rightSide) - l1.optimalPositionX)
+ local diff = math.abs(desiredR - actualR)
+ if distance == 0 then
+ distance = 0.01
+ end
+ local force = diff / distance
+ local newForce = force * factorRepulsiveControlPoint
+ l1.currentForce = l1.currentForce + newForce
+ l1.forceLimitDec = math.min(l1.forceLimitDec, distance * 0.45)
+ else
+ -- R1 has to be decreased
+ if distance == 0 then
+ distance = 0.01
+ end
+ local force = actualR / distance
+ local newForce = -force * factorRepulsiveControlPoint
+ l1.currentForce = l1.currentForce + newForce
+ local oldLim = l1.forceLimitInc
+ l1.forceLimitInc = math.min(l1.forceLimitInc, distance * 0.45)
+ --if oldLim ~= l1.forceLimitInc then
+ --print(k1 .. ": Reduced forceLimitInc from " .. oldLim .. " to " .. l1.forceLimitInc .. " because of " .. k2 .. " (distance: " .. distance .. ")")
+ --end
+ end
+ end
+ end
+ end
end
-function applyForces(v)
+local function computeAttractingControlPointForces()
+ for _, l in pairs(notesForPage) do
+ local desiredR = math.abs(labelArea:getXTextSide(l.rightSide) - l.optimalPositionX)
+ local actualR = math.abs(labelArea:getXTextSide(l.rightSide) - l.movableControlPointX)
+ local newForce = (desiredR - actualR) * factorAttractingControlPoint
+ l.currentForce = l.currentForce + newForce
+ end
+end
+local function applyForces(v)
--print("force on note " .. v.index .. ": " .. v.currentForce .. " (limit: +" .. v.forceLimitInc .. ", -" .. v.forceLimitDec .. ")")
-- limit the force so the movable control point is between the port and the optimal position
@@ -1073,7 +1139,7 @@ function applyForces(v)
v.currentForce = 0
return c
end
-function getAngle(centerX, centerY, x, y)
+local function getAngle(centerX, centerY, x, y)
local vectorX = x - centerX
local vectorY = y - centerY
local length = math.sqrt((vectorX ^ 2) + (vectorY ^ 2))
@@ -1090,7 +1156,7 @@ function getAngle(centerX, centerY, x, y)
return degAngle
end
-function solveQuadraticEquation(a, b, c)
+local function solveQuadraticEquation(a, b, c)
local discr = (b * b) - (4 * a * c)
if discr < 0 then
@@ -1110,7 +1176,7 @@ function solveQuadraticEquation(a, b, c)
return solution1
end
end
-function computeOptimalPosition(v)
+local function computeOptimalPosition(v)
local distance = point.distance(v.inputX, v.inputY, labelArea:getXTextSide(v.rightSide), v.leaderArmY)
-- the angle at the port between the point and the movable control point
@@ -1144,7 +1210,7 @@ function computeOptimalPosition(v)
v.optimalPositionX = labelArea:getXTextSide(v.rightSide) + r
end
end
-function drawSBezierLeaders()
+local function drawSBezierLeaders()
for _, v in pairs(notesForPage) do
-- initialise leader
v.leaderArmY = v:getLabelAnchorY()
@@ -1194,9 +1260,9 @@ function drawSBezierLeaders()
local curve = constructCurve(v)
local unmovableStr = "(" .. curve[2].x .. "sp," .. curve[2].y .. "sp)"
local movableStr = "(" .. curve[3].x .. "sp," .. curve[3].y .. "sp)"
- drawLeaderPath(v, v:getInTextAnchorTikz() .. " .. controls " ..
- unmovableStr .. " and " .. movableStr .. " .. " ..
- v:getLabelAnchorTikz())
+ drawLeaderPath(v, v:getLabelAnchorTikz() .. " .. controls " ..
+ movableStr .. " and " .. unmovableStr .. " .. " ..
+ v:getInTextAnchorTikz())
-- draw control points when requested
if todonotesDebug then
@@ -1220,26 +1286,11 @@ leaderTypes["sBezier"] = {algo = drawSBezierLeaders}
-- ** helper functions
--- divides notes in two lists (for left and right side)
--- side must be stored in note.rightSide for every note before using this function
-function segmentNotes(notes)
- local availableNotesLeft = {}
- local availableNotesRight = {}
- for k, v in pairs(notes) do
- if v.rightSide == true then
- table.insert(availableNotesRight, k)
- else
- table.insert(availableNotesLeft, k)
- end
- end
- return availableNotesLeft, availableNotesRight
-end
-
-- finds the index in the list given as parameter with the minimum angle
-- the function used for computation of the angle is given as second parameter
-- (the alphaFormula gets the note, to which the angle should be computed, as
-- the only parameter)
-function findIndexMinAlpha(availableNotesIndex, alphaFormula)
+local function findIndexMinAlpha(availableNotesIndex, alphaFormula)
local minAlpha = math.huge -- infinity
local minIndex = -1
@@ -1257,7 +1308,7 @@ end
-- ** partition into stacks
-function getMeanYHeight(stack)
+local function getMeanYHeight(stack)
-- TODO: Alternative: nicht das arithmetische Mittel verwenden, sondern
-- Mittelpunkt zwischen dem obersten und untersten Punkt
local sumY = 0
@@ -1278,7 +1329,7 @@ function getMeanYHeight(stack)
end
return meanY, height
end
-function stacksIntersect(stackTop, stackBottom)
+local function stacksIntersect(stackTop, stackBottom)
local topMeanY, topHeight = getMeanYHeight(stackTop)
local topLower = topMeanY - topHeight/2
@@ -1291,7 +1342,7 @@ function stacksIntersect(stackTop, stackBottom)
return false
end
end
-function findStacks(notesOnSide)
+local function findStacks(notesOnSide)
local notes = table.copy(notesOnSide)
table.sort(notes, compareNoteIndInputYDesc)
@@ -1327,7 +1378,7 @@ end
-- ** positioning: inText
-function posInText()
+local function posInText()
-- trivial algorithm
-- places notes in text on position where todo-command was issued
for k, v in ipairs(notesForPage) do
@@ -1342,22 +1393,8 @@ positioningAlgos["inText"] = {algo = posInText,
--- ** positioning: inputOrder
--- start at top and place notes below each other on left/right side
--- notes are placed in the order induced by their y-coordinates
-function posInputOrder(notes, rightSide)
- table.sort(notes, compareNoteIndInputYDesc)
- placeNotesInputOrder(notes, labelArea:getArea(rightSide).top, rightSide)
-end
-positioningAlgos["inputOrder"] = {algo = posInputOrder,
- leaderAnchor = "east",
- leaderShift = false,
- twoSided = true}
-
-
-
-- ** positioning: inputOrderStacks
-function placeNotesInputOrder(stack, yStart, rightSide)
+local function placeNotesInputOrder(stack, yStart, rightSide)
local freeY = yStart
for _, k in ipairs(stack) do
@@ -1367,7 +1404,7 @@ function placeNotesInputOrder(stack, yStart, rightSide)
freeY = freeY - v:getHeight() - 2 * noteInnerSep - noteInterSpace
end
end
-function posInputOrderStacks(notesOnSide, rightSide)
+local function posInputOrderStacks(notesOnSide, rightSide)
table.sort(notesOnSide, compareNoteIndInputYDesc)
local stacks = findStacks(notesOnSide)
@@ -1386,8 +1423,22 @@ positioningAlgos["inputOrderStacks"] = {algo = posInputOrderStacks,
+-- ** positioning: inputOrder
+-- start at top and place notes below each other on left/right side
+-- notes are placed in the order induced by their y-coordinates
+local function posInputOrder(notes, rightSide)
+ table.sort(notes, compareNoteIndInputYDesc)
+ placeNotesInputOrder(notes, labelArea:getArea(rightSide).top, rightSide)
+end
+positioningAlgos["inputOrder"] = {algo = posInputOrder,
+ leaderAnchor = "east",
+ leaderShift = false,
+ twoSided = true}
+
+
+
-- ** positioning: sLeaderNorthEast
-function posSLeaderNorthEast(notes, rightSide)
+local function posSLeaderNorthEast(notes, rightSide)
local noteY = labelArea:getArea(rightSide).top
local alphaFormula
@@ -1423,7 +1474,7 @@ positioningAlgos["sLeaderNorthEast"] = {algo = posSLeaderNorthEast,
-- ** positioning: sLeaderNorthEastBelow
-function placeNotesNorthEastBelow(stack, yStart, rightSide)
+local function placeNotesNorthEastBelow(stack, yStart, rightSide)
-- calculate minimum height of all notes
local minHeight = math.huge -- (infinity)
for _, v in pairs(stack) do
@@ -1462,7 +1513,7 @@ function placeNotesNorthEastBelow(stack, yStart, rightSide)
table.remove(availableNotes, minIndex)
end
end
-function posSLeaderNorthEastBelow(notes, rightSide)
+local function posSLeaderNorthEastBelow(notes, rightSide)
placeNotesNorthEastBelow(notes, labelArea:getArea(rightSide).top, rightSide)
end
positioningAlgos["sLeaderNorthEastBelow"] = {algo = posSLeaderNorthEastBelow,
@@ -1473,7 +1524,7 @@ positioningAlgos["sLeaderNorthEastBelow"] = {algo = posSLeaderNorthEastBelow,
-- ** positioning: sLeaderNorthEastBelowStacks
-function posSLeaderNorthEastBelowStacks(notesOnSide, rightSide)
+local function posSLeaderNorthEastBelowStacks(notesOnSide, rightSide)
local stacks = findStacks(notesOnSide)
-- place stacks
@@ -1491,7 +1542,7 @@ positioningAlgos["sLeaderNorthEastBelowStacks"] = {algo = posSLeaderNorthEastBel
-- ** positioning: sLeaderEast
-function posSLeaderEast(notes, rightSide)
+local function posSLeaderEast(notes, rightSide)
local leaderPosY
local noteY = labelArea:getArea(rightSide).top
@@ -1634,13 +1685,13 @@ positioningAlgos["sLeaderEast"] = {algo = posSLeaderEast,
-- ** positioning: poLeaders
-function getRasterAbsolute(rasterHeight, top, rasterIndex)
+local function getRasterAbsolute(rasterHeight, top, rasterIndex)
return top - (rasterIndex - 1) * rasterHeight
end
-- distance between line and leader that algorithm tries to reach when there is
-- no neighbouring line
local poMinDistLine = string.todimen("4pt")
-function getPosAboveLine(linePositionsCurPage, lineInd)
+local function getPosAboveLine(linePositionsCurPage, lineInd)
local line = linePositionsCurPage[lineInd]
local posAbove
if linePositionsCurPage[lineInd - 1] ~= nil then
@@ -1651,7 +1702,7 @@ function getPosAboveLine(linePositionsCurPage, lineInd)
end
return posAbove
end
-function getPosBelowLine(linePositionsCurPage, lineInd)
+local function getPosBelowLine(linePositionsCurPage, lineInd)
local line = linePositionsCurPage[lineInd]
local posBelow
if linePositionsCurPage[lineInd + 1] ~= nil then
@@ -1662,7 +1713,7 @@ function getPosBelowLine(linePositionsCurPage, lineInd)
end
return posBelow
end
-function posPoLeaders(notes, rightSide, avoidLines)
+local function posPoLeaders(notes, rightSide, avoidLines)
print("rasterHeight: " .. rasterHeight)
local linePositionsCurPage
@@ -1998,8 +2049,8 @@ function posPoLeaders(notes, rightSide, avoidLines)
-- DEBUG on page
if todonotesDebug then
tex.print("\\node[text=blue,fill=white,rectangle,align=center] at (10.5cm,-27cm) {" ..
- "total length: " .. number.tocentimeters(length) .. "\\\\ " ..
- "rasterHeight: " .. number.tocentimeters(rasterHeight) ..
+ "total length: " .. number.tocentimeters(length, "%s%s") .. "\\\\ " ..
+ "rasterHeight: " .. number.tocentimeters(rasterHeight, "%s%s") ..
"};")
end
@@ -2025,7 +2076,7 @@ positioningAlgos["poLeaders"] = {algo = posPoLeaders,
leaderShift = false,
twoSided = true}
-function posPoLeadersAvoid(notes, rightSide)
+local function posPoLeadersAvoid(notes, rightSide)
posPoLeaders(notes, rightSide, true)
end
positioningAlgos["poLeadersAvoidLines"] = {algo = posPoLeadersAvoid,
@@ -2041,7 +2092,7 @@ positioningAlgos["poLeadersAvoidLines"] = {algo = posPoLeadersAvoid,
-- ** splittingAlgorithm: none
-- place all notes on the wider side
-function splitNone()
+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). " ..
@@ -2064,7 +2115,7 @@ splittingAlgos["none"] = {algo = splitNone}
-- ** splittingAlgorithm: middle
-- split on middle of page
-function splitMiddle()
+local function splitMiddle()
if labelArea:isOneSided() then
splitNone()
else
@@ -2084,7 +2135,7 @@ splittingAlgos["middle"] = {algo = splitMiddle}
-- ** splittingAlgorithm: median
-- split at median (sites sorted by x-coordinate)
-function splitMedian()
+local function splitMedian()
if labelArea:isOneSided() then
splitNone()
else
@@ -2122,7 +2173,7 @@ splittingAlgos["median"] = {algo = splitMedian}
-- ** splittingAlgorithm: weightedMedian
-- split at weighted median (sites sorted by x-coordinate)
-- sum of heights of labels on both sides are similiar to each other
-function splitWeightedMedian()
+local function splitWeightedMedian()
if labelArea:isOneSided() then
splitNone()
else
diff --git a/Master/texmf-dist/tex/lualatex/luatodonotes/luatodonotes.sty b/Master/texmf-dist/tex/lualatex/luatodonotes/luatodonotes.sty
index 6f7a193ccce..d300a1ba5ad 100644
--- a/Master/texmf-dist/tex/lualatex/luatodonotes/luatodonotes.sty
+++ b/Master/texmf-dist/tex/lualatex/luatodonotes/luatodonotes.sty
@@ -8,7 +8,7 @@
%%
%% This is a generated file.
%%
-%% Copyright (C) 2014 by Fabian Lipp <fabian.lipp@gmx.de>
+%% Copyright (C) 2014-2015 by Fabian Lipp <fabian.lipp@gmx.de>
%% based on the todonotes package by
%% Henrik Skov Midtiby <henrikmidtiby@gmail.com>
%%
@@ -24,9 +24,15 @@
%%
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{luatodonotes}
- [2014/08/07 v0.1 luatodonotes source and documentation.]
+ [2015/03/13 v0.2 luatodonotes source and documentation.]
-\ProvidesPackage{luatodonotes}[2014/06/08]
+\RequirePackage{ifluatex}
+\ifluatex\else
+ \PackageError{luatodonotes}{LuaTeX is required for this package. Aborting.}{%
+ This package can only be used with the LuaTeX engine\MessageBreak
+ (command `lualatex'). Package loading has been stopped\MessageBreak
+ to prevent additional errors.}
+\fi
\RequirePackage{ifthen}
\RequirePackage{xkeyval}
\RequirePackage{xcolor}
@@ -56,7 +62,7 @@
\newcommand{\@todonotes@interNoteSpace}{5pt}
\newcommand{\@todonotes@noteInnerSep}{5pt}
\newcommand{\@todonotes@routingAreaWidth}{0.4cm}
-\newcommand{\@todonotes@minNoteWidth}{2.0cm}
+\newcommand{\@todonotes@minNoteWidth}{1.0cm}
\newcommand{\@todonotes@distanceNotesPageBorder}{0.5cm}
\newcommand{\@todonotes@distanceNotesText}{0.2cm}
\newcommand{\@todonotes@rasterHeight}{1cm}
@@ -242,62 +248,29 @@
\newdimen\@todonotes@fontsize
\newdimen\@todonotes@currentsidemargin
\directlua{require("luatodonotes")}
-\directlua{noteInnerSep =
+\directlua{luatodonotes.noteInnerSep =
string.todimen("\luatexluaescapestring{\@todonotes@noteInnerSep}")}
-\directlua{noteInterSpace =
+\directlua{luatodonotes.noteInterSpace =
string.todimen("\luatexluaescapestring{\@todonotes@interNoteSpace}")}
-\directlua{routingAreaWidth =
+\directlua{luatodonotes.routingAreaWidth =
string.todimen("\luatexluaescapestring{\@todonotes@routingAreaWidth}")}
-\directlua{minNoteWidth =
+\directlua{luatodonotes.minNoteWidth =
string.todimen("\luatexluaescapestring{\@todonotes@minNoteWidth}")}
-\directlua{distanceNotesPageBorder =
+\directlua{luatodonotes.distanceNotesPageBorder =
string.todimen("\luatexluaescapestring{\@todonotes@distanceNotesPageBorder}")}
-\directlua{distanceNotesText =
+\directlua{luatodonotes.distanceNotesText =
string.todimen("\luatexluaescapestring{\@todonotes@distanceNotesText}")}
-\directlua{rasterHeight =
+\directlua{luatodonotes.rasterHeight =
string.todimen("\luatexluaescapestring{\@todonotes@rasterHeight}")}
-\IfStrEqCase{\@todonotes@positioning}{%
- {inText}{\directlua{positioning = positioningAlgos["inText"]}}%
- {inputOrder}{\directlua{positioning = positioningAlgos["inputOrder"]}}%
- {inputOrderStacks}{\directlua{positioning =
- positioningAlgos["inputOrderStacks"]}}%
- {sLeaderNorthEast}{\directlua{positioning =
- positioningAlgos["sLeaderNorthEast"]}}%
- {sLeaderNorthEastBelow}{\directlua{positioning =
- positioningAlgos["sLeaderNorthEastBelow"]}}%
- {sLeaderEast}{\directlua{positioning =
- positioningAlgos["sLeaderEast"]}}%
- {poLeaders}{\directlua{positioning = positioningAlgos["poLeaders"]}}%
- {poLeadersAvoidLines}{\directlua{positioning =
- positioningAlgos["poLeadersAvoidLines"]}}%
- {sLeaderNorthEastBelowStacks}{\directlua{positioning =
- positioningAlgos["sLeaderNorthEastBelowStacks"]}}}%
- [\directlua{positioning = positioningAlgos["inputOrderStacks"]}
- \PackageWarningNoLine{luatodonotes}
- {Invalid value for parameter positioning: \@todonotes@positioning}]
-\IfStrEqCase{\@todonotes@splitting}{%
- {none}{\directlua{splitting = splittingAlgos["none"]}}%
- {middle}{\directlua{splitting = splittingAlgos["middle"]}}%
- {median}{\directlua{splitting = splittingAlgos["median"]}}%
- {weightedMedian}{\directlua{splitting = splittingAlgos["weightedMedian"]}}}%
- [\directlua{splitting = splittingAlgos["none"]}
- \PackageWarningNoLine{luatodonotes}
- {Invalid value for parameter split: \@todonotes@splitting}]
-\IfStrEqCase{\@todonotes@leadertype}{%
- {s}{\directlua{leaderType = leaderTypes["s"]}}%
- {opo}{\directlua{leaderType = leaderTypes["opo"]}}%
- {po}{\directlua{leaderType = leaderTypes["po"]}}%
- {sBezier}{\directlua{leaderType = leaderTypes["sBezier"]}}%
- {os}{\directlua{leaderType = leaderTypes["os"]}}}%
- [\directlua{leaderType = leaderTypes["opo"]}
- \PackageWarningNoLine{luatodonotes}
- {Invalid value for parameter leadertype: \@todonotes@leadertype}]
+\directlua{luatodonotes.setPositioningAlgo("\luatexluaescapestring{\@todonotes@positioning}")}
+\directlua{luatodonotes.setSplittingAlgo("\luatexluaescapestring{\@todonotes@splitting}")}
+\directlua{luatodonotes.setLeaderType("\luatexluaescapestring{\@todonotes@leadertype}")}
\def\@todonotes@pdflastypos{\the\pdflastypos}
\newcommand{\@todonotes@lineposition}[3]{%
- \directlua{linePositionsAddLine(#1,#2,#3)}%
+ \directlua{luatodonotes.linePositionsAddLine(#1,#2,#3)}%
}
\newcommand{\@todonotes@nextpage}{%
- \directlua{linePositionsNextPage()}%
+ \directlua{luatodonotes.linePositionsNextPage()}%
}%
\newcommand{\@todonotes@writeNextpageToLpo}{%
\ifdefined\tf@lpo%
@@ -305,15 +278,15 @@
\fi
}
\if@todonotes@debugenabled
- \directlua{todonotesDebug = true}
+ \directlua{luatodonotes.todonotesDebug = true}
\newcommand{\@todonotes@AtBeginShipoutUpperLeft}
{\AtBeginShipoutUpperLeftForeground}
\else
- \directlua{todonotesDebug = false}
+ \directlua{luatodonotes.todonotesDebug = false}
\newcommand{\@todonotes@AtBeginShipoutUpperLeft}
{\AtBeginShipoutUpperLeft}
\fi
-\directlua{initTodonotes()}
+\directlua{luatodonotes.initTodonotes()}
\soulregister{\ }{0}
\newlength{\todonotes@textmark@width}
\newlength{\todonotes@textmark@fontsize}
@@ -336,7 +309,7 @@
{% last line of area
\def\todonotes@textmark@decoRight{}%
\addtolength\todonotes@textmark@width{2pt}%
- \directlua{processLastLineInTodoArea()}}%
+ \directlua{luatodonotes.processLastLineInTodoArea()}}%
{\def\todonotes@textmark@decoRight{@todonotes@todoarea}%
\addtolength\todonotes@textmark@width{4pt}}%
\newcommand{\@todonotes@nodeNamePrefix}%
@@ -543,7 +516,13 @@
\edef\@todonotes@tmp{\@todonotes@currentleaderwidth}%
\@todonotes@toks@currentleaderwidth=\expandafter{\@todonotes@tmp}%
\@todonotes@toks@sizecommand=\expandafter{\@todonotes@sizecommand}%
- \savebox\@todonotes@notetextbox{\@todonotes@sizecommand\@todonotes@text}%
+ \savebox\@todonotes@notetextbox{%
+ \@parboxrestore
+ \@marginparreset
+ \@todonotes@sizecommand\@todonotes@text%
+ \@minipagefalse
+ \outer@nobreak
+ }%
\if@todonotes@line%
\def\@todonotes@param@drawLeader{true}%
\else%
@@ -554,7 +533,7 @@
\else%
\def\@todonotes@param@noteType{}%
\fi%
- \directlua{addNoteToList(\arabic{@todonotes@numberoftodonotes},%
+ \directlua{luatodonotes.addNoteToList(\arabic{@todonotes@numberoftodonotes},%
\@todonotes@param@drawLeader,\luastringO{\@todonotes@param@noteType})}%
}%
\newcommand{\@todonotes@addElementToListOfTodos}{%
@@ -612,19 +591,17 @@
\checkoddpage%
\ifoddpageoroneside%
\@todonotes@currentsidemargin=\the\oddsidemargin%
- \directlua{currentPageOdd = true}%
\else%
\@todonotes@currentsidemargin=\the\evensidemargin%
- \directlua{currentPageOdd = false}%
\fi\relax%
\BeginCatcodeRegime\CatcodeTableLaTeX
- \directlua{calcLabelAreaDimensions()}%
- \directlua{calcHeightsForNotes()}% has to be outside of tikzpicture
+ \directlua{luatodonotes.calcLabelAreaDimensions()}%
+ \directlua{luatodonotes.calcHeightsForNotes()}% has to be outside of tikzpicture
\begin{tikzpicture}[remember picture,overlay]
- \directlua{getInputCoordinatesForNotes()}
- \directlua{printNotes()}
+ \directlua{luatodonotes.getInputCoordinatesForNotes()}
+ \directlua{luatodonotes.printNotes()}
\end{tikzpicture}%
- \directlua{clearNotes()}%
+ \directlua{luatodonotes.clearNotes()}%
\EndCatcodeRegime
}%
}