这个问题的答案可能是“不”,但我只是想确定一下……(此外,我并不想参与整个“goto 是邪恶的”的争论:)
)。
基本上,当前工作流程中让我恼火的事情之一是,当我最终编辑到第 34 页时,发现前 33 页已经有大量图像;因此,如果我在第 34 页遇到某些问题而需要多次文本处理,我必须等待所有 33 页都完成文本处理(这可能需要一段时间),然后才能看到感兴趣的结果。
pdflatex
所以我想,如果 LaTeX(或者说,就我目前而言)支持某种“跳转”或“转到”命令,那将会很棒,我可以像这样使用:
\documentclass{article}
\usepackage{tikz}
% ...
% probably something like this would be needed - pseudo:
\declareGotoMarker{\myjumplabelA}
\begin{document}
% at this point, I'm not interested in the content from
% start to page 33 - so I'm issuing a jump command
% right at the document start:
\JumpGoto{\myjumplabelA}
% here content of skipped pages
% ...
% here is the label, the tex processor
% should jump to, and continue from:
\myjumplabelA
\section{My page 34 section}
Here there is some content that I'm texing:
A test: \problemcommand
...
% here is end of the snippet that I care about texing at the moment;
% don't need a jump here - can just use \stop etc to exit prematurely:
\stop
% here content continues, to end of doc;
% but I won't be seeing it in PDF, as I issued
% \stop just previously:
\section{My page 45 section}
Here some more content, which I'll eventually tex - but not now...
...
\end{document}
好吧,我想代码本身就说明了一切 - 所需的输出将是包含内容的 PDF,对应于原始文档的第 34-44 页。显然,在进行这种“跳跃”缩短的运行时,页码、页面和其他一些(部分、公式等)参考资料将不可用/无法使用,但这不言而喻;这样做的目的或多或少是为了帮助处理大型文档中麻烦的片段,而无需(或尽管如此)将内容分成部分文件,然后有\input
选择地注释行。
世界上有这样的事吗pdflatex
?
答案1
我将加载该comment
包并使用它的comment
环境。
将所有想要排除的代码放在环境内comment
,即\JumpGoto{\myjumplabelA}
用\begin{comment}
和\myjumplabelA
替换\end{comment}
。
平均能量损失
\documentclass{article}
\usepackage{comment}
\usepackage{lipsum} % only for the example
\begin{document}
This is printed.
\begin{comment}
This is not printed
\lipsum[1-15]
\end{comment}
\section{My page 34 section}
Here there is some content that I'm texing:
\end{document}
输出
如果你想打印comment
环境中的内容,只需添加以下行
\includecomment{comment}
答案2
您可以使用verbbox
将不需要的内容塞入逐字框(未排版)。要撤消此操作,请注释掉\begine{verbbox}
和\end{verbbox}
命令。不过,从输出中可以看出,注释掉的注释就像从未存在过一样,包括章节划分等。
\documentclass{article}
\usepackage{verbatimbox}
\usepackage{lipsum}
\begin{document}
\section{First}
\begin{verbbox}
\lipsum[1-12]
\section{Second}
\lipsum[1-5]
\end{verbbox}
\section{Third}
\lipsum[1]
\end{document}
答案3
似乎没人知道这个包ifthen
!例如:
\documentclass{article}
\usepackage{ifthen}
\begin{document}
\newcommand{\optionaltext}{1}%
%or: \newcommand{\optionaltext}{0}%
My mandatory text.
\ifthenelse{\equal{\optionaltext}{1}}{%
Optional line 1.
Optional line 2.
etc.
}{}%
Further mandatory text.
\end{document}
答案4
使用 memmoir 类时,我发现一个非常有用的功能,它比我认为使用 GOTO 所能实现的功能更强大。请参阅下面的 newcomment、commentson 和 commentsoff。
\documentclass{memoir}%
\newcomment{printme} % declaration
\commentson{printme} % no need to do anything with this line
\newcomment{printtoc} % declaration
\commentson{printtoc} % no need to do anything with this line
\begin{document}
\commentsoff{printme} % <----- THIS, COMMENT AND UN-COMMENT
%\commentsoff{printtoc} % <----- THIS, COMMENT AND UN-COMMENT
\begin{printtoc}
\tableofcontents
\end{printtoc}
\begin{printme}
\chapter{Templates Improve Throughput}
Frequently I need the same set of helper commands so I put them in templates below end of document. The pluses and minuses are simply to attract my attention until the final compile. You can have many task-unique print commands. Definitions can be in preamble or main body. These behave decently well with the subfiles package.
\end{printme}
\end{document}
\begin{printme}\let\clearpage\relax --- +++ \\
\end{printme}\par --- +++ \par
\begin{printtoc}\let\clearpage\relax --- +++ \\
\end{printtoc}\par --- +++ \par