[Tex/LaTex] Adding new line in cv entry (moderncv)

moderncv

I'm trying to add a new line inside a cv entry in class moderncv, but when I use \newline the compiler just ignores it:

\item{\cventry{2011--2014}%
       {Extensive additional courses in Physics \newline Quantum Mechanics, Analytical Mechanics, Modern Physics}%
       {B.Sc. in Geophysics}%
       {}{\textit{}}{}%
 } 

The result is:

enter image description here

I want the "Quantum Mechanics .. " to be in a new line

Best Answer

Class moderncv has a fixed definition of command \cventry, for example for style banking

\renewcommand*{\cventry}[7][.25em]{
  \begin{tabular*}{\maincolumnwidth}{l@{\extracolsep{\fill}}r}% <============
    {\bfseries #4} & {\bfseries #5}\\%
    {\itshape #3\ifthenelse{\equal{#6}{}}{}{, #6}} & {\itshape #2}\\%
  \end{tabular*}%
  \ifx&#7&%
  \else{\\%
    \begin{minipage}{\maincolumnwidth}%
      \small#7%
    \end{minipage}}\fi%
  \par\addvspace{#1}}

with the resulting command in the cv:

\cventry[length--1]{year--year--2}{Degree--3}{Institution--4}{City--5}{\textit{Grade}--6}{Description--7}  % arguments 4 to 7 can be left empty

After a look into the definition you can see that you can only place text with more than one line in the minipage, filled with argument #7 (Description). The other parts are realized as tabular, where you can not simply use \newline or \\ to get a new line ...

Therefore you should rewrite your entry to (see the numbers corresponding to #2 etc. in the definition):

  \cventry{2011--2014 2}%
  {Employee 3}%
  {B.Sc. in Geophysics 4}%
  {City, State 5}%
  {6}%
  {Extensive additional courses in Physics  Quantum Mechanics, 
   Analytical Mechanics, Modern Physics 7}%

Based on my answer to a question with \item before cventry the following MWE can solve your problem:

\documentclass[11pt,letterpaper,sans]{moderncv}

\usepackage{enumitem}

\moderncvstyle{banking}
% style options: 'casual' (default), 'classic', 'oldstyle' and 'banking'
\moderncvcolor{blue}

\usepackage{showframe} % <==============================================

\newcommand*{\mycventry}[7][.25em]{
  \begin{tabular*}{\linewidth}{l@{\extracolsep{\fill}}r}% <=============
    {\bfseries #4} & {\bfseries #5}\\%
    {\itshape #3\ifthenelse{\equal{#6}{}}{}{, #6}} & {\itshape #2}\\%
  \end{tabular*}%
  \ifx&#7&%
  \else{\\%
    \begin{minipage}{\linewidth}% \maincolumnwidth <====================
      \small#7%
    \end{minipage}}\fi%
  \par\addvspace{#1}}

% --------------------------------------------
% header details
% --------------------------------------------
\usepackage{import}
\name{John}{Smith}
\address{1234 Main Street}{Chicago, IL}{12345}
\phone[fixed]{+1 (123) 456-7899}
\homepage{https://github.com/john-smith}


\begin{document}
\makecvtitle

\section{Experience}
\begin{itemize}
\item%
  \cventry{2011--2014 2}%
  {Employee 3}%
  {B.Sc. in Geophysics 4}%
  {City, State 5}%
  {6}%
  {Extensive additional courses in Physics  Quantum Mechanics, 
   Analytical Mechanics, Modern Physics 7}%

\item%
  \mycventry{2011--2014 2}%
  {Employee 3}%
  {B.Sc. in Geophysics 4}%
  {City, State 5}%
  {6}%
  {Extensive additional courses in Physics  Quantum Mechanics, 
   Analytical Mechanics, Modern Physics 7}%
\end{itemize}

\end{document}

and the resulting pdf:

resulting pdf