1

I am writing my CV using the moderncv package. I already have adjusted the CV to meet my needs. Therefore I amplified the maximum number of parameters possible in the \cventry command. However, now I have some ugly spacing in case I do NOT use all parameters (see second \cventry in the MWE for illustration): enter image description here Any suggestions to make the spacing collapse in case not all parameters are occupied? As you can see from the MWE I already have adjusted for \ifthenelse command. I use texlive 2014.

\documentclass[11pt,a4paper,sans]{moderncv}
\moderncvstyle{banking}
\moderncvcolor{blue}
\usepackage[scale=0.7]{geometry}
\name{John}{Doe}
\title{Resume title}
\address{street and number}{postcode city}{country}
\phone[mobile]{+1~(234)~567~890}

\renewcommand*{\cventry}[9][.4em]{% 
\begin{tabular*}{\textwidth}{l@{\extracolsep{\fill}}r}% 
\ifthenelse{\equal{\bfseries #4}{}}{}{{\bfseries #4}} & \ifthenelse{\equal{\bfseries #5}{}}{}{{\bfseries #5}} \\%  
\ifthenelse{\equal{\itshape #3}{}}{}{{\itshape #3\ifthenelse{\equal{#6}{}}{}{, #6}}} & \ifthenelse{\equal{\itshape #2}{}}{}{{\itshape #2}}\\% 
\ifthenelse{\equal{#7}{}}{}{{#7}} & \ifthenelse{\equal{#8}{}}{}{\\ {#8} & \\}%
\end{tabular*}% 
}

\begin{document}
\makecvtitle
\section{Education}
\cventry{Grade}{Degree}{Institution}{year--year}{M.Sc.}{Majors}{Majors}{}
\cventry{}{Degree}{Institution}{City}{}{}{}{}
\cventry{year--year}{Degree}{Institution}{City}{Grade}{Majors}{Majors}{}
\end{document}
  • Thanks. I assume you are asking for this: moderncv.cls 2013/04/29 v1.5.1 modern curriculum vitae and letter document class – Phil May 8 '15 at 16:21
  • xparse is quite flexible for this, but when you're putting things in a tabular environment, things become rather inflexible. And then to be doing it in moderncv ... you're now also stuck in an inflexible class. I would consider getting rid of moderncv, and do it yourself in a more agnostic class such as article (or even memoir or one of the KOMA classes). – jon May 8 '15 at 17:21
  • I see your point, however, I would prefer to stick to my current CV. Hopefully, somebody has an idea on my initial problem. – Phil May 8 '15 at 17:35
  • the question is not very clear but \equal{\itshape #3}{} is never going to be true even if #3 is empty as you have \itshape, did you mean to test {#3}{} ? – David Carlisle May 8 '15 at 19:59
  • Has anybody an idea how to solve this problem? – Phil May 21 '15 at 11:27
1

I'm not sure of the layout you want but perhaps this:

\documentclass[11pt,a4paper,sans]{moderncv}
\moderncvstyle{banking}
\moderncvcolor{blue}
\usepackage[scale=0.7]{geometry}
\name{John}{Doe}
\title{Resume title}
\address{street and number}{postcode city}{country}
\phone[mobile]{+1~(234)~567~890}

\renewcommand*{\cventry}[9][.4em]{% 
\begin{tabular*}{\textwidth}{l@{\extracolsep{\fill}}r}% 
\ifthenelse{\equal{#4}{}}{}{\bfseries #4} &
\ifthenelse{\equal{#5}{}}{}{\bfseries #5\\}  
\itshape #3\ifthenelse{\equal{#6}{}}{}{, #6} &
\ifthenelse{\equal{#2}{}}{}{\itshape #2\\}
\ifthenelse{\equal{#7}{}}{}{#7\\}
\ifthenelse{\equal{#8}{}}{}{#8\\}%
\end{tabular*}%
}

\begin{document}
\makecvtitle
\section{Education}
\cventry{Grade}{Degree}{Institution}{year--year}{M.Sc.}{Majors}{Majors}{}
\cventry{}{Degree}{Institution}{City}{}{}{}{}
\cventry{year--year}{Degree}{Institution}{City}{Grade}{Majors}{Majors}{}
\end{document}

tests such as

\equal{\itshape #3}{} 

can never be true so I changed to

\equal{#3}{}

tests such as

\ifthenelse{\equal{#7}{}}{}{{#7}}

says do nothing if #7 is empty, but if #7 is empty, doing it does no harm, also the tabular cell is a group so the extra {} are not needed, so it simplifies to just

#7

however the tests are needed to pull the \\ inside the test so that no line is thrown if both cells in that row are empty.

  • Thanks for your reply and your solution. At a first glance it works perfectly, however, leaving for instance unused parameter 2 (very first bracket) the ugly spacing between different \cventry appears again. Another problem that comes up is that - if you use parameter 7 but not 2 - the former gets traded up to the spot there actually parameter 2 should be located. Obviously, parameter 2 is not use, however, this up-shift is not wanted. I do not see what is the problem in the formula... Any suggestions? – Phil May 9 '15 at 7:31
  • @Phil I'd assumed that you always used them in pairs left and right (otherwise I don't understand the layout at all:-) I'd never use a macro with 9 arguments it makes it so hard to read the source, to know which argument is which, but anyway if you want to say add \\ just if either of #2 or #7 are non empty then the test needs to be \equal{#2#7}{} – David Carlisle May 9 '15 at 8:57
  • Well, I want to use them in pairs left and right, but sometimes one parameter remains unused (usually on the right side). However, I am not sure if I got your advice the right way because my output is still not satisfying me: \renewcommand*{\cventry}[9][.4em]{% \begin{tabular*}{\textwidth}{l@{\extracolsep{\fill}}r}% \ifthenelse{\equal{#4}{}}{}{\bfseries #4} & \ifthenelse{\equal{#5}{}}{}{\bfseries #5\\} \itshape #3\ifthenelse{\equal{#6}{}}{}{, #6} & \ifthenelse{\equal{#2#7}{}}{\\}{\itshape #2\\} \ifthenelse{\equal{#7}{}}{}{#7\\} \ifthenelse{\equal{#8}{}}{}{#8\\}% \end{tabular*}% } – Phil May 9 '15 at 11:22
  • Is my command formatted the right way? at least it does not produce the output I want... – Phil May 10 '15 at 19:34
  • Could you please check my entry: tex.stackexchange.com/questions/245952/… – Phil May 21 '15 at 12:35
0

I have no idea how the source of the ModernCV looks like and how the functions and commands like \cventry are defined, but as a user, you can define any command you need.

You can easily solve your problem by defining new commands which do what you want in your LaTeX code. To remove that white space, I did not know how the existing \cventry code could be improved so that the white space you are not satisfied with could be removed, so I defined a new \cventryother command so that the white space can be adjusted by the writer of the document.

\newcommand{\cventryother}[3]{\textbf{#1}\hfill\textbf{#2}\\\textit{#3}\\[5pt]}

If you need extra white space, just add to the value of [5pt] at the end of the command. In the code bellow you can compare your previous and this newly defined code easily. I drew a green rectangular in the output so that you find which part of the code you should look at to track the changes. (note: I drew this green rectangular shape myself, so you won't see such shape if you run the LaTeX code bellow.)

enter image description here

\documentclass[11pt,a4paper,sans]{moderncv}
\moderncvstyle{banking}
\moderncvcolor{blue}
\usepackage[scale=0.7]{geometry}
\name{John}{Doe}
\title{Resume title}
\address{street and number}{postcode city}{country}
\phone[mobile]{+1~(234)~567~890}

\renewcommand*{\cventry}[9][.4em]{% 
\begin{tabular*}{\textwidth}{l@{\extracolsep{\fill}}r}%
\ifthenelse{\equal{#4}{}}{}{\bfseries #4} & \ifthenelse{\equal{#5}{}}{}        {\bfseries #5\\} \itshape #3\ifthenelse{\equal{#6}{}}{}{, #6} & \ifthenelse{\equal{#2#7}{}}{\\}{\itshape #2\\} \ifthenelse{\equal{#7}{}}{}{#7\\}     \ifthenelse{\equal{#8}{}}{}{#8\\}% 
\end{tabular*}% 
\par\addvspace{#1}%
}

\newcommand{\cventryother}[3]{\textbf{#1}\hfill\textbf{#2}\\\textit{#3}\\[5pt]}

\begin{document}
\makecvtitle
\section{Education}
\cventry{Grade}{Degree}{Institution}{year--year}{M.Sc.}{Majors}{Majors}{}
\cventryother{Institution}{City}{Degree}
\cventry{}{Degree}{Institution}{City}{}{}{}{}
\cventry{year--year}{Degree}{Institution}{City}{Grade}{Majors}{Majors}{}
\end{document}

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.