1

I'm using the moderncv document type with the classic style and trying to create a new command similar to the \cventry as described here. I'm trying to eliminate the period that shows up at the end and only have year, title, description. I know I can leave unwanted fields blank, but I thought it might be a good lesson to figure this out. I renamed anything that had cventry, but can I reuse anything? I'm trying to define in the preamble as below:

\newcommand*{\cvthing}[4][.25em]{%
    \savebox{\cvthingyearbox}{%
        \hspace*{2\separatorcolumnwidth}%
        \hintstyle{#2}}%
    \setlength{\cvthingtitleboxwidth}{\widthof{\usebox{\cvthingyearbox}}}%
    \setlength{\cvthingtitleboxwidth}{\maincolumnwidth-\cvthingtitleboxwidth}%
    \begin{minipage}{\maincolumnwidth}%
        \parbox[t]{\cvthingtitleboxwidth}{%
            \strut%
            {\bfseries#3}%
            {\strut}%
        \usebox{\cvthingyearbox}%
    \end{minipage}%
    \ifx&#4&%
    \else{%
        \newline{}%
        \begin{minipage}[t]{\maincolumnwidth}%
            \small%
            #4%
    \end{minipage}}\fi%
    \par\addvspace{#1}}

but I get these errors:

File ended while scanning use of \@xargdef.
You have requested package `moderncvheadi', but the package provides `moderncvheadi'.
You have requested package `moderncvbodyi', but the package provides `moderncvbodyi'.

I've been using LaTeX for a few years but haven't tried to change much. If one could please explain what I am doing wrong?

  • 1
    Welcome to TeX.SE! Which style of moderncv do you use? Which version of moderncv do you use? Current is 2.0.0. Please do not post only a code, describe what it should do and/or add an images showing what you want to get ... – Mensch Apr 3 at 1:05
  • Thank you. Yes v2.0.0 the lastest on LinuxMint 19.1, I added a description of what I want. I can add a picture later if it is still unclear. – askrabal Apr 3 at 16:57
  • Also take a look at tex.stackexchange.com/questions/260446/… – user170109 Apr 3 at 19:14
3

In your given code snippet are several issues, some I can correct, some not because you did not told us what you want to archive. I use \cvtest for the following remarks and in the mwe below ...

  • To use a new box you need to initialize it: \@initializebox{\cvtestyearbox}
  • To use a new length you have to define it: \newlength{\cvtesttitleboxwidth}
  • Because we have to use \@initializebox we need to use \makeatletter and \makeatother
  • Some of your brackets are in the wrong position. For example: you can not open an \parbox and close inside it an minipage, opened before the \parbox ...

Update:

Because you gave more informations now, I deleted the code I guessed before. See below the MWE with correct working code.

The main issue here is a missunderstanding, because the code you used was not build for \moderncvstyle{classic}, it was build for \moderncvstyle{casual}.

Therefore the code for \cvtest (see the new name please!):

\makeatletter
\@initializebox{\cvtestyearbox} % <====================================
\newlength{\cvtesttitleboxwidth} % <===================================
\newcommand*{\cvtest}[4][.25em]{%
  \savebox{\cvtestyearbox}{%
    \hspace*{2\separatorcolumnwidth}%
    \hintstyle{#2}}%
  \setlength{\cvtesttitleboxwidth}{\widthof{\usebox{\cvtestyearbox}}}%
  \setlength{\cvtesttitleboxwidth}{\maincolumnwidth-\cvtesttitleboxwidth}%
  \begin{minipage}{\maincolumnwidth}%
    \parbox[t]{\cvtesttitleboxwidth}{%
      \strut%
      {\bfseries#3}%
      \strut}%
    \usebox{\cvtestyearbox}%
  \end{minipage}%
  \ifx&#4&%
    \else{%
      \newline{}%
      \begin{minipage}[t]{\maincolumnwidth}%
        \small%
        #4%
      \end{minipage}}\fi%
  \par\addvspace{#1}}
\makeatother

compiles now, but with the wrong result:

wrong result

To get the \cvthing command usable in style classic you need to start with the definition of cventry in this style:

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

That we can now change to:

%\cvthing{year--year}{title}{description} % <===========================
\newcommand*{\cvthing}[4][.25em]{%
  \cvitem[#1]{#2}{%
    {\bfseries#3}%
    \strut%
    \ifx&#4&%
    \else{\newline{}\begin{minipage}[t]{\linewidth}\small#4\end{minipage}}\fi}}

So at last we get with the following complete code

\documentclass[11pt,a4paper,sans]{moderncv}

% moderncv themes
\moderncvstyle{classic} % casual, classic, banking, oldstyle and fancy
\moderncvcolor{blue} 

\usepackage[utf8]{inputenc}
\usepackage[scale=0.75]{geometry}

%\cvthing{year--year}{title}{description} % <===========================
\newcommand*{\cvthing}[4][.25em]{%
  \cvitem[#1]{#2}{%
    {\bfseries#3}%
    \strut%
    \ifx&#4&%
    \else{\newline{}\begin{minipage}[t]{\linewidth}\small#4\end{minipage}}\fi}}

\makeatletter
\@initializebox{\cvtestyearbox} % <====================================
\newlength{\cvtesttitleboxwidth} % <===================================
%\cvtest{year--year}{title}{description} % <===========================
\newcommand*{\cvtest}[4][.25em]{%
  \savebox{\cvtestyearbox}{%
    \hspace*{2\separatorcolumnwidth}%
    \hintstyle{#2}}%
  \setlength{\cvtesttitleboxwidth}{\widthof{\usebox{\cvtestyearbox}}}%
  \setlength{\cvtesttitleboxwidth}{\maincolumnwidth-\cvtesttitleboxwidth}%
  \begin{minipage}{\maincolumnwidth}%
    \parbox[t]{\cvtesttitleboxwidth}{%
      \strut%
      {\bfseries#3}%
      \strut}%
    \usebox{\cvtestyearbox}%
  \end{minipage}%
  \ifx&#4&%
    \else{%
      \newline{}%
      \begin{minipage}[t]{\maincolumnwidth}%
        \small%
        #4%
      \end{minipage}}\fi%
  \par\addvspace{#1}}
\makeatother


% personal data
\name{John}{Doe}
\title{Resumé title}
\address{street and number}{postcode city}{country}
\phone[mobile]{+1~(234)~567~890}
\phone[fixed]{+2~(345)~678~901}
\phone[fax]{+3~(456)~789~012}
\email{john@doe.org}
\homepage{www.johndoe.com}
\social[linkedin]{john.doe}
\social[twitter]{jdoe}
\social[github]{jdoe}
\extrainfo{additional information}
\photo[64pt][0.4pt]{example-image-a}
\quote{Some quote}

\setlength{\footskip}{66pt}


\begin{document}

\makecvtitle

\section{Education}
\cventry{year--year}{Degree}{Institution--3}{City--4}{\textit{Grade}--5}{Description--6}  % arguments 3 to 6 can be left empty
\cventry{year--year}{Degree}{Institution}{City}{\textit{Grade}}{Description}

\cvthing{year--year}{Degree}{Institution}% <============================

\cvtest{year--year}{Degree}{Institution}% <=============================

\section{Master thesis}
\cvitem{title}{\emph{Title}}
\cvitem{supervisors}{Supervisors}
\cvitem{description}{Short thesis abstract}

\end{document}

the following result (see that \cvtest is not correct for style classic!):

result

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.