# ModernCV: “comment” section of \cvitemwithcomment is going off the page

\documentclass[11pt,a4paper,sans]{moderncv}
\moderncvstyle{oldstyle}                           % style options are 'casual' (default), 'classic', 'oldstyle' and 'banking'
\moderncvcolor{grey}                               % color options 'blue' (default), 'orange', 'green', 'red', 'purple', 'grey' and 'black'
\usepackage[utf8]{inputenc}
\usepackage[scale=0.75]{geometry}

% personal data
\name{John}{Doe}
\title{Resumé title}
\phone[mobile]{+1~(234)~567~890}
\phone[fixed]{+2~(345)~678~901}
\phone[fax]{+3~(456)~789~012}
\email{john@doe.org}
\homepage{www.johndoe.com}

\begin{document}

\makecvtitle

\section{Education}
\cventry{year--year}{Degree}{Institution}{City}{\textit{Grade}}{Description}  % arguments 3 to 6 can be left empty

\section{Master thesis}
\cvitem{title}{\emph{Title}}
\cvitem{supervisors}{Supervisors}
\cvitem{description}{Short thesis abstract}

\section{References}
\cvitemwithcomment{Prof. Xxxxxx Xxxxxxx}{\newline BE project advisor and coauthor}{\hfill \newline xxxxxx.xxxxxxx@xxx.xx}
\cvitemwithcomment{Assoc. Prof. Xxxx Xxxx}{\newline Examiner of BE thesis defence and lecturer}{\hfill \newline xxxx.xxxxxx@xxx.xx}
\cvitemwithcomment{Prof. Xxxxxx Xxx}{\newline Summer research supervisor and lecturer}{\hfill \newline xxxxxx.xxx@xxx.xx}

\end{document}


Using the ModernCV Oldstyle template in ShareLaTeX and as you can see the email address for the associate professor in my references is trailing off the page. How can I get it to be properly aligned with the other two emails? There is not enough space for them all to fit nicely on one line each, hence the \newlines so I would rather split them like the first and third reference. Any and all suggestions welcome, even if they are solving the root problem in a completely different way.

Well, the best seems to me to create a new command, for example \mycvitemwithcomment. Then you can define the length for the main part (name and description) and for the comment part (e-mail).

In the following code you can change the values (in cm) to your needs (see marked lines with <=====):

\newcommand*{\mycvitemwithcomment}[4][.25em]{%
\setlength{\cvitemwithcommentmainlength}{8cm} % <=====================
\setlength{\cvitemwithcommentcommentlength}{3.5cm} % <================
\begin{minipage}[t]{\cvitemwithcommentmainlength}\hintstyle{#2}: #3\end{minipage}%
\hfill% fill of \separatorcolumnwidth
\begin{minipage}[t]{\cvitemwithcommentcommentlength}\raggedleft\small\itshape#4\end{minipage}%


The complete MWE

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

\moderncvstyle{oldstyle}
\moderncvcolor{grey}
\usepackage[utf8]{inputenc}
\usepackage[scale=0.75,showframe]{geometry}

% personal data
\name{John}{Doe}
\title{Resumé title}
\phone[mobile]{+1~(234)~567~890}
\phone[fixed]{+2~(345)~678~901}
\phone[fax]{+3~(456)~789~012}
\email{john@doe.org}
\homepage{www.johndoe.com}

\begin{document}

\makecvtitle

\section{Education}
\cventry{year--year}{Degree}{Institution}{City}{\textit{Grade}}{Description}  % arguments 3 to 6 can be left empty

\section{Master thesis}
\cvitem{title}{\emph{Title}}
\cvitem{supervisors}{Supervisors}
\cvitem{description}{Short thesis abstract}

\newcommand*{\mycvitemwithcomment}[4][.25em]{%
\setlength{\cvitemwithcommentmainlength}{8cm} % <=====================
\setlength{\cvitemwithcommentcommentlength}{3.5cm} % <================
\begin{minipage}[t]{\cvitemwithcommentmainlength}\hintstyle{#2}: #3\end{minipage}%
\hfill% fill of \separatorcolumnwidth
\begin{minipage}[t]{\cvitemwithcommentcommentlength}\raggedleft\small\itshape#4\end{minipage}%

\section{References}
\mycvitemwithcomment{Prof. Xxxxxx Xxxxxxx}{%
\newline BE project advisor and coauthor}{xxxxxx.xxxxxxx@xxx.xx}
\mycvitemwithcomment{Assoc. Prof. Xxxx Xxxx}{%
\newline Examiner of BE thesis defence and lecturer}{xxxx.xxxxxx@xxx.xx}
\mycvitemwithcomment{Prof. Xxxxxx Xxx}{%
\newline Summer research supervisor and lecturer}{\hfill \newline xxxxxx.xxx@xxx.xx}

\end{document}


gives then the following result:

• Done :) Thanks again! – Oisín Moran Apr 23 '19 at 14:49