我为简历字段创建了命令。这是所需结果的简化示例:
目前,我必须创建两个单独的命令来执行此操作,一个带有\begin{itemize}
,另一个不带有,否则我会收到错误:
! LaTeX Error: Something's wrong--perhaps a missing \item.
这是因为\begin{itemize}
第二部分中的环境是空的。
\begin{itemize}
问题:是否有允许环境为空的包或使用方法?例如:
\begin{itemize}
% This environment is empty.
\end{itemize}
梅威瑟:
\documentclass[pdftex, 10pt, letterpaper, oneside]{memoir}
\usepackage{color}
\usepackage[table]{xcolor}
\usepackage{enumitem}
\newcommand{\narrowColumn}[0]{0.25\textwidth}
\newcommand{\wideColumn}[0]{0.75\textwidth}
\newcommand{\tabularEndSpacing}[0]{0.375 cm}
% I would like something like this for everything.
\newcommand{\withItemize}[5]{
\begin{tabular}{r | l}
\begin{minipage}[c]{\narrowColumn}
#1
\end{minipage}
&
\begin{minipage}[c]{\wideColumn}
{\bfseries\scshape#2}, {\itshape#3}\\
#4
\begin{itemize}[nosep]
#5
\end{itemize}
\end{minipage}
\end{tabular}\\[\tabularEndSpacing]
}
% However, I am forced to create a second command that does not use itemize.
\newcommand{\withoutItemize}[5]{
\begin{tabular}{r | l}
\begin{minipage}[c]{\narrowColumn}
#1
\end{minipage}
&
\begin{minipage}[c]{\wideColumn}
{\bfseries\scshape#2}, {\itshape#3}\\
#4
#5
\end{minipage}
\end{tabular}\\[\tabularEndSpacing]
}
\begin{document}
\thispagestyle{empty}
% This works fine.
\withItemize{Jun 2013---Present}{Company Name}{Company Location}{Position at Company}{
\item Comment 1
\item Comment 2
\item Comment 3
}
% This does not work.
%\withItemize{Jun 2013---Present}{School Name}{School Location}{Degree}{}
% Using the second command: This works fine.
\withoutItemize{Jun 2013---Present}{School Name}{School Location}{Degree}{}
\end{document}
答案1
测试是否#5
为空。如果是,则不执行任何操作,否则打印itemize
环境。
\newcommand{\myentry}[5]{%
\begin{tabular}{r | l}
\begin{minipage}[c]{\narrowColumn}
#1
\end{minipage}
&
\begin{minipage}[c]{\wideColumn}
\textbf{#2}, \textit{#3}\\
#4
\if\relax\detokenize{#5}\relax\else
\begin{itemize}[nosep]
#5
\end{itemize}
\fi
\end{minipage}
\end{tabular}\\[\tabularEndSpacing]%
}
我已经删除了\scshape
因为字体通常没有粗体小写变体。使用一强调的属性:粗体或小型大写。