3

I am modifying the moderncv resume template and I'm running into a compile error when using \textit within a \makecell.

Here is my redefinition of cventry. The error is happening on line 4, within the first \makecell.

\renewcommand{\cventry}[9][a]{
\begin{tabularx}{\linewidth}{X r}
    {\bfseries #4} & {\itshape #2}\\
        \makecell[l]{\textit{#3}\ifthenelse{\equal{#6}{}}{}{, #6}} & \makecell[r]{\itshape #5}\\
    \ifstrequal{#9}{1}{\small#8}
    \ifstrequal{#9}{2}{}{\small#7}
\end{tabularx}
\ifstrequal{#1}{a}{\par\vspace{\gaplength}}{\par\vspace{-4pt}}
}

And I am calling it as follows:

 \cventry{Overall dates}{Position 1, Location 2\\ Position 2, Location 2}{Company}{Position 1 dates \\ Position 2 dates}{}{
    \begin{itemize}
    \item content
    \end{itemize}
}{}{}

I am using \makecell to enable position 1/position 2 and their dates to be in different lines. I want the positions and their dates to be italics. I tried {\itshape position 1 // position 2], however the text on the second line (position 2) did not get italicized with \itshape.

The errors I am getting say "missing }" and "forgotten \endgroup". Any help would be appreciated.

edit: below is the document class definition of cventry.

\newcommand{\cventry}[9]{}
3
  • 2
    Welcome to TeX.SX! Since \cventry is not defined by default, you should complete the question with the document class you're using and a full example showing the issue.
    – egreg
    Sep 18, 2018 at 15:49
  • I'm sorry -- I'm not quite sure what you are looking for when you say the document class. It is using a custom "moderncv" class. Are you looking for the text of the entire .cls file? It is quite lengthy, so I've just included the .cls definition of \cventry in my edit.
    – Keshinko
    Sep 18, 2018 at 15:59
  • egreg is, as far as I know, pointing to: Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with \documentclass{...} and ending with \end{document}.
    – albert
    Sep 18, 2018 at 16:07

1 Answer 1

1

Your definition

\renewcommand{\cventry}[9][a]{
  \begin{tabularx}{\linewidth}{X r}
    {\bfseries #4} & {\itshape #2} \\
    \makecell[l]{\textit{#3}\ifthenelse{\equal{#6}{}}{}{, #6}} &
      \makecell[r]{\itshape #5} \\
    \ifstrequal{#9}{1}{\small#8}
    \ifstrequal{#9}{2}{}{\small#7}
  \end{tabularx}
  \ifstrequal{#1}{a}{\par\vspace{\gaplength}}{\par\vspace{-4pt}}
}

only uses \makecell for arguments #3, #5 and #6. However, with a call like

\cventry
  % #1 is empty and defaults to 'a'
  {Overall dates} % #2
  {Position 1, Location 2 \\ Position 2, Location 2} % #3
  {Company} % #4
  {Position 1 dates \\ Position 2 dates} % #5
  {} % #6
  {% #7
    \begin{itemize}
    \item content
    \end{itemize}
  }
  {} % #8
  {} % #9

your use of argument #3 ends up as (expands to)

\makecell[l]{%
  \textit{Position 1, Location 2 \\ Position 2, Location 2}%
  \ifthenelse{\equal{#6}{}}{}{, #6}%
}

which is not allowed. You can't use \textit{<stuff> \\ <more stuff>}. Instead, use the following definition for \cventry:

\renewcommand{\cventry}[9][a]{%
  \begin{tabularx}{\linewidth}{X r}
    \bfseries #4 & \itshape #2 \\
    \itshape\makecell[l]{#3\ifthenelse{\equal{#6}{}}{}{, #6}} & 
      \itshape\makecell[r]{#5} \\
    \small\ifstrequal{#9}{1}{}{#8}%
          \ifstrequal{#9}{2}{}{#7}
  \end{tabularx}
  \ifstrequal{#1}{a}{\par\vspace{\gaplength}}{\par\vspace{-4pt}}
}

Note how the font switches are placed outside of the \makecell definitions, thereby applying it to every row.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .