我正在使用 xelatex 制作简历。我的简历的某些版本有我的姓名和地址,而其他版本(公开的)没有。有没有一种简单的方法可以在公开版本中隐藏这些信息。截至目前,我只需运行
xelatex file.tex
我真的不想每次都进入并编辑文件。有什么想法吗?
答案1
您可以使用如下模板创建文档(称之为file.tex
):
\documentclass{article}
\newif\ifinclude
\ifdefined\public\else\includetrue\fi
\begin{document}
Here is some content that is always visible.
\ifinclude
Here is some content that depends on a condition.
\fi
Here is some content that is always visible.
\end{document}
这定义了一个条件\ifinclude
,该条件可以为真(\includetrue
)或假(\includefalse
,默认)。此条件的打开/关闭取决于是否\public
定义了宏(使用 e-TeX 原语\ifdefined
)。将文档/简历中的非公开详细信息包装在原语\ifinclude
...\fi
条件中,您可以根据 的存在选择性地包含或不包含此内容\public
,然后在命令行中定义它。例如,
xelatex \def\public{}\input{file.tex}
生产
尽管
xelatex file.tex
生产
因为\public
未定义。