我想扩展该version
包以打印一些可选添加的不同颜色的文本。如以下示例所示:
\documentclass{article}
\usepackage{version}
\usepackage{xcolor}
\includeversion{mynote} % Like this it works.
%\excludeversion{mynote} % Like this it doesn't work.
\newenvironment{note}{\begin{mynote}\color{red}}{\end{mynote}}
\begin{document}
Some text. \begin{note}And a note.\end{note} And some more text.
\end{document}
如果我在该\includeversion{mynote}
行中发表评论,它就会起作用:
但如果我切换到该\excludeversion{mynote}
行,我会得到以下信息:
Runaway argument?
! File ended while scanning use of \@Vii@ExcludeToEnd.
<inserted text>
\par
答案1
您的\end{mynote}
不被视为输入流的一部分,因为它隐藏在 中\end{note}
。您可以使用不同的技术并捕获整个note
环境内容,然后将其传递到“干净”(或更可见)的mynote
环境:
\documentclass{article}
\usepackage{version,xcolor,environ}
%\includeversion{mynote} % Like this it works.
\excludeversion{mynote} % Like this it works.
%\newenvironment{note}{\begin{mynote}\color{red}}{\end{mynote}}
\NewEnviron{note}{\begin{mynote}\color{red}\BODY\end{mynote}}
\begin{document}
Some text. \begin{note}And a note.\end{note} And some more text.
\end{document}
environ
允许您捕获里面的环境内容\BODY
。