1

By trying to define a new command in the moderncv package by extending the file moderncv.cls, I have noticed the following:

There is an existing command defined by

\newcommand*{\cvitem}[3][.25em]{}

Now, if I define a command by myself, in the same file, say

\newcommand*{\cvitemtwo}[3][.25em]{}

Then, using it in my CV document, it does not behave the same as the command \cvitem. In fact, I do not even understand why the usage according to the comments,

% makes a resume line with a header and a corresponding text
% usage:\cvitem[spacing]{header}{text}

holds. There must be some additional definition, either in the same file, or in some other file, which specifies the command with the exact name \cvitem. Do you have an idea?

1 Answer 1

1

moderncv defines \cvitem within moderncv.cls but redefines it depending on the style you choose (banking, casual, classic, empty, fancy or oldstyle). This allows for consistent code within the styles (although there are other ways of achieving this) since the macros being redefined will always exist at that point of loading.

Here, for example, is the formal definition of \cvitem as its redefined within moderncvbodyi.sty - the macros that define the "body" when loading casual:

\renewcommand*{\cvitem}[3][.25em]{%
  \begin{tabular}{@{}p{\hintscolumnwidth}@{\hspace{\separatorcolumnwidth}}p{\maincolumnwidth}@{}}%
    \raggedleft\hintstyle{#2} &{#3}%
  \end{tabular}%
  \par\addvspace{#1}}

If you want to make something similar to this one, you'll have to copy it after loading the style (which loads the body formatting macros). You can do this with letltxmacro or \NewCommandCopy (since LaTeX's October 2020 kernel update).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .