6

I created commands for resume fields. This is a simplified example of the desired outcome: enter image description here

Currently, I have to create two separate commands to do this, one with \begin{itemize} and the other without, otherwise I get the error:

! LaTeX Error: Something's wrong--perhaps a missing \item.

This is because the \begin{itemize} environment is empty in the second section.

Question: Is there a package or a way of using \begin{itemize} that allows the environment to be empty? For example:

\begin{itemize}
    % This environment is empty.
\end{itemize}

MWE:

\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}
3

Test whether #5 is empty. If it is do nothing, otherwise print an itemize environment.

\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]%
}

I've removed \scshape because fonts normally don't have a boldface small caps variant. Use one attribute for emphasis: either bold face or small caps.

| improve this answer | |
  • Thank you for the quick response. I'll look up \relax, \detokenize and \fi. – JDG Jun 9 '13 at 19:37
  • 1
    @JDG The \if\relax\detokenize{...}\relax sequence of commands is just the safest way for testing whether what's passed (in your case #5) is empty or not. Note that typing { } is different from {} for the test to succeed. – egreg Jun 9 '13 at 19:39
  • Thanks very much. { } vs. {} is a very helpful detail. – JDG Jun 9 '13 at 19:40
  • For what it's worth, I am using {\familydefault}{\sfdefault}, which has a boldface small caps that looks quite nice. – JDG Jun 9 '13 at 20:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.