假设你写了一篇 25 页的文章。通常你会将文章的简短版本(12 页)提交给会议,然后将完整版本上传到某个地方或作为电子附件附加。
如何最好地管理这两个版本?有两个文件(例如intro_short.tex
和intro_full.tex
)是一个非常糟糕的主意,因为您必须重现更改。首先想到的是用环境包围段落\begin{full_version_only}... \end{full_version_only}
。这听起来很乏味。
有人有更好的建议吗?
谢谢!
答案1
您可以使用布尔变量来告诉 LaTeX 打印哪个版本并进行测试,如下所示:
\documentclass{article}
\usepackage{ifthen}
\newboolean{shortver}
%\setboolean{shortver}{true}% for short version
\setboolean{shortver}{false}% for long version
\begin{document}
\ifthenelse{\boolean{shortver}}{%
\section{Short version}
}{%
\section{Long version}
}
This line will be printed both in short version and in long version.
\ifthenelse{\boolean{shortver}}{%
This line will be printed only in short version
}{%
This line will be printed only in long version
}
\ifthenelse{\boolean{shortver}}{}{%
You can have also paragraphs.
Of course, the short version content is not mandatory.
}
\end{document}
与:
\setboolean{shortver}{true}% for short version
%\setboolean{shortver}{false}% for long version