summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source
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 /Master/texmf-dist/source
parenta3e2c07a7a98d9b5afdd8940333dae4a7e3e6196 (diff)
luatodonotes (5dec15)
git-svn-id: svn://tug.org/texlive/trunk@39019 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source')
-rw-r--r--Master/texmf-dist/source/lualatex/luatodonotes/luatodonotes.dtx234
1 files changed, 203 insertions, 31 deletions
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}