1

I have a moderncv \cvitem shown as below.

\cvitem{title}{item1, item2, ... , item(n)}

When the item list gets longer, it displays as following:

Title: item1, item2, ... 
item(n-1), item(n)

However, I would like to make it to look as following:

Title: item1, item2, ...
       item(n-1), item(n)

Is there a simple way to do this? I tried to apply some of the hanging indentation solutions, but I could not quite make it work. Any help would be appreciated.

Edit: Adding compilable code below

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

\usepackage[scale=0.75, vmargin=1.0in]{geometry}

\name{first}{last}

\begin{document}

\makecvtitle

\section{Title}

\cvitem{Subtitle}{item-loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong, item1, item2, item3, item4, item5, item6, item7}

\end{document}
  • 1
    Welcome to TeX.SE! Please can you add an short, compilable code showing what you have tried so far? – Mensch Apr 15 '16 at 16:35
  • Ah, okay, I'll try to make and add compilable code. – Yui Apr 15 '16 at 16:38
  • I am sorry for the delayed response. I was working on something else, for a while. – Yui Apr 25 '16 at 17:51
1

Well, class moderncv offers different commands you could use for your list. I added them into the following MWE to show all possibilities.

If you insist in your list inside \cvitem there is some programming needed. Please have a look to the following code:

\makeatletter
\newcommand*{\mycvitem}[3][.25em]{%
  \@initializelength{\mydefwidth}\settowidth{\mydefwidth}{\hintstyle{#2}: }
  \@initializelength{\myitawidth}\setlength{\myitawidth}{\maincolumnwidth-\separatorcolumnwidth-\mydefwidth}
  \ifthenelse{\equal{#2}{}}{}{\hintstyle{#2}: }{\begin{minipage}[t]{\myitawidth}\raggedright #3\end{minipage}}% 
  \par\addvspace{#1}}
\makeatother

Let's say we use \mycvitem{definiens}{definiendum}.

In command \mydefwidth (line 3 above) we calculate the length of the first word definiens (#2) including :. In command \myitawidth (line 4) we calculate the remaining width for your following list, here definiendum (#3). Line 5 is used to print the definiens: followed by a minipage, containing the list definiendum. Line 6 is used to add an space to the next paragraph. If no value is given (an optional value #1) the default value .25em is used. Commands \makeatletter and \makeatother are need to be able to use @ in the code.

Please compile the following MWE:

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

\moderncvstyle{banking} % head3, body3

\makeatletter
\newcommand*{\mycvitem}[3][.25em]{%
  \@initializelength{\mydefwidth}\settowidth{\mydefwidth}{\hintstyle{#2}: }
  \@initializelength{\myitawidth}\setlength{\myitawidth}{\maincolumnwidth-\separatorcolumnwidth-\mydefwidth}
  \ifthenelse{\equal{#2}{}}{}{\hintstyle{#2}: }{\begin{minipage}[t]{\myitawidth}\raggedright #3\end{minipage}}% 
  \par\addvspace{#1}}
\makeatother

\usepackage[%
  scale=0.75, 
  showframe, % <========== just to show the typing area ================
%  vmargin=1.0in
]{geometry}


\name{first}{last}


\begin{document}

\makecvtitle

\section{Title}

\cvitem{Subtitle}{item-loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong, 
  item1, item2, item3, item4, item5, item6, item7}

\mycvitem{Subtitl2}{item-loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong, 
  item1, item2, item3, item4, item5, item6mmmm, item7}

\mycvitem{Subtitl3}{item-loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong, 
  item1mmmmm, item2, item3, item4, item5, item6mmmm, item7llllllllllllllllllllllllllllllllllllllllll m m m m m m m m m m m m }

\mycvitem{Subtitle 4}{item-loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong, 
  item1mmmmmm, item2, item3, item4, item5, item6, item7llllllllllllllllllllllllllllllllllllllllll}

\cvitem{Subtitle}{%
\begin{itemize}
  \item loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong, 
  \item item2, 
  \item item3. 
\end{itemize}%
}

\section{Extra 1}
\cvlistitem{Item 1}
\cvlistitem{Item 2}
\cvlistitem{Item 3. This item is particularly long and therefore normally spans over several lines. Did you notice the indentation when the line wraps?}

\section{Extra 2}
\cvlistdoubleitem{Item 1}{Item 4}
\cvlistdoubleitem{Item 2}{Item 5}
\cvlistdoubleitem{Item 3}{Item 6. Like item 3 in the single column list before, this item is particularly long to wrap over several lines.}

\section{References}
\begin{cvcolumns}
  \cvcolumn{Category 1}{\begin{itemize}\item Person 1\item Person 2\item Person 3\end{itemize}}
  \cvcolumn{Category 2}{Amongst others:\begin{itemize}\item Person 1, and\item Person 2\end{itemize}(more upon request)}
  \cvcolumn[0.5]{All the rest \& some more}{\textit{That} person, and \textbf{those} also (all available upon request).}
\end{cvcolumns}

\end{document}

and see the resulting pdf:

result of new command

You see first your \cvitem and afterwards some examples with the new command \mycvitem. Then you can see in the complete pdf the result of provided commands of class moderncv.

  • I don't understand how the \newcommand block works exactly. However, I get a rough idea from your kind explanation. I added the newcommand to the moderncvheadiii.sty and used the new command \mycvitem to my list. Now, it works beautifully as you demonstrated! Thank you very much!!! – Yui Apr 25 '16 at 17:54

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.