2

I'm making a CV using the moderncv class. For most of the commands, the text is aligned such that it looks to be divided into two columns; one which takes the header, years etc. argument of the commands, and is left-aligned (the text is right-aligned within it), and the other which takes up the remaining width of the page and has the main information in the cvitem, cventry etc. as in the following: Two columns

I want to compress the right column from the right and add in an extra column to the right of that (right-aligned, the text would be left-aligned in the column) something like the following: Three columns (obviously without cutting off the text as in the image).

I couldn't think of a way to do this myself so I tried looking in the moderncv class file to see how it creates the left column (so to speak), and use the same idea to create the right column, but couldn't see where it creates the left column. So I have no idea how to do this!

So I'm wondering is there an easy way to edit the cventry, cvitem etc. commands such that they take an extra argument which is left-aligned in a sort of column which is flushright, and compresses the middle column. I realise I may have made this sound ridiculously complicated but hopefully the images convey what I'm trying to do.

  • Have you had a look at the definition of \cvitem in moderncvstyleclassic.sty? It typesets its arguments in a tabular with two columns. Adding a third amounts to adding a third column to the tabular. – Bordaigorl Jan 3 '14 at 22:30
1

The macros offered by moderncv are designed for a two column layout since \cvitem can distinguish between two arguments (the one for the side column and the one for the main content area). So you need to design your own macros that take three arguments for the contents of the three columns.

It is fairly easy to take the definition of \cvitem in moderncvstyleclassic.sty and adapt it to take 3 arguments and typeset three columns instead of just two: the columns are created using a tabular which can be used to add the third column. In this solution I also create some lengths to allow customisation without changing the definition of the new macro \cvitemthree:

\newlength{\rightcolumnwidth}
\newlength{\leftcolumnwidth}
\setlength{\rightcolumnwidth}{10em}
\setlength{\leftcolumnwidth}{\maincolumnwidth}
\addtolength{\leftcolumnwidth}{-\rightcolumnwidth-\separatorcolumnwidth}

\newcommand*{\cvitemthree}[4][.25em]{%
    \begin{tabular}{@{}p{\hintscolumnwidth}@{\hspace{\separatorcolumnwidth}}p{\leftcolumnwidth}@{\hspace{\separatorcolumnwidth}}p{\rightcolumnwidth}@{}}%
    \raggedleft\hintstyle{#2} &{#3} &{#4}%
  \end{tabular}%
  \par\addvspace{#1}
}

Then \cvitemthree{item}{This is the main text, ...}{date perhaps} would replicate your example image.

  • Thanks for the response. I tried to do something like that after your comment but couldn't quite get there, I have very little experience with newcommands. Anyway, I tried pasting your solution into my code and using the \cvitemthree command but this is what it produced: http://i.stack.imgur.com/25f23.jpg – davly Jan 3 '14 at 23:20
  • Ok, I've almost got it to work, you forgot the \textwidth in \addtolength, which is why it was all bunched together, I think the line should be \addtolength{\leftcolumnwidth}{\textwidth-\rightcolumnwidth-\separatorcolumnwidth}. However, the right column is going into the margin, rather than going onto the next line. – davly Jan 4 '14 at 0:24
  • Got \cvitem to work now, it was going into the margin because the leftcolumnwidth was off, I used \setlength{\leftcolumnwidth}{\maincolumnwidth-\hintscolumnwidth-\separatorcolumnwidth}. Thanks for the help! Now just to apply it to the other commands! – davly Jan 4 '14 at 0:35
  • That's weird, it worked fine for me, maybe we are using different versions of moderncv? If you like my solution please consider accepting it as an answer. – Bordaigorl Jan 4 '14 at 0:48
  • 2013/04/29 v1.5.1? I got it to work anyway, including \cventry. – davly Jan 4 '14 at 0:52

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.