创建没有效果的宏,即使在一行中单独使用

创建没有效果的宏,即使在一行中单独使用

我有一个inlinetodo根据切换按钮定义的宏/命令:

\nottoggle{disableAnnotations}{
    \NewDocumentCommand \inlinetodo {m}{\pdfmarkupcomment[color=yellow]{[TODO: #1]}{}}
}{
    \NewDocumentCommand \inlinetodo {m}{}
}

如您所见,如果启用,该命令不会产生任何效果disableAnnotations。但这并不完全正确。如果我有

This is the first line.
\inlinetodo{Explain the issue here!}
Last line here.

那么“…第一行。”和“最后一行…”之间的空间就会更大。

我怎样才能避免空间,以便结果等于

This is the first line.
Last line here.

如果注释被禁用?

答案1

这取决于你到底想要什么:

\documentclass{article}

\begin{document}

This is the first line. Last line here.

\medskip
\NewDocumentCommand \inlinetodo {m}{}

This is the first line. \inlinetodo{Explain the issue here!} Last line here.

This is the first line. \inlinetodo{Explain the issue here!}Last line here.

This is the first line.\inlinetodo{Explain the issue here!} Last line here.

\medskip
\RenewDocumentCommand \inlinetodo {m}{\ignorespaces}

This is the first line. \inlinetodo{Explain the issue here!} Last line here.

This is the first line. \inlinetodo{Explain the issue here!}Last line here.

This is the first line.\inlinetodo{Explain the issue here!} Last line here.

\medskip
\RenewDocumentCommand \inlinetodo {m}{\unskip}

This is the first line. \inlinetodo{Explain the issue here!} Last line here.

This is the first line. \inlinetodo{Explain the issue here!}Last line here.

This is the first line.\inlinetodo{Explain the issue here!} Last line here.


\medskip
\makeatletter \RenewDocumentCommand \inlinetodo {m}{\@bsphack\@esphack} 
\makeatother 


This is the first line. \inlinetodo{Explain the issue here!} Last line here.

This is the first line. \inlinetodo{Explain the issue here!}Last line here.

This is the first line.\inlinetodo{Explain the issue here!} Last line here.

\end{document} 

在此处输入图片描述

相关内容