21

Im using the template for moderncv, and i want to remove the dots at the end of the line of \cventry, can someone recode the command for me?

\documentclass[11pt,a4paper,sans]{moderncv}
\moderncvstyle{casual}
\name{John}{Doe}
\begin{document}
\makecvtitle
\section{Education}
\cventry{1990--2015}{Wisdom}{School of life}{Earth}{}{Description}
\end{document}
  • Welcome to TeX.SX! A tip: If you indent lines by 4 spaces or enclose words in backticks `, they'll be marked as code, as can be seen in my edit. You can also highlight the code and click the "code" button (with "{}" on it). – Adam Liter Apr 28 '15 at 19:49
  • 1
    Also, providing some basic code is a good start, but this is not a minimal (non-)working example (MWE) because it doesn't compile. The moderncv class requires some missing arguments in order to compile. Can you please convert the code you have posted in your question into an MWE? It will make it much easier to help you since we can then just copy and paste your code into our editors. – Adam Liter Apr 28 '15 at 19:53
17

In order to change this, you will need to change how \cventry is defined.

\cventry is defined as:

\renewcommand*{\cventry}[7][.25em]{%
  \savebox{\cventryyearbox}{%
    \hspace*{2\separatorcolumnwidth}%
    \hintstyle{#2}}%
  \setlength{\cventrytitleboxwidth}{\widthof{\usebox{\cventryyearbox}}}%
  \setlength{\cventrytitleboxwidth}{\maincolumnwidth-\cventrytitleboxwidth}%
  \begin{minipage}{\maincolumnwidth}%
    \parbox[t]{\cventrytitleboxwidth}{%
      \strut%
      {\bfseries#3}%
      \ifthenelse{\equal{#4}{}}{}{, {\slshape#4}}%
      \ifthenelse{\equal{#5}{}}{}{, #5}%
      \ifthenelse{\equal{#6}{}}{}{, #6}%
      .\strut}%
    \usebox{\cventryyearbox}%
  \end{minipage}%
  \ifx&#7&%
    \else{%
      \newline{}%
      \begin{minipage}[t]{\maincolumnwidth}%
        \small%
        #7%
      \end{minipage}}\fi%
  \par\addvspace{#1}}

You can use the package xpatch to patch this command in the preamble of your document. If you look at the definition above, you will see that the relevant thing to change is the line that says .\strut}%.

xpatch provides the command \xpatchcmd. The syntax for the command is:

\xpatchcmd{⟨command⟩}{⟨search⟩}{⟨replace⟩}{⟨success⟩}{⟨failure⟩}

MWE

\documentclass{moderncv}

\moderncvstyle{casual}
\name{John}{Doe}

\usepackage{xpatch}
\xpatchcmd{\cventry}{.\strut}{\strut}{}{}

\begin{document}
\makecvtitle
\section{Education}
\cventry{1990--2015}{Wisdom}{School of life}{Earth}{}{Description}
\end{document}

enter image description here

  • 2
    Wow! That's a very useful package!! :D – JorgeGT Jun 27 '15 at 20:17
  • How could I remove the comma too? – nilon Feb 25 '17 at 19:03
  • 2
    @nilon Which comma? Depending on which comma you want to remove, the easiest thing to do is probably just to copy the \cventry macro and redefine it in your preamble. See Remove comma from moderncv's \cventry. – Adam Liter Feb 25 '17 at 22:31
2

This also works for me:

\usepackage{xpatch}
\xpatchcmd\cventry{.}{}{}{}
0

As note, starting from the answer of @AdamLiter, you need to consider the \moderncvstyle used. For example, by using \moderncvstyle{casual}, reading inside the file moderncvstylecasual.sty (located in '/texmf-dist/tex/latex/moderncv', considering TeXlive 2019), you will see \moderncvbody{1} that means moderncvbodyi.sty. So, inside this last one, you can take the definition of \cventry, that in this case is:

\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}}

In your tex file preamble you can now copy it, changing .\strut% with \strut%, and I suggest you to give another name to this new command (for example \cventrynofinaldotcasual) to not overwrite the original one but to use this custom \cventry only when you need it, like so:

\newcommand*{\cventrynofinaldotcasual}[7][.25em]{% ROW CHANGED: NOTE '\newcommand', NOT '\renewcommand'!
  \cvitem[#1]{#2}{%
    {\bfseries#3}%
    \ifthenelse{\equal{#4}{}}{}{, {\slshape#4}}%
    \ifthenelse{\equal{#5}{}}{}{, #5}%
    \ifthenelse{\equal{#6}{}}{}{, #6}%
    \strut% ROW CHANGED!
    \ifx&#7&%
    \else{\newline{}\begin{minipage}[t]{\linewidth}\small#7\end{minipage}}\fi}}

Now you can use the new command in the body of your tex file like so:

\cventrynofinaldotcasual[spacing]{years}{degree/job title}{institution/employer}{localization}{optional: grade/...}{optional: comment/job description} % OUTPUT WITHOUT FINAL DOT!

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.