6

I'm looking to use moderncv for a resume. Using \cventry (well, using any of the moderncv environments, really) makes all the text justified, but I'd like it to be ragged-right throughout the whole document. Here is an MWE:

\documentclass[12pt,a4paper,sans]{moderncv}
\usepackage{lipsum}

\moderncvtheme[blue]{classic}

\firstname{Some}
\familyname{Dude}
\title{CV}

\begin{document}

\maketitle

\section{Using cventry:}
\cventry{year--year}{THIS IS JUSTIFIED, AS YOU CAN PLAINLY SEE}{THIS IS ALSO JUSTIFIED}{THIS IS JUSTIFIED, TOO}{AND THIS IS JUSTIFIED AS WELL}{I would like all this stuff to be raggedright, however. The "year-year" is not important. }

\end{document}

I have tried editing moderncv.cls and moderncvstyleclassic.sty and have found no way to just change "justified" to "raggedright".

As far as I understand, \cventry uses a tabular environment which gets an array of p passed to it for the alignment of the columns. Changing that p to r freaks out the compiler.

There is the option of using cvline and passing it a \raggedright in the second argument (and doing all the formatting manually), but that seems like a brute-force solution I'd prefer to avoid.

Pretty clueless what to do, appreciate your help!

Edit following David's and Werner's solutions:

Here's an MWE with more content without the solutions.

\documentclass[12pt,a4paper,sans]{moderncv}
\usepackage{lipsum}

\moderncvtheme[blue]{classic}

\firstname{Some}
\familyname{Dude}
\title{CV}

\begin{document}

\maketitle

\section{Using cventry:}

\cventry{year--year}{THIS IS JUSTIFIED, AS YOU CAN PLAINLY SEE}{THIS IS ALSO JUSTIFIED}{THIS IS JUSTIFIED, TOO}{AND THIS IS JUSTIFIED AS WELL}{I would like all this stuff to be raggedright, however. The "year-year" is not important. }

\cventry{year--year}{THIS IS JUSTIFIED, AS YOU CAN PLAINLY SEE}{THIS IS ALSO JUSTIFIED}{THIS IS JUSTIFIED, TOO}{AND THIS IS JUSTIFIED AS WELL}{I would like all this stuff to be raggedright, however. The "year-year" is not important. }

\cventry{year--year}{THIS IS JUSTIFIED, AS YOU CAN PLAINLY SEE}{THIS IS ALSO JUSTIFIED}{THIS IS JUSTIFIED, TOO}{AND THIS IS JUSTIFIED AS WELL}{I would like all this stuff to be raggedright, however. The "year-year" is not important. }

\section{Using cventry:}

\cventry{year--year}{THIS IS JUSTIFIED, AS YOU CAN PLAINLY SEE}{THIS IS ALSO JUSTIFIED}{THIS IS JUSTIFIED, TOO}{AND THIS IS JUSTIFIED AS WELL}{I would like all this stuff to be raggedright, however. The "year-year" is not important. }

\cventry{year--year}{THIS IS JUSTIFIED, AS YOU CAN PLAINLY SEE}{THIS IS ALSO JUSTIFIED}{THIS IS JUSTIFIED, TOO}{AND THIS IS JUSTIFIED AS WELL}{I would like all this stuff to be raggedright, however. The "year-year" is not important. }

\cventry{year--year}{THIS IS JUSTIFIED, AS YOU CAN PLAINLY SEE}{THIS IS ALSO JUSTIFIED}{THIS IS JUSTIFIED, TOO}{AND THIS IS JUSTIFIED AS WELL}{I would like all this stuff to be raggedright, however. The "year-year" is not important. }



\end{document}

Here's a screenshot of the pdf produced by the solutions; sorry for the quality, stitched it quickly together.

As you can see, Werner's solution seems to add some space between the <code>\cventry</code>s (in comparison to the MWE with the standard justification, while David's doesn't. Not sure why.

As you can see, Werner's solution seems to add some space between the \cventrys (in comparison to the MWE with the standard justification, while David's doesn't. Not sure why. If both are used simultaneously, the spaces stay.

So I'm upvoting both solutions, but considering David's as the right answer. Thanks a lot for the quick help!

5

enter image description here

\documentclass[12pt,a4paper,sans]{moderncv}
\usepackage{lipsum}

\moderncvtheme[blue]{classic}

\renewcommand*{\cventry}[7][.25em]{%
  \cvitem[#1]{#2}{\raggedright%
    {\bfseries#3}%
    \ifthenelse{\equal{#4}{}}{}{, {\slshape#4}}%
    \ifthenelse{\equal{#5}{}}{}{, #5}%
    \ifthenelse{\equal{#6}{}}{}{, #6}%
    .\strut\endgraf%
    \ifx&#7&%
      \else{\begin{minipage}[t]{\linewidth}\small\raggedright #7\end{minipage}}\fi}}

\firstname{Some}
\familyname{Dude}
\title{CV}

\begin{document}

\maketitle

\section{Using cventry:}
\cventry{year--year}{THIS IS JUSTIFIED, AS YOU CAN PLAINLY SEE}{THIS IS ALSO JUSTIFIED}{THIS IS JUSTIFIED, TOO}{AND THIS IS JUSTIFIED AS WELL}{I would like all this stuff to be raggedright, however. The "year-year" is not important. }

\end{document}
  • Thank you both for your quick answers! Have checked both solutions with more CV content, David's solution seems to work better - editing post for screenshots. – Zubo Nov 3 '14 at 20:22
  • That with #7 does not seem to work in my case? The \small information below is still justified, isn't it? Moreover: what about the \cvitem-fields? (I know that wasn't part of the original question.) – ClintEastwood Nov 12 '14 at 22:08
  • @ClintEastwood small code in #7 looks raggedright to me looking at the code here and the image? – David Carlisle Nov 12 '14 at 22:20
  • 1
    @ClintEastwood I think I know what you mean (I also removed endgraf), this worked for me for the cventry: \renewcommand*{\cventry}[7][.25em]{% \cvitem[#1]{#2}{\raggedright% {\bfseries#3}% \ifthenelse{\equal{#4}{}}{}{, {\slshape#4}} \ifthenelse{\equal{#5}{}}{}{, #5}% \ifthenelse{\equal{#6}{}}{}{, #6}% .\strut% \ifx&#7&% \else{\newline\begin{minipage}[t]{\linewidth}\small\raggedright #7\end{minipage}}\fi}} – Zubo Nov 22 '14 at 19:56
  • 1
    and this for cvitem: \renewcommand*{\cvitem}[3][.25em]{% \begin{tabular}{@{}p{\hintscolumnwidth}@{\hspace{\separatorcolumnwidth}}p{\maincolumnwidth}@{}}% \raggedright\hintstyle{#2} &\raggedright{#3}% \end{tabular}% \par\addvspace{#1}} – Zubo Nov 22 '14 at 20:00
5

The following is similar to David's answer, with a patch provided by xpatch:

\usepackage{xpatch}
% \xpatchcmd{<cmd>}{<search>}{<replace>}{<success>}{<failure>}
\xpatchcmd{\cvitem}{#3}{\raggedright #3\par}{}{}
\xpatchcmd{\cventry}{\small}{\small\raggedright}{}{}

Place the above content after specifying the \moderncvtheme as classic. The reason for this is because \cvitem and \cventry are defined within the specific theme.

  • Thank you both for your quick answers! Have checked both solutions with more CV content, David's solution seems to work better - editing post for screenshots. – Zubo Nov 3 '14 at 20:42

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.