20

I'm typesetting a document with lengthy itemize lists and in most cases LaTeX leaves lots of empty space before the environment in order to get it entirely on one page.

How can I encourage LaTeX to put page breaks within lists?

Update: I found that it works just fine when used not within \cventry command.

Is there anyway to fix \cventry definition in order to avoid non-breaking behavior?

From moderncvstylebanking.sty:

\renewcommand*{\cventry}[7][.25em]{
  \begin{tabular*}{\textwidth}{l@{\extracolsep{\fill}}r}%
      {\bfseries #4} & {\bfseries #5} \\%
      {\itshape #3\ifthenelse{\equal{#6}{}}{}{, #6}} & {\itshape #2}\\%
  \end{tabular*}%
  \ifx&#7&%
    \else{\\\vbox{\small#7}}\fi%
  \par\addvspace{#1}}

Examples: Originally I've used \cventry in the following way:

\cventry{March 2009--April 2011}{Software Developer}{Company}{City}{}{
    \begin{itemize}
        \item Item 1;
        % Lots of items here
        \item Item n.
    \end{itemize}
}

Probably I'm just misusing \cventry because using the following makes it just fine:

\cventry{March 2009--April 2011}{Software Developer}{Company}{City}{}{}
\begin{itemize}
    \item Item 1;
    % Lots of items here
    \item Item n.
\end{itemize}
6
  • 4
    LaTeX puts \@itempenalty between items but this is already negative (in article class at least) indicating that this is a good place to break. Is something else samepage for example setting this penalty (samepage sets it to the maximum penalty possible.) A MWE would help... Feb 28, 2012 at 17:30
  • Your concern is just before itemize? This can be controlled via enumitem's topsep key-value.
    – Werner
    Feb 28, 2012 at 17:30
  • @David Carlisle, I'm using moderncv class, but as far as I can see it also have negative \@itempenalty.
    – Regent
    Feb 28, 2012 at 17:42
  • @Werner, I would say I concerned about not breaking the page within itemize in general.
    – Regent
    Feb 28, 2012 at 17:49
  • 3
    Setting content in a box (like tabular), as is the case with \cventry, keeps things together and doesn't allow breaking across the page boundary. Would you be able to supply a minimal example that highlights your use of \cventry?
    – Werner
    Feb 28, 2012 at 18:22

4 Answers 4

12

I believe you answered your question yourself Regent :)

In regular circumstances, you do not want the explanation / itemization that goes with a cv entry to be broken up across page. It makes reading your resume and understanding your career achievements harder, which should be avoided at all costs. So in most cases, you simply put your itemize environment inside the last argument of \cventry

For special cases where you explicitly do want to split the explanation / itemize over 2 pages, you put it after the \cventry command.
Finally, note that in these special cases and when using the classic or casual styles, you will have to do the left padding yourself. An (ugly) way around this is to manually break your input over 2 \cventry or \cvitem.

2
  • 1
    Thanks, it's great to have the answer from moderncv package creator!
    – Regent
    Mar 1, 2012 at 12:29
  • If you use the first approach, the second part will have an alone point in the beginning of the page... \cventry{}{}{}{}{}{ \begin{itemize} \item ABC \end{itemize}}
    – Carmoreno
    Jan 7, 2022 at 4:06
8

I just discovered this problem today and ended up implementing a custom version of the \cventry command (dubbed \cventrylong) along with a customized itemize list environment cvitemize (via enumitem package):

% customize the enumerate environments (i.e. enumerate, itemize, ...)
\usepackage{enumitem}
\setlist{nolistsep}

% A custom version of the \cventry command that supports large itemized lists
% inside argument #7 (the custom cvitemize lists should be used!)
\newcommand*{\cventrylong}[7][.25em]{%
  \begin{tabular}{@{}p{\hintscolumnwidth}@{\hspace{\separatorcolumnwidth}}p{\maincolumnwidth}@{}}%
    \raggedleft\hintstyle{#2} &{%
        {\bfseries#3}%
        \ifthenelse{\equal{#4}{}}{}{, {\slshape#4}}%
        \ifthenelse{\equal{#5}{}}{}{, #5}%
        \ifthenelse{\equal{#6}{}}{}{, #6}%
    }%
  \end{tabular}%
  {\small#7}%
  \par\addvspace{#1}}
% A custom version of the itemize environment that sets the appropriate left
% margin for use inside \cventylong
\newlist{cvitemize}{itemize}{1}
\setlist[cvitemize]{label=\labelitemi,%
leftmargin=\hintscolumnwidth+\separatorcolumnwidth+\labelwidth+\labelsep}

Using a trimmed version of template.tex provided by the moderncv package, I can demonstrate the results:

  • Before: enter image description here

  • After: enter image description here

6
  • This appears to be a great solution for normal cventries, but doesn't help much in this case: tex.stackexchange.com/questions/181223/…
    – Mil
    May 30, 2014 at 11:18
  • @tjanez I'm having a similar problem. I also have a section with long texts, not necessarily because of many list items. Half of my first page is blank as your results show before change. How can I get rid of the blank? Nov 11, 2014 at 22:31
  • @tjanez, your solution seems good, but it compromises the aligniment of the arguments befor the 7th (look at you screenshots). Anyway I'm interested in this solution, so could you tell me how to fix this problem?
    – Enlico
    Oct 16, 2016 at 9:40
  • Is it possible to do without using itemize? If yes, then it answers my question here. Nov 28, 2017 at 16:28
  • Hi @tjanez, how can I Itemize with a dash "-" instead of a bullet the nested \begin{itemize} ... \end{itemize} ? ....Indeed, if I have \begin{cvitemize} ... \begin{itemize} ... \end{itemize} ... \end{cvitemize}, both \cvitemize and \itemize show bullets... I would like bullets for \cvitemize and dash "-" for the nested/inside\itemize...
    – Ommo
    Nov 7, 2022 at 16:59
2

Many document classes (notably, the standard classes article, book, and report, the KOMA-Script classes, memoir, and the AMS classes) include the code lines

\@lowpenalty=51

and

\@itempenalty=-\@lowpenalty

i.e., they set \@itempenalty to -51 and hereby encourage page breaks between list items. The moderncv class, however, only includes the second code line, i.e., the class sets \@itempenalty implicitly to 0. I don't know if this was done on purpose or should be considered a bug. However, try to add the following to your document preamble (EDIT: stupid mistake corrected):

\makeatletter
\@itempenalty=-51
\makeatother
7
  • Unfortunately manual setting of \@lowpenalty made no difference.
    – Regent
    Feb 28, 2012 at 18:10
  • I think it might be a problem with the way \cventry is defined, because it brake the page well when it was used not within \eventry...
    – Regent
    Feb 28, 2012 at 18:12
  • 1
    @lockstep -- don't you mean to set \@itempenalty=-51? Feb 28, 2012 at 18:13
  • @barbarabeeton Thanks! I don't know what I was thinking. Answer edited.
    – lockstep
    Feb 28, 2012 at 18:16
  • 1
    @lockstep, \@itempenalty=-51 doesn't help too.
    – Regent
    Feb 28, 2012 at 18:21
2

To complement @Xavier's answer, I post here the code of a custon defined mcvitemize environment, that mimics the behavior of \cventry for classic and casual themes.

\newenvironment{mcvitemize}
{%
    \addtolength{\leftmargini}{\dimexpr\hintscolumnwidth+\separatorcolumnwidth}
    \small
    \begin{itemize}
}{%
    \end{itemize}
}

where \addtolength{\leftmargini}{\dimexpr\hintscolumnwidth+\separatorcolumnwidth} controls the left padding of the items. \hintscolumnwidth and \separatorcolumnwidth are lengths defined by the modenrcv class.

To use it simply add the code to the preamble and then do

\cventry{March 2009--April 2011}{Software Developer}{Company}{City}{}{}
\begin{mcvitemize}
    \item Item 1;
    % Lots of items here
    \item Item n.
\end{mcvitemize}
1
  • Hi @Alessandro Cuttin, your solution leaves (i) a significant vertical space between {city} and the list of \item, and (ii) no space between two \cventry. Any solution to adjust those vertical spaces ?
    – Ommo
    Nov 4, 2022 at 12:28

You must log in to answer this question.

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