5

I have upgraded from MacTeX 2017 to 2019 and I have this problem that I can\t figure out. Consider:

\documentclass[article,oneside]{memoir}
\usepackage{letltxmacro}
\usepackage{tikz}

\usepackage[textsize=small, linecolor=magenta, bordercolor=magenta,
            backgroundcolor=magenta, textwidth=4cm]{todonotes}

\makeatletter
    \renewcommand{\@todonotes@drawMarginNoteWithLine}{%
    \begin{tikzpicture}[remember picture, overlay, baseline=-0.75ex]%
        \node [coordinate] (inText) {};%
    \end{tikzpicture}%
    \marginpar[{% Draw note in left margin
        \@todonotes@drawMarginNote{r}%
        \@todonotes@drawLineToLeftMargin%
    }]{% Draw note in right margin
        \@todonotes@drawMarginNote{l}%
        \@todonotes@drawLineToRightMargin%
    }%
    }
    \renewcommand{\@todonotes@drawMarginNote}[1]{
        \makebox[\marginparwidth][#1]{\begin{tikzpicture}[remember picture,baseline=(X.base)]%
            \node(X){\vphantom{X}};%
            \draw node[notestyle,font=\@todonotes@sizecommand,anchor=north] (inNote) at (X.north)%
                {\@todonotes@text};%
            \if@todonotes@authorgiven%
                \draw node[notestyle,font=\@todonotes@sizecommand,anchor=north] (inNote) at (X.north)%
                    {\@todonotes@sizecommand\@todonotes@author};%
                \node(Y)[below=of X]{};%
                \draw node[notestyle,font=\@todonotes@sizecommand,anchor=north] (inNote) at (X.south)%
                    {\@todonotes@text};%
            \else%
                \draw node[notestyle,font=\@todonotes@sizecommand,anchor=north] (inNote) at (X.north)%
                    {\@todonotes@text};%
            \fi%
        \end{tikzpicture}%
    }}
\makeatother

\LetLtxMacro{\oldtodo}{\todo}
\renewcommand{\todo}[1]{{\color{magenta}\oldtodo[fancyline]{\color{white}\textsf{#1}}}}

\begin{document}
Lorem \todo{Test} ipsum\ldots

\end{document}

enter image description here

I am sure the text "small" was not there in black before the upgrade. It is supposed to be the text size of the todo comment...

What has gone wrong / changed?

jonalv
  • 11,466

2 Answers2

7

An update to todonotes.sty introduced a regression: the code

\define@key{todonotes.sty}%
    {textsize}{\renewcommand{\@todonotes@textsize}{\csname #1\endcsname}}

became

\define@key{todonotes.sty}%
    {textsize}{\renewcommand{\@todonotes@textsize}{#1}}
\define@key{todonotes.sty}%
    {size}{\renewcommand{\@todonotes@textsize}{#1}}

which is the cause for the appearance of “small”.

Workaround:

\documentclass[article,oneside]{memoir}
\usepackage{letltxmacro}
\usepackage{tikz}

\usepackage[linecolor=magenta, bordercolor=magenta,
            backgroundcolor=magenta, textwidth=4cm]{todonotes}

\makeatletter
\define@key{todonotes.sty}%
    {textsize}{\renewcommand{\@todonotes@textsize}{\csname#1\endcsname}}
\define@key{todonotes.sty}%
    {size}{\renewcommand{\@todonotes@textsize}{\csname#1\endcsname}}
\makeatother
\setkeys{todonotes.sty}{textsize=small}


\makeatletter
    \renewcommand{\@todonotes@drawMarginNoteWithLine}{%
    \begin{tikzpicture}[remember picture, overlay, baseline=-0.75ex]%
        \node [coordinate] (inText) {};%
    \end{tikzpicture}%
    \marginpar[{% Draw note in left margin
        \@todonotes@drawMarginNote{r}%
        \@todonotes@drawLineToLeftMargin%
    }]{% Draw note in right margin
        \@todonotes@drawMarginNote{l}%
        \@todonotes@drawLineToRightMargin%
    }%
    }
    \renewcommand{\@todonotes@drawMarginNote}[1]{%
        \makebox[\marginparwidth][#1]{\begin{tikzpicture}[remember picture,baseline=(X.base)]%
            \node(X){\vphantom{X}};%
            \draw node[notestyle,font=\@todonotes@sizecommand,anchor=north] (inNote) at (X.north)%
                {\@todonotes@text};%
            \if@todonotes@authorgiven%
                \draw node[notestyle,font=\@todonotes@sizecommand,anchor=north] (inNote) at (X.north)%
                    {\@todonotes@sizecommand\@todonotes@author};%
                \node(Y)[below=of X]{};%
                \draw node[notestyle,font=\@todonotes@sizecommand,anchor=north] (inNote) at (X.south)%
                    {\@todonotes@text};%
            \else%
                \draw node[notestyle,font=\@todonotes@sizecommand,anchor=north] (inNote) at (X.north)%
                    {\@todonotes@text};%
            \fi%
        \end{tikzpicture}%
    }}
\makeatother

\LetLtxMacro{\oldtodo}{\todo}
\renewcommand{\todo}[1]{{\color{magenta}\oldtodo[fancyline]{\color{white}\textsf{#1}}}}

\begin{document}
Lorem \todo{Test} ipsum\ldots

\end{document}
egreg
  • 1,121,712
4

The issue was caused by the commit: https://github.com/henrikmidtiby/todonotes/commit/f181263dda919c52f23a4b62dae13d571185144f where the way the textsize command was stored was changed to accept two different values like \small and the string small as values for the size option in the todo command.

As an example take the document below

\documentclass{article}
\usepackage{todonotes}

\begin{document}
This\todo[fancyline]{Test}
is a\todo[fancyline, size=Huge]{Test}
very simple test\todo[fancyline, size=\tiny]{Test}.
\end{document}

When the value in the fontsize should be used, it now required the use of the \@todonotes@useSizeCommand. I assume that will fix the issues. So everytime you have used \@todonotes@sizecommand it should be replaced with \@todonotes@useSizeCommand.

I'm sorry that it has broken your existing code, but I had not imagined that usecase when the change was tested.

midtiby
  • 1,863