From bb5325dae4202b519b7210a338651301e048998d Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Tue, 18 Feb 2020 03:02:28 +0000 Subject: CTAN sync 202002180302 --- macros/luatex/latex/luatodonotes/luatodonotes.dtx | 82 ++++++++++++++++++---- macros/luatex/latex/luatodonotes/luatodonotes.ins | 4 +- macros/luatex/latex/luatodonotes/luatodonotes.lua | 59 +++++++++++----- macros/luatex/latex/luatodonotes/luatodonotes.pdf | Bin 212809 -> 215081 bytes 4 files changed, 112 insertions(+), 33 deletions(-) (limited to 'macros/luatex') diff --git a/macros/luatex/latex/luatodonotes/luatodonotes.dtx b/macros/luatex/latex/luatodonotes/luatodonotes.dtx index 2351cfbf6c..1d634a6fc8 100644 --- a/macros/luatex/latex/luatodonotes/luatodonotes.dtx +++ b/macros/luatex/latex/luatodonotes/luatodonotes.dtx @@ -1,6 +1,6 @@ % \iffalse meta-comment % -% Copyright (C) 2014-2017 by Fabian Lipp +% Copyright (C) 2014-2020 by Fabian Lipp % based on the todonotes package % by Henrik Skov Midtiby % ------------------------------------------------------------ @@ -24,7 +24,7 @@ %\NeedsTeXFormat{LaTeX2e}[1999/12/01] %\ProvidesPackage{luatodonotes} %<*package> - [2017/09/30 v0.4 luatodonotes source and documentation.] + [2020/02/16 v0.5 luatodonotes source and documentation.] % % %<*driver> @@ -32,7 +32,7 @@ \usepackage{wrapfig} \PassOptionsToPackage{colorlinks, urlcolor=blue}{hyperref} \usepackage{hypdoc} % this package loads hyperref among others -\usepackage[colorinlistoftodos, shadow]{luatodonotes}[2017/09/30] +\usepackage[colorinlistoftodos, shadow]{luatodonotes}[2020/02/16] \usepackage{fontspec} \usepackage{amsmath} \usepackage{setspace} @@ -51,7 +51,7 @@ % % \fi % -% \CheckSum{906} +% \CheckSum{951} % % \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 @@ -742,7 +742,7 @@ % 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 +% 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} @@ -933,6 +933,12 @@ % 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} +% \changes{0.5}{2020/01/19}{Fixed bugs when using \texttt{poLeadersAvoidLines} +% as positioning algorithm in newer LuaTeX versions because some APIs have +% changed} +% \changes{0.5}{2020/01/20}{Bugfix: The line position calculation didn't use +% the current page height, which caused an offset on these positions in +% documents not using a4paper} % \end{environment} % % \subsection{Dependencies and definitions} @@ -1316,6 +1322,11 @@ % \changes{0.3}{2015/12/01}{Introduce package option \texttt{additionalMargin}} % \changes{0.4}{2016/04/01}{Fixed problems of the \texttt{additionalMargin} % option with certain documentclasses} +% \changes{0.5}{2017/11/21}{Make \texttt{additionalMargin} compatible with +% \texttt{\textbackslash newgeometry}} +% \changes{0.5}{2020/01/19}{Adapt to new LuaTeX versions, which provide command +% \texttt{\textbackslash pagewidth} instead of +% \texttt{\textbackslash pdfpagewidth} (but stay backwards compatible)} % \begin{macrocode} \newif{\if@todonotes@additionalMarginEnabled} \@todonotes@additionalMarginEnabledfalse @@ -1363,20 +1374,34 @@ \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} \AfterEndPreamble{% - \setlength{\@todonotes@modpaperwidth}{\paperwidth}% - \addtolength{\@todonotes@modpaperwidth}{\@todonotes@additionalMargin}% - \addtolength{\@todonotes@modpaperwidth}{\@todonotes@additionalMargin}% - \pdfpagewidth=\@todonotes@modpaperwidth% - \addtolength{\hoffset}{\@todonotes@additionalMargin}% + \@todonotes@setAdditionalMargin% +% \end{macrocode} +% Additionally, if the |geometry| package is loaded we hook into +% |\Gm@changelayout| to repeat this computation whenever |\newgeometry| is +% called. +% \begin{macrocode} + \ifdefined\Gm@changelayout + \g@addto@macro{\Gm@changelayout}{\@todonotes@setAdditionalMargin} + \fi }% \fi% % \end{macrocode} +% We simply increase the page size by the doubled value of |additionalMargin| +% and move the contents to the right using |\hoffset|. +% \begin{macrocode} +\newcommand{\@todonotes@setAdditionalMargin}{ + \setlength{\@todonotes@modpaperwidth}{\paperwidth}% + \addtolength{\@todonotes@modpaperwidth}{\@todonotes@additionalMargin}% + \addtolength{\@todonotes@modpaperwidth}{\@todonotes@additionalMargin}% + \ifdefined\pdfpagewidth\else\let\pdfpagewidth\pagewidth\fi + \pdfpagewidth=\@todonotes@modpaperwidth% + \addtolength{\hoffset}{\@todonotes@additionalMargin}% +} +% \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. @@ -1456,6 +1481,7 @@ % We need this workaround because we cannot insert |\pdflastypos| directly into % the tokenlist in the Lua callback \texttt{callbackOutputLinePositions()}. % \begin{macrocode} +\ifdefined\pdflastypos\else\let\pdflastypos\lastypos\fi \def\@todonotes@pdflastypos{\the\pdflastypos} % \end{macrocode} % The following commands are written to the temporary \texttt{lpo}-file. @@ -1493,6 +1519,18 @@ {\AtBeginShipoutUpperLeft} \fi % \end{macrocode} +% Define commands that are used for every tikzpicture to disable +% externalization. +% We only call the |\tikzexternaldisable| command if it is defined (i.e., the +% externalization library for TikZ is loaded). +% Externalization is reenabled after the end of the group (if it was enabled +% before). +% \changes{0.5}{2018/04/08}{Disable TikZ externalization for our tikzpictures} +% \begin{macrocode} +\newcommand{\@todonotes@before@tikzpict}{\begingroup% + \ifdefined\tikzexternaldisable\tikzexternaldisable\fi} +\newcommand{\@todonotes@after@tikzpict}{\endgroup} +% \end{macrocode} % Initialise the script when all Lua variables are set according to the package % options. % \begin{macrocode} @@ -1532,6 +1570,7 @@ {@todonotes@\arabic{@todonotes@numberoftodonotes}% @\arabic{@todonotes@numberofLinesInArea} }% \hspace*{\todonotes@textmark@shift}{\smash{% + \@todonotes@before@tikzpict% \begin{tikzpicture}[overlay,remember picture, deco/.style={}]% \setlength\todonotes@textmark@linebelow% @@ -1560,7 +1599,8 @@ -- (\@todonotes@nodeNamePrefix areaSE) } -- cycle; - \end{tikzpicture}% + \end{tikzpicture}% + \@todonotes@after@tikzpict% }}% }% % \end{macrocode} @@ -1828,10 +1868,12 @@ % Mark the end of the highlighted area with a Tikz coordinate. % The begin is marked by |\@todocommon|. % \begin{macrocode} + \@todonotes@before@tikzpict% \begin{tikzpicture}[remember picture, overlay]% \node [coordinate] (@todonotes@\arabic{@todonotes@numberoftodonotes} % inTextEnd) {};% \end{tikzpicture}% + \@todonotes@after@tikzpict% \zref@label{@todonotes@\arabic{@todonotes@numberoftodonotes}@end}% }% % \end{macrocode} @@ -1846,10 +1888,12 @@ % First is the current location in the document stored, this enables % us later to connect this point with the inserted todonote. % \begin{macrocode} + \@todonotes@before@tikzpict% \begin{tikzpicture}[remember picture, overlay]% \node [coordinate] (@todonotes@\arabic{@todonotes@numberoftodonotes} % inText) {};% \end{tikzpicture}% + \@todonotes@after@tikzpict% % \end{macrocode} % Update the dimensions to be accessed by Lua. % \begin{macrocode} @@ -1937,7 +1981,9 @@ % Define helper function |drawInlineNote|. % \begin{macrocode} \newcommand{\@todonotes@drawInlineNote}{% - {\par\noindent\begin{tikzpicture}[remember picture]% + {\par\noindent% + \@todonotes@before@tikzpict% + \begin{tikzpicture}[remember picture]% \draw node[@todonotes@inlinenote,font=\@todonotes@sizecommand]{% \if@todonotes@authorgiven% {\noindent \@todonotes@sizecommand % @@ -1945,7 +1991,9 @@ \else% {\noindent \@todonotes@sizecommand \@todonotes@text}% \fi};% - \end{tikzpicture}\par}% + \end{tikzpicture}% + \@todonotes@after@tikzpict% + \par}% }% % \end{macrocode} % \end{macro} @@ -1957,6 +2005,7 @@ \addcontentsline{tdo}{todo}{\@todonotes@MissingFigureText: #2}% \par \noindent +\@todonotes@before@tikzpict% \begin{tikzpicture} \draw[fill=\@todonotes@currentfigcolor, draw = black!40, line width=2pt] (-2, -2.5) rectangle +(\@todonotes@currentfigwidth, \@todonotes@currentfigheight); @@ -1967,6 +2016,7 @@ \draw (0, 0.3) node {\@todonotes@MissingFigureUp}; \draw (0, -0.3) node {\@todonotes@MissingFigureDown}; \end{tikzpicture}\hfill +\@todonotes@after@tikzpict% }% Ending \missingfigure command \fi% Ending \@todonotes@ifdisabled % \end{macrocode} @@ -2054,6 +2104,7 @@ % \begin{macrocode} \raisebox{\voffset}{% \hspace{-\hoffset}% + \@todonotes@before@tikzpict% \begin{tikzpicture}[remember picture,overlay] % \end{macrocode} % Reads the absolute coordinates of every note on the page and writes them to @@ -2065,6 +2116,7 @@ % \begin{macrocode} \directlua{luatodonotes.printNotes()} \end{tikzpicture}% + \@todonotes@after@tikzpict% }% % \end{macrocode} % Delete the drawn notes from the Lua lists and prepare for the next page. diff --git a/macros/luatex/latex/luatodonotes/luatodonotes.ins b/macros/luatex/latex/luatodonotes/luatodonotes.ins index 1fc75094df..bfaeb98a7e 100644 --- a/macros/luatex/latex/luatodonotes/luatodonotes.ins +++ b/macros/luatex/latex/luatodonotes/luatodonotes.ins @@ -1,5 +1,5 @@ %% -%% Copyright (C) 2014-2015 by Fabian Lipp +%% Copyright (C) 2014-2020 by Fabian Lipp %% based on the todonotes package by %% Henrik Skov Midtiby %% @@ -23,7 +23,7 @@ This is a generated file. -Copyright (C) 2014-2015 by Fabian Lipp +Copyright (C) 2014-2020 by Fabian Lipp based on the todonotes package by Henrik Skov Midtiby diff --git a/macros/luatex/latex/luatodonotes/luatodonotes.lua b/macros/luatex/latex/luatodonotes/luatodonotes.lua index 5ef9b8f03b..1926597ab9 100644 --- a/macros/luatex/latex/luatodonotes/luatodonotes.lua +++ b/macros/luatex/latex/luatodonotes/luatodonotes.lua @@ -1,5 +1,5 @@ -- --- Copyright (C) 2014-2015 by Fabian Lipp +-- Copyright (C) 2014-2020 by Fabian Lipp -- ------------------------------------------------------------ -- -- This file may be distributed and/or modified under the @@ -374,8 +374,7 @@ function luatodonotes.linePositionsNextPage() end function luatodonotes.linePositionsAddLine(ycoord, lineheight, linedepth) - local baseline = ycoord - tex.pageheight - linePositionsCurPage[#linePositionsCurPage + 1] = {baseline, baseline + lineheight, baseline - linedepth} + linePositionsCurPage[#linePositionsCurPage + 1] = {ycoord, lineheight, linedepth} end @@ -741,7 +740,7 @@ function luatodonotes.callbackOutputLinePositions(head) end if foundGlyph then - local w = node.new("whatsit", "write") -- 8/1 + local w = node.new("whatsit", "write") w.stream = lpoFileStream local tokenlist = { {12, 92, 0}, -- \ @@ -770,19 +769,31 @@ function luatodonotes.callbackOutputLinePositions(head) {12, 110, 0}, -- n {12, 123, 0} -- { } - t = token.create("@todonotes@pdflastypos") - tokenlist[#tokenlist + 1] = t - tokenlist[#tokenlist + 1] = {12, 125, 0} - tokenlist[#tokenlist + 1] = {12, 123, 0} + local t = token.create("@todonotes@pdflastypos") + -- the token handling changed with newer LuaTeX versions + if tex.luatexversion > 81 then + tokenlist[#tokenlist + 1] = {0, t.tok} + else + tokenlist[#tokenlist + 1] = t + end + tokenlist[#tokenlist + 1] = {12, 125, 0} -- } + tokenlist[#tokenlist + 1] = {12, 123, 0} -- { appendStrToTokenlist(tokenlist, tostring(head.height)) - tokenlist[#tokenlist + 1] = {12, 125, 0} - tokenlist[#tokenlist + 1] = {12, 123, 0} + tokenlist[#tokenlist + 1] = {12, 125, 0} -- } + tokenlist[#tokenlist + 1] = {12, 123, 0} -- { appendStrToTokenlist(tokenlist, tostring(head.depth)) - tokenlist[#tokenlist + 1] = {12, 125, 0} + tokenlist[#tokenlist + 1] = {12, 125, 0} -- } w.data = tokenlist head.head = node.insert_before(head.head,head.head,w) - local w = node.new("whatsit", "pdf_save_pos") -- 8/23 + -- the name of the whatsit node changed with newer LuaTeX versions + local whatsitName + if tex.luatexversion > 80 then + whatsitName = "save_pos" + else + whatsitName = "pdf_save_pos" + end + local w = node.new("whatsit", whatsitName) head.head = node.insert_before(head.head,head.head,w) end end @@ -1742,7 +1753,18 @@ end local function posPoLeaders(notes, rightSide, avoidLines) local linePositionsCurPage if avoidLines then - linePositionsCurPage = linePositions[currentPage] or {} + linePositionsCurPage = {} + -- use the current pageheight to convert coordinates: + -- savepos yields coordinates relativ to lower left corner of page, + -- while our tikzpicture is anchored at the upper left corner + for k, v in pairs(linePositions[currentPage] or {}) do + local baseline = v[1] - tex.pageheight + linePositionsCurPage[k] = {baseline, baseline + v[2], baseline - v[3]} + if todonotesDebug then + print("linePositionsAddLine, add: " .. v[1] .. ", pageheight: " .. tex.pageheight .. + ", result: " .. baseline) + end + end end -- number of slots on the whole page @@ -1759,11 +1781,16 @@ local function posPoLeaders(notes, rightSide, avoidLines) -- sort notes by inputY table.sort(notes, compareNoteIndInputYDesc) - -- draw slots + -- draw slots and line positions if todonotesDebug then for i = 1,totalNumSlots+1 do local pos = area.top - (i-1) * rasterHeight - tex.print("\\draw[blue,dashed] (0," .. pos .. "sp) -- +(21cm,0);") + tex.print("\\draw[blue,dashed] (0," .. pos .. "sp) -- +(21cm,0);") + end + for ind, v in pairs(linePositionsCurPage) do + local pos = v[1] + tex.print("\\draw[red,dashed] (0," .. pos .. "sp) -- +(21cm,0);") + tex.print("\\node[red] at (1cm," .. pos .. "sp) {" .. ind .. "};") end end @@ -1870,7 +1897,7 @@ local function posPoLeaders(notes, rightSide, avoidLines) if avoidLines then leaderArmR = labelTopR - noteInnerSep - r:getHeight() / 2 -- east anchor - -- find first line (from the top) which lower bound is below leaderArmR + -- find first line (from the top) whose lower bound is below leaderArmR local lineBelowInd for ind, v in pairs(linePositionsCurPage) do if v[3] <= leaderArmR then diff --git a/macros/luatex/latex/luatodonotes/luatodonotes.pdf b/macros/luatex/latex/luatodonotes/luatodonotes.pdf index 3235a373c2..81bc887aa6 100644 Binary files a/macros/luatex/latex/luatodonotes/luatodonotes.pdf and b/macros/luatex/latex/luatodonotes/luatodonotes.pdf differ -- cgit v1.2.3