1

I am using the latex style moderncv with command \cventry which has the definition as follows:

% makes a typical resume job / education entry
% usage: \cventry[spacing]{years}{degree/job title}{institution/employer}{localization}{optionnal: grade/...}{optional: comment/job description}
\newcommand*{\cventry}[7][.25em]{}

I am using this to create a CV entry for my current employment however, my institution/employer entry is too long to fit on one line and I get an overfull hbox. How can I wrap this onto the next line?

A MWE is given below:

\documentclass[11pt,a4paper,sans]{moderncv}       
\moderncvstyle{banking}                           
\moderncvcolor{blue}                              
\usepackage[utf8]{inputenc}                     
\usepackage[scale=0.82]{geometry}
\usepackage{import}
\name{Joe}{Bloggs}
\address{Somewhere Street, Somewhere}{12345}{Country}

\begin{document}

\makecvtitle

\section{Current Employment}

\vspace{6pt}

\begin{itemize}

\item{\cventry{date--present}{Job Title}{Job name}{Long name of my current employer which causes an overfull hbox and runs off the edge of the page}{}{}{\vspace{3pt}}}

\end{itemize}

\end{document}

The output is shown below:

Overflowing Hbox

Ideally I would like to wrap the overflowing Hbox onto a new line (still right aligned so that 'Long name of my current employer...' doesn't collide with the left-handside Hbox ('Job title') and run off the right-hand side margin. Is there a way to do this?

1
  • Actually, the definition of \cventry that your MWE uses is the following: \renewcommand*{\cventry}[7][.25em]{ \begin{tabular*}{\maincolumnwidth}{l@{\extracolsep{\fill}}r}% {\bfseries #4} & {\bfseries #5}\\% {\itshape #3\ifthenelse{\equal{#6}{}}{}{, #6}} & {\itshape #2}\\% \end{tabular*}% \ifx&#7&% \else{\\% \begin{minipage}{\maincolumnwidth}% \small#7% \end{minipage}}\fi% \par\addvspace{#1}} (taken from moderncvbodyiii.sty that is loaded by the banking style of moderncv.)
    – leandriis
    Sep 29, 2019 at 10:14

1 Answer 1

2

The current definition of command \cventry does not allow to get what you want. But you can define an new command \mycventry like this:

\newcommand*{\mycventry}[8][.25em]{ % <=================================
  \begin{tabular*}{\maincolumnwidth}{l@{\extracolsep{\fill}}r}% 
  {\bfseries #4} & {\bfseries #5}\\% 
   & {\bfseries #8} \\ % <==============================================
  {\itshape #3\ifthenelse{\equal{#6}{}}{}{, #6}} & {\itshape #2}\\% 
  \end{tabular*}% 
  \ifx&#7&% 
  \else{\\% 
  \begin{minipage}{\maincolumnwidth}% 
    \small#7% 
  \end{minipage}}\fi% 
  \par\addvspace{#1}}

As you can see I added an 8th parameter (#8) to take the second part of your needed text. So parameter 5 (#5) takes the first part of your text, parameter 8 the second part. If you want you can change the used parameters to get both text parts in for example parameter 5 and 6, but then you have to change the new command \mycventry. Your case is very special, I think the given solution above is good enouph ... You can use is like this:

\item \mycventry{date--present--2}%
  {Job Title--3}%
  {Job name--4}%
  {Long name of my current employer whichcauses an--5}%
  {--6}%
  {--7}%
  { overfull hbox and runs off the edge of the page--8}% <=========================

With the following complete code

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

\moderncvstyle{banking}
\moderncvcolor{blue}

\usepackage[utf8]{inputenc}
\usepackage[scale=0.82]{geometry}
\usepackage{import}

\name{Joe}{Bloggs}
\address{Somewhere Street, Somewhere}{12345}{Country}

\newcommand*{\mycventry}[8][.25em]{ % <=================================
  \begin{tabular*}{\maincolumnwidth}{l@{\extracolsep{\fill}}r}% 
  {\bfseries #4} & {\bfseries #5}\\% 
   & {\bfseries #8} \\ % <==============================================
  {\itshape #3\ifthenelse{\equal{#6}{}}{}{, #6}} & {\itshape #2}\\% 
  \end{tabular*}% 
  \ifx&#7&% 
  \else{\\% 
  \begin{minipage}{\maincolumnwidth}% 
    \small#7% 
  \end{minipage}}\fi% 
  \par\addvspace{#1}}


\begin{document}

\makecvtitle

\section{Current Employment}

\vspace{6pt}

\begin{itemize}

%\item \cventry{date--present--2}{Job Title--3}{Job name--4}{Long name of my current employer whichcauses an overfull hbox \\ and runs off the edge of the page--5}{--6}{--7}%{\vspace{3pt}}

\item \mycventry{date--present--2}{Job Title--3}{Job name--4}{Long name of my current employer whichcauses an--5}{--6}{--7}{ overfull hbox and runs off the edge of the page--8}% <=========================

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

\item \cventry{year--year--2}{Degree--3}{}{}{}{}  % arguments 4 to 7 can be left empty

\end{itemize}

\end{document}

you get the following resulting pdf:

resulting pdf

You must log in to answer this question.

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