[Tex/LaTex] Moderncv \cventry remove fields

cvmoderncvpdftex

I am writing my own cv using moderncv. In the section "education" I have an entry that does not suit the inputs required by \cventry. Generally, \cventry requires 6 fields, but I only need 4. My problem is that if I insert text only where I need, and leave the curvy brakets I do not need empty, what I get is:

01.2001-02-2002: Name, City, .
Text that briefly describes it.

As you can see, after the label "City" there is a ", " that I don't want. How can I get rid of it? My current \cventry is like this:

 \cventry{Date1-Date2}{Name}{}{City}{\textit{}}{Some text}

I tried to switch "City" to the empty bracket on its right, I get rid of the ", " but my city name turns into italics. On the other hand, if I shift my "City" label to the left, I still get the ", " sign and the city name becomes italics.

Best Answer

Moderncv should account for this, the following is the extract which defines \cventry in the package (moderncvbodyi.sty in http://ctan.org/tex-archive/macros/latex/contrib/moderncv).

\renewcommand*{\cventry}[7][.25em]{%
  \cvitem[#1]{#2}{%
    {\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#7\end{minipage}}\fi}}

\ifthenelse checks whether the fourth, fifth, or sixth elements are empty or not, so as to avoid commas between blank spaces. If there is nothing in a pair of braces it will not insert the comma but if the pair of braces is not empty, it adds the comma and inserts the contents of the braces. Note that this works in your example as no blank comma appears for the {} you use between Name and City.

I believe the problem is that {\textit{}} is not equal to {}, while no print text is defined in the argument the test finds that \textit{} is distinct from nothing. Removing this and using \cventry{Date1-Date2}{Name}{}{City}{}{Some text} should then resolve problems.

To define a short entry (assuming you never use the optional argument), the following should suffice but is probably not worth the hassle

\newcommand{\cventryshort}[4]{\cventry{#1}{#2}{#3}{}{}{#4}}