0

Is there a way to get the \cventry{}{}{}{}{}{} effect in plain LaTeX without the use of the moderncv package?

Is there a \newcommand patch for \cventry which when initialized in any standard TeX file will reproduce this effect of moderncv?

epR8GaYuh
  • 2,432
  • Do you only need \cventry? What is with the \section command etc.? – Mensch Feb 13 '20 at 10:00
  • \section will work even under normal class. So I am not too worried about that. – gradstudent Feb 13 '20 at 16:48
  • It will work in other classes but with an different layout: the leading colored rule is then missing ... Do you really want that? Can you explain better what you want to do with that new command? Can you please add an short compilable tex code what you have tried so far? – Mensch Feb 13 '20 at 21:15
  • I need to copy my CV into a different file which has a completely different document class. There is no simple way to import it unless I can recreate the \cventry in that new file. – gradstudent Feb 13 '20 at 22:25
  • In package koma-moderncvclassic (search for it on CTAN) that is already done. For a simple example please have a look to this question: https://tex.stackexchange.com/q/466746/16550 – Mensch Feb 13 '20 at 22:45
  • So if this package is called then "\cventry" of moderncv class will work? – gradstudent Feb 14 '20 at 01:08
  • Well, have you tried it? Did you saw that command \section is changed too? Why do you not simply use pdfpages to include your cv into the other document? – Mensch Feb 14 '20 at 10:07
  • 1
    Do you have any news for us? – Mensch Feb 21 '20 at 10:28
  • Thanks for asking! So it seems that doing \usepackage{koma-moderncvclassic} is not only making the CV section of the file compile like "moderncvclassic" but it is also affecting the \section, \subsection, \chapter title looks and fonts everywhere else! This is clearly not the wanted scenrio - I need the \cventry to work only in the CV section of the file. – gradstudent Feb 23 '20 at 22:13
  • Please see my added answer! If you like my answer and it was helpful, please consider upvoting (by clicking on the arrows next to the score) and/or marking it as the accepted answer (by clicking on the checkmark ✓). – Mensch Mar 02 '20 at 12:24

1 Answers1

2

Well, you can do this by your own with a little bit try and error like this:

  1. Copy the definition of command \cventry into your other class in the preamble and use command \cventry in the document.
  2. Compile and see the resulting error: command \cvitem is undefined.
  3. Copy the definition of command \cvitem into the preamble. Do not forget to add the needed packages (calc, xcolor and ifthen) ...
  4. Compile and see the resulting errors: some more definitions are missing.
  5. Copy the missing definitions into the preamble and compile again.
  6. If you got all missing definitions the code can compile now.

Please see the following example for class article and command \cventry:

\documentclass{article}

\usepackage{calc}   % <=================================================
\usepackage{xcolor} % <=================================================
\usepackage{ifthen} % <=================================================

% <================== added code from moderncv.cls and moderncvbodyi.sty
\newcommand*{\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}}

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

\newlength{\hintscolumnwidth}
\setlength{\hintscolumnwidth}{0.175\textwidth}

\newlength{\separatorcolumnwidth}
\setlength{\separatorcolumnwidth}{0.025\textwidth}

\newlength{\maincolumnwidth}
\setlength{\maincolumnwidth}{\textwidth-\leftskip-\rightskip-\separatorcolumnwidth-\hintscolumnwidth}

\definecolor{color0}{rgb}{0,0,100} % <================================== blue
\newcommand*{\hintfont}{\mdseries} % <================================== bold
\newcommand*{\hintstyle}[1]{{\hintfont\textcolor{color0}{#1}}}


\begin{document}

\section{Test}

This is a usual paragraph in the document. This is a usual paragraph in the document. 
This is a usual paragraph in the document. This is a usual paragraph in the document. 
This is a usual paragraph in the document. This is a usual paragraph in the document. 

\section{Education}
\cventry{year--year}{Degree}{really very long Institution--3}{very long City--4}{\textit{Grade}--5}%
  {This is a very long description--6. This is a very long description. 
   This is a very long description. This is a very long description. 
   This is a very long description. This is a very long description}  

\end{document}

and see its resulting pdf page:

resulting pdf

Mensch
  • 65,388