10

In a moderncv document, using an itemize in a cvitem produces extra spacing after the itemized list.

Here's a minimum working example:

\documentclass{moderncv}

\moderncvstyle{casual}
\moderncvcolor{green}

\name{John}{Smith}

\begin{document}
\makecvtitle

\section{List section}
\cvitem{Some category}{
    \begin{itemize}
        \item the first
        \item the second
        \item the third
    \end{itemize}
}
\cvitem{Another category}{
    \begin{itemize}
        \item number one
        \item number two
        \item number three
    \end{itemize}
}
\cvitem{text}{with a description}

More text.

\end{document}

I can add a \vspace{-1em} after each itemize to remove the space, but that seems like fighting the LaTeX rather than embracing it. Is there a setting I can change to remove the extra spacing here?

wchargin
  • 3,139

2 Answers2

13

An option to set the spacing of a cvitem is already provided by the moderncv class:

\documentclass{moderncv}
\moderncvstyle{casual}
\moderncvcolor{green}

\name{John}{Smith}

\begin{document} \makecvtitle

\section{List section} \cvitem[-1.2em]{Some category}{ %new code \begin{itemize} \item the first \item the second \item the third \end{itemize} } \cvitem[-1.2em]{Another category}{ %new code
\begin{itemize} \item number one \item number two \item number three \end{itemize} } \cvitem{text}{with a description}

More text. \end{document}

enter image description here

See the moderncv.cls file:

% makes a resume line with a header and a corresponding text

% usage: \cvitem[spacing]{header}{text}

d-cmst
  • 23,095
  • 1
    Thanks, this looks good, but still seems a bit un-LaTeX-ish, having to provide manual spacing every time (and with a fixed dimension at that): should I define a \newcommand{cvitemnospace}[2]{\cvitem[-1.2em]{#1}{#2}}? And where does the 1.2em come from? Could it depend on any text attributes? Would something like -\baselineskip be better? – wchargin Dec 27 '13 at 21:13
  • @WChargin 1.2em was just a random number to show the option effect. As you can see in the source the default spacing is 0.25em. I think your example of a custom macro is OK, I'd do the same if I had to apply the same custom spacing to many cvitems – d-cmst Dec 27 '13 at 21:55
10

Use a minipage:

\documentclass{moderncv}

\moderncvstyle{casual}
\moderncvcolor{green}

\name{John}{Smith}

\begin{document}
\makecvtitle

\section{List section}
\cvitem{Some category}{%
   \begin{minipage}{\linewidth}
    \begin{itemize}
        \item the first
        \item the second
        \item the third
    \end{itemize}
    \end{minipage}
}
\cvitem{Another category}{%
   \begin{minipage}{\linewidth}
    \begin{itemize}
        \item number one
        \item number two
        \item number three
    \end{itemize}
    \end{minipage}
}
\cvitem{text}{with a description}

More text.

\end{document}

enter image description here

You can also prefer to use [t] position specifier for the minipage:

\documentclass{moderncv}

\moderncvstyle{casual}
\moderncvcolor{green}

\name{John}{Smith}

\begin{document}
\makecvtitle

\section{List section}
\cvitem{Some category}{%
   \begin{minipage}[t]{\linewidth}
    \begin{itemize}
        \item the first
        \item the second
        \item the third
    \end{itemize}
    \end{minipage}
}
\cvitem{Another category}{%
   \begin{minipage}[t]{\linewidth}
    \begin{itemize}
        \item number one
        \item number two
        \item number three
    \end{itemize}
    \end{minipage}
}
\cvitem{text}{with a description}

More text.

\end{document}

enter image description here

  • Thanks, this is better - but there's really no simple option like setitemize{nosepafter}? – wchargin Dec 26 '13 at 02:35
  • 1
    @WChargin This is the simplest option ;-) On the other hand, you may try with enumitem package and try to tweak vertical dimensions. See the manual for enumitem. –  Dec 26 '13 at 02:36