[Tex/LaTex] Alignment of CV Reference in ModernCV

horizontal alignmentmoderncvspacing

I'm using the latex template for CV from here CV Template.

For reference, I added these lines

\newcommand{\cvdoublecolumn}[2]{%
  \cvline{}{%
  \begin{minipage}[t]{\listdoubleitemmaincolumnwidth}#1\end{minipage}%
  \hfill%
  \begin{minipage}[t]{\listdoubleitemmaincolumnwidth}#2\end{minipage}%
 }%
}

\newcommand{\cvreference}[7]{%
\textbf{#1}\newline% Name
\ifthenelse{\equal{#2}{}}{}{\addresssymbol~#2\newline}%
\ifthenelse{\equal{#3}{}}{}{#3\newline}%
\ifthenelse{\equal{#4}{}}{}{#4\newline}%
\ifthenelse{\equal{#5}{}}{}{#5\newline}%
\ifthenelse{\equal{#6}{}}{}{\emailsymbol~\texttt{#6}\newline}%
\ifthenelse{\equal{#7}{}}{}{\phonesymbol~#7}}

Everything is fine. To add 2 two references, it works nicely side-by-side. But adding another reference, it comes next line and the alignment breaks and also a new page is created.

Reference Alignments

How can I fix this ?

I have fixed it other way, where I put 3 columns in minipage

\newcommand{\cvdoublecolumn}[3]{%
  \cvline{}{%
  \begin{minipage}[t]{\listdoubleitemmaincolumnwidth}#1\end{minipage}%
  %\hfill%
  \begin{minipage}[t]{\listdoubleitemmaincolumnwidth}#2\end{minipage}%
  %\hfill%
  \begin{minipage}[t]{\listdoubleitemmaincolumnwidth}#3\end{minipage}%
  }%
}

Best Answer

You can provide the necessary definitions for three columns:

\newlength\listtripleitemmaincolumnwidth

\makeatletter
\renewcommand*{\recomputecvlengths}{%
  \setlength{\quotewidth}{0.65\textwidth}%
  \setlength{\maincolumnwidth}{\textwidth-\separatorcolumnwidth-\hintscolumnwidth}%
  \setlength{\listitemmaincolumnwidth}{\maincolumnwidth-\listitemsymbolwidth}%
  \setlength{\doubleitemmaincolumnwidth}{\maincolumnwidth-\hintscolumnwidth-\separatorcolumnwidth-\separatorcolumnwidth}%
  \setlength{\doubleitemmaincolumnwidth}{0.5\doubleitemmaincolumnwidth}%
  \setlength{\listdoubleitemmaincolumnwidth}{\maincolumnwidth-\listitemsymbolwidth-\separatorcolumnwidth-\listitemsymbolwidth}%
  \setlength{\listdoubleitemmaincolumnwidth}{0.5\listdoubleitemmaincolumnwidth}%
  \setlength\listtripleitemmaincolumnwidth{.66\listdoubleitemmaincolumnwidth}%
  \renewcommand{\headwidth}{\textwidth}%
  \setlength{\parskip}{0\p@}%
}
\makeatother

\newcommand{\cvtriplecolumn}[3]{%
  \cvline{}{%
  \begin{minipage}[t]{\listtripleitemmaincolumnwidth}#1\end{minipage}%
  \hfill%
  \begin{minipage}[t]{\listtripleitemmaincolumnwidth}#2\end{minipage}%
  \hfill%
  \begin{minipage}[t]{\listtripleitemmaincolumnwidth}#3\end{minipage}%
 }%
}

A complete example:

\documentclass[11pt,a4paper,sans]{moderncv}
\moderncvstyle{casual}
\moderncvcolor{blue}
\usepackage{lipsum}
\usepackage[scale=0.75]{geometry}

\newlength\listtripleitemmaincolumnwidth

\makeatletter
\renewcommand*{\recomputecvlengths}{%
  \setlength{\quotewidth}{0.65\textwidth}%
  \setlength{\maincolumnwidth}{\textwidth-\separatorcolumnwidth-\hintscolumnwidth}%
  \setlength{\listitemmaincolumnwidth}{\maincolumnwidth-\listitemsymbolwidth}%
  \setlength{\doubleitemmaincolumnwidth}{\maincolumnwidth-\hintscolumnwidth-\separatorcolumnwidth-\separatorcolumnwidth}%
  \setlength{\doubleitemmaincolumnwidth}{0.5\doubleitemmaincolumnwidth}%
  \setlength{\listdoubleitemmaincolumnwidth}{\maincolumnwidth-\listitemsymbolwidth-\separatorcolumnwidth-\listitemsymbolwidth}%
  \setlength{\listdoubleitemmaincolumnwidth}{0.5\listdoubleitemmaincolumnwidth}%
  \setlength\listtripleitemmaincolumnwidth{.66\listdoubleitemmaincolumnwidth}%
  \renewcommand{\headwidth}{\textwidth}%
  \setlength{\parskip}{0\p@}%
}
\makeatother

\newcommand{\cvdoublecolumn}[2]{%
  \cvline{}{%
  \begin{minipage}[t]{\listdoubleitemmaincolumnwidth}#1\end{minipage}%
  \hfill%
  \begin{minipage}[t]{\listdoubleitemmaincolumnwidth}#2\end{minipage}%
 }%
}

\newcommand{\cvtriplecolumn}[3]{%
  \cvline{}{%
  \begin{minipage}[t]{\listtripleitemmaincolumnwidth}#1\end{minipage}%
  \hfill%
  \begin{minipage}[t]{\listtripleitemmaincolumnwidth}#2\end{minipage}%
  \hfill%
  \begin{minipage}[t]{\listtripleitemmaincolumnwidth}#3\end{minipage}%
 }%
}

\newcommand{\cvreference}[7]{%
  \textbf{#1}\newline% Name
  \ifthenelse{\equal{#2}{}}{}{\addresssymbol~#2\newline}%
  \ifthenelse{\equal{#3}{}}{}{#3\newline}%
  \ifthenelse{\equal{#4}{}}{}{#4\newline}%
  \ifthenelse{\equal{#5}{}}{}{#5\newline}%
  \ifthenelse{\equal{#6}{}}{}{\emailsymbol~\texttt{#6}\newline}%
  \ifthenelse{\equal{#7}{}}{}{\phonesymbol~#7}}

\firstname{John}
\familyname{Doe}

\nopagenumbers

\begin{document}

\section{References}

\cvdoublecolumn{\cvreference{A}{B}{C}{D}{E}{F}{G}}{\cvreference{A}{B}{C}{D}{E}{F}{G}}
\cvtriplecolumn{\cvreference{A}{B}{C}{D}{E}{F}{G}}{\cvreference{A}{B}{C}{D}{E}{F}{G}}{\cvreference{A}{B}{C}{D}{E}{F}{G}}

\end{document}

The result:

enter image description here