根据两个例子这里,的内联形式\todo
经过修改,以允许真正内联待办事项。但是,如果\todo
单独一行,Bad space factor (0).
则会产生错误(有时,请参阅下面的代码)。有没有办法让命令在任一上下文中工作?
\documentclass[12pt]{article}
\usepackage[colorinlistoftodos]{todonotes}
%%%
%%% https://tex.stackexchange.com/questions/329701/todonotes-how-to-make-literally-inline-notes-without-line-breaks
%%%
\makeatletter
\tikzstyle{inlinenotestyle} = [
draw=\@todonotes@currentbordercolor,
fill=\@todonotes@currentbackgroundcolor,
line width=0.5pt,
inner sep = 0.8 ex,
rounded corners=4pt]
\renewcommand{\@todonotes@drawInlineNote}{%
{\begin{tikzpicture}[remember picture,baseline=(current bounding box.base)]%
\draw node[inlinenotestyle,font=\@todonotes@sizecommand, anchor=base,baseline]{%
\if@todonotes@authorgiven%
{\noindent \@todonotes@sizecommand \@todonotes@author:\,\@todonotes@text}%
\else%
{\noindent \@todonotes@sizecommand \@todonotes@text}%
\fi};%
\end{tikzpicture}}}%
\newcommand{\mytodo}[1]{\@todo[inline]{#1}}%
\makeatother
\begin{document}
This is \todo[inline]{fine}.
The following breaks if the line above is commented out.
\todo[inline]{a test}
\end{document}
答案1
您可以使用\leavevmode\todo[inline]{a test}
但它看起来像是 todonotes 中的一个错误\@bsphack
您正在定义\mytodo
(从上一个答案复制)但没有使用它,使用\mytodo
而不是\todo[inline]
也会解决问题,因为它避免了使用\@bsphack
。