1

I'm relearning LaTeX, but it effectively feels like starting over. My experience was limited to writing mathematics papers using templates, and frankly, that was years ago. As a way to refresh my LaTeX skills, I've been recreating my CV and drafting some teaching aids. My current questions revolve around macros in ModernCV (2015/07/28 v2.0.0 modern curriculum vitae and letter document class, as found on CTAN).

a) What does the last line of the \cventry macro, \par\addvspace{#1}, do? It's a very particular way of adding vertical space, so I'm curious about what it does.

b) How can the boundaries for wrapping text within a macro be adjusted (i.e., limited to columns)? I don't understand the structuring here and I haven't been able to find a good explanation (perhaps, for a lack of proper terminology). I was able to achieve decent results in a hacky way, by adding argument entries for \cventry (by default there are 7, bumped to 8 using \renewcommand and modifications) and manually splitting the long line into two arguments (vs wrapped).

c) How can the lines associated with \section and \subsection be extended to cover the full width of the page (they fail to reach the right edge of document/text)? I was unable to determine how they were defined when looking in the class file. It seems natural (to me) that they should scale with the document margins, but they don't.

Below is the minimized version of the preamble, my modifications, and the problems.

\documentclass[11pt,letterpaper,sans]{moderncv}
\moderncvstyle{banking}
\moderncvcolor{blue}

\usepackage[scale=0.81, margins=0.5in]{geometry}

\renewcommand*{\cventry}[8][.25em]{
  \begin{tabular*}{\textwidth}{l@{\extracolsep{\fill}}r}%
      {\bfseries #4} & {\bfseries #5} \\ % #4 = {institution/employer}; #5 = {localization}
      {\itshape #3\ifthenelse{\equal{#6}{}}{}{, #6}} & {\itshape #2}\\ % #3 = {degree/job title} ;#6 = {optional: comment/job description}; #2 = {years}
  \end{tabular*}%
  \ifx&#7&%
    \else{\\\vbox{\small#7}}\fi%
  \ifx&#8&%
    \else{\vspace{-2pt}\\\vbox{\small#8}}\fi%    
  \par\addvspace{#1}}

\newcommand*{\cvpdentry}[4][.25em]{
  \begin{tabular*}{\textwidth}{l@{\extracolsep{\fill}}r} %
      {\bfseries #2} & {\bfseries #3} \\ %
  \end{tabular*}%
  \ifx&#4&%
    \else{\\\vbox{\small#4}}\fi%
  \par\addvspace{#1}}

\begin{document}
\section{Education}
\subsection{Academic}
\begin{itemize}

\item\cventry[] %[spacing]
{December 2012} %{years}
{Master of Science in Important Subject} %{degree/job title}
{Land Grant University} %{institution/employer}
{Universitytown, ST} %{localization}
{summa magna cum laude} %{optional: grade/...}
{If this text section is too lengthy, it will overlap with the column containing the city and date(s).}{ How do I limit its length and force it to wrap prior to entering the right tabular structure?} %{optional: comment/job description}
\end{itemize}

\subsection{Professional Development}

\begin{itemize}
\item{\cvpdentry
{Premier Technological University}
{Premier, ST}
{Certificate of Oft-Used New Technology, Difficult Additional Coursework (HS6900), Proof of Updated Skills}}
\end{itemize}

\end{document}
  • Which version of moderncv do you use (check the log file for that information and add it please to your question ... – Mensch May 6 at 13:25
  • @Mensch Thanks for the reply. I added the version information. I'm unsure which version Overleaf uses by default, but it seems to produce the same results. – Eeight May 7 at 0:48
1

In your shown code are several missunderstandings and some errors. But let us have a look on that step by step.

  1. Question a: What does \par\addvspace{#1}, do? The new macro \cventry is defined like \renewcommand*{\cventry}[7][.25em], that means, it has one optional parameter (the first one #1, taking an predefined value of .25em) and six non optional parameters #2-#7. Command \par starts a new paragraph, command \addvspace{#1} adds then an vertical space of length #1, usualy (predefined) .25em. That makes sure, all cventrys have the same distance to each other.

  2. Therefore you have to use command \cventry[0pt]... instead your used \cventry[]... to get rid off the additional space.

  3. Question b: How can the boundaries for wrapping text within a macro be adjusted (i.e., limited to columns)? As you are already talking about columns -- you indeed need -- use a table for the complete \cventry or \cvpdentry. That means, that you can add an second table inside your \ifx&#7& or \ifx&#4& to get no overlapping first column. Instead your used l column in your table use a p{15cm} column: \begin{tabular*}{\textwidth}{p{15cm}@{\extracolsep{\fill}}r}%. For command \cvpdentry we get then the following code:

    %\cvpdentry[addvspace]{institution/employer}{localization}{optional: comment/job description}
    \newcommand*{\cvpdentry}[4][.25em]{
      \begin{tabular*}{\textwidth}{p{15cm}@{\extracolsep{\fill}}r} % <======
          {\bfseries #2} & {\bfseries #3} \\ %
      \end{tabular*}\par% <=================================================
      \ifx&#4&%
        \else{%
          \begin{tabular*}{\textwidth}{p{15cm}@{\extracolsep{\fill}}r}% <========= 
            {\small#4} & \\
          \end{tabular*}%
        }%
      \fi%
      \par\addvspace{#1}%
    }
    

    Have you noticed, that I deleted your 8th parameter, it is now not needed any more ...

  4. Question c: How can the lines associated with \section and \subsection be extended to cover the full width of the page (they fail to reach the right edge of document/text)? That is a missunderstanding, I fear ... The real problem here is that you are using \item to insert the bullet. But now the calculation of correct \textwidth for your table fails. You have to recalculate the correct table width like this: \textwidth-\labelwidth-\labelsep (the "label" here is the used bullet). In the following MWE I showed the correct calculation in commad \cventry, as you can see in the resulting pdf screenshot.

  5. Option margins for package geometry is wrong, it has to be margin ...

Please have a closer look to the following MWE (important code changings or added code is marked with <=========):

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

\moderncvstyle{banking}
\moderncvcolor{blue}

\usepackage[%
  scale=0.81, margin=0.5in, % <========================================= margin
  showframe                 % <=========== to visualize typing area and margins
]{geometry} 
%\cventry[addvspace]{years}{degree/job title}{institution/employer}{localization}{optional: grade/...}{optional: comment/job description}
\renewcommand*{\cventry}[7][.25em]{ % <=================================
  \begin{tabular*}{\textwidth-\labelwidth-\labelsep}{p{15cm}@{\extracolsep{\fill}}r}% <=======
      {\bfseries #4} & {\bfseries #5} \\ % #4 = {institution/employer}; #5 = {localization}
      {\itshape #3\ifthenelse{\equal{#6}{}}{}{, #6}} & {\itshape #2}\\ % #3 = {degree/job title} ;#6 = {optional: comment/job description}; #2 = {years}
  \end{tabular*}\par%
  \ifx&#7&%
    \else{%
      \begin{tabular*}{\textwidth}{p{15cm}@{\extracolsep{\fill}}r}%  
        {\small#7} & \\
      \end{tabular*}%
    }%
  \fi%
  \par\addvspace{#1}%
}

%\cvpdentry[addvspace]{institution/employer}{localization}{optional: comment/job description}
\newcommand*{\cvpdentry}[4][.25em]{
  \begin{tabular*}{\textwidth}{p{15cm}@{\extracolsep{\fill}}r} % <======
      {\bfseries #2} & {\bfseries #3} \\ %
  \end{tabular*}\par% <=================================================
  \ifx&#4&%
    \else{%
      \begin{tabular*}{\textwidth}{p{15cm}@{\extracolsep{\fill}}r}% <========= 
        {\small#4} & \\
      \end{tabular*}%
    }%
  \fi%
  \par\addvspace{#1}%
}

\name{John}{Doe} % <====================================================


\begin{document}
\section{Education Education Education Education Education Education 
  Education Education Education Education Education}
\subsection{Academic Academic Academic Academic Academic Academic 
  Academic Academic Academic}
\begin{itemize}

\item\cventry[0pt]                       %[spacing] <===================
{December 2012}                          %{years}
{Master of Science in Important Subject} %{degree/job title}
{Land Grant University}                  %{institution/employer}
{Universitytown, ST}                     %{localization}
{summa magna cum laude}                  %{optional: grade/...}
{If this text section is too lengthy, it will overlap with the column 
  containing the city and date(s). How do I limit its length and force 
  it to wrap prior to entering the right tabular structure?} %{optional: comment/job description}
\end{itemize}

\subsection{Professional Development}

\begin{itemize}
\item{\cvpdentry[0pt] % <===============================================
  {Premier Technological University Premier Technological University 
    Premier Technological University Premier Technological University}
  {Premier, ST}
  {Certificate of Oft-Used New Technology, Difficult Additional 
    Coursework (HS6900), Proof of Updated Skills}%
}
\end{itemize}

\end{document}

and the resulting pdf:

resulting pdf

| improve this answer | |
  • 1
    Wow, what a terrifically comprehensible, thorough, detail-oriented answer. Thank you so much for sharing your time and expertise. – Eeight May 7 at 17:09

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.