設定標誌以使文字在 LaTeX 中可見

設定標誌以使文字在 LaTeX 中可見

我正在撰寫履歷,有些資訊是在某些申請中必須包含的,而在其他申請中則是不必要的。例如,當申請以科學為導向的工作時,我在學位期間學習的模組可能很重要,因此應該包括在內,但對於其他部門來說,它們是無關緊要的。

有沒有一種方法可以在文件頂部設置一個標誌LaTeX,並使用此方法使文字在建立文件時隱藏/取消隱藏在區塊中?

答案1

\newif您可以使用以下命令定義自己的開關:

\documentclass[a4paper,12pt]{article}

\newif\ifimportant

\importanttrue % or \importantfalse
\begin{document}

 some stuff which will always be shown

\ifimportant
 % only shown if \importanttrue is set
 this is some important text
\fi
\end{document}

透過此設置,將顯示重要的內容。當你想隱藏這部分時,你設定\importantfalse而不是\importanttrue

答案2

您也可以使用comment專門為此目的而設計的套件。

\usepackage{comment}
\begin{document}
\begin{comment}
something I might want to include, or maybe not
\end{comment}

然後,你使用序言中的這些開關:

\includecomment{comment} %show comments
\excludecomment{comment} %do not show comments

相關內容