![我的代码在 MacTeX 2017 和 MacTex 2019 之间有哪些变化?](https://linux22.com/image/402108/%E6%88%91%E7%9A%84%E4%BB%A3%E7%A0%81%E5%9C%A8%20MacTeX%202017%20%E5%92%8C%20MacTex%202019%20%E4%B9%8B%E9%97%B4%E6%9C%89%E5%93%AA%E4%BA%9B%E5%8F%98%E5%8C%96%EF%BC%9F.png)
我已经从 MacTeX 2017 升级到 2019,但遇到了这个问题,我无法解决。考虑一下:
\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}
我确信升级前没有黑色的“小”字样。它应该是待办事项注释的文本大小...
出了什么问题或者发生了哪些变化?
答案1
更新todonotes.sty
引入了回归:代码
\define@key{todonotes.sty}%
{textsize}{\renewcommand{\@todonotes@textsize}{\csname #1\endcsname}}
成为
\define@key{todonotes.sty}%
{textsize}{\renewcommand{\@todonotes@textsize}{#1}}
\define@key{todonotes.sty}%
{size}{\renewcommand{\@todonotes@textsize}{#1}}
这就是“小”出现的原因。
解决方法:
\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}
答案2
该问题是由以下提交引起的: https://github.com/henrikmidtiby/todonotes/commit/f181263dda919c52f23a4b62dae13d571185144f
其中,textsize 命令的存储方式被更改为接受两个不同的值,例如\small
和字符串small
作为 todo 命令中 size 选项的值。
以下面的文档为例
\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}
当应使用字体大小中的值时,现在需要使用\@todonotes@useSizeCommand
。我认为这将解决问题。因此,每次使用时\@todonotes@sizecommand
都应将其替换为\@todonotes@useSizeCommand
。
很抱歉它破坏了您现有的代码,但是在测试更改时我没有想到这个用例。