我已经使用 verbatim 包来注释掉我的 tex 文件的重要部分。
1) 我现在希望在编译时在我的 pdf 文档中看到这些注释...以不同的颜色(比如红色),而不必浏览文档并取消注释所有内容。
2) 我还希望能够仅将注释编译为单独的 pdf……而不必将所有注释复制并粘贴到单独的 tex 文件中。
有没有简单的方法可以实现 1 和 2?谢谢
梅威瑟:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{verbatim}
\begin{document}
minimal example
\begin{comment}
i want this to compile in the pdf, and look red (by typing something in the
preamble of the doc perhaps). (and also be able to switch back to it being a
comment easily).
\end{comment}
\end{document}
答案1
对于 1) 您可以使用下列方法之一将注释放入红色文本或边缘中。
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{verbatim}
\usepackage{xcolor}
\usepackage{environ}% needed only for into the margin
\renewenvironment{comment}{\color{red}}{}% red and in text
\RenewEnviron{comment}{\marginpar{\color{red}\BODY}}% red and in the margin
\begin{document}
minimal example
\begin{comment}
i want this to compile in the pdf, and look red (by typing something in the
preamble of the doc perhaps). (and also be able to switch back to it being a
comment easily).
\end{comment}
\end{document}
对于 2) 一个简单的解决方案是将每个评论写入文件\jobname.comments
。然后您可以使用此文件创建单独的文档。
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{verbatim}
\usepackage{environ}
\RenewEnviron{comment}
{%
\immediate\write\CommentsWrite{\unexpanded\expandafter{\BODY}}%
\immediate\write\CommentsWrite{}%
}
\newwrite\CommentsWrite
\immediate\openout\CommentsWrite=\jobname.comments
\AtEndDocument{\immediate\closeout\CommentsWrite}
\begin{document}
minimal example
\begin{comment}
i want this to compile in the pdf, and look red (by typing something in the
preamble of the doc perhaps). (and also be able to switch back to it being a
comment easily).
\end{comment}
\begin{comment}
A second comment
\end{comment}
\end{document}