xdanaux / moderncv

A modern curriculum vitae class for LaTeX
1.8k stars 556 forks source link

Regression: \newline in cvitemwithcomment not working from v2.0.0 #50

Open Nodraak opened 7 years ago

Nodraak commented 7 years ago

Hi!

I just reinstalled my whole system yesterday (Debian 9 Stretch) and found a regression when compiling my resume. The bug was introduced in moderncv between these two version:

Minimal example:

\documentclass[11pt, a4paper]{moderncv}
\usepackage[utf8]{inputenc}

\moderncvstyle{classic}
\moderncvcolor{blue}

\firstname{first}
\familyname{last}

\begin{document}

\cvitemwithcomment{2016-2017}{ Lorem ipsum dolor sit amet, consectetur adipiscing elit. \newline Donec efficitur rutrum nisl, quis sodales mi mattis eget.}{}

\end{document}

Some more info (not sure if usefull ...)

tree's output for moderncv v2.0.0 installed with tlmgr:

$ tree ~/texmf/
/home/nodraak/texmf/
├── tex
│   └── latex
│       ├── framed
│       │   └── framed.sty
│       └── moderncv
│           ├── moderncvbodyiii.sty
│           ├── moderncvbodyii.sty
│           ├── moderncvbodyi.sty
│           ├── moderncvbodyiv.sty
│           ├── moderncvbodyv.sty
│           ├── moderncv.cls
│           ├── moderncvcollection.sty
│           ├── moderncvcolorblack.sty
│           ├── moderncvcolorblue.sty
│           ├── moderncvcolorburgundy.sty
│           ├── moderncvcolorgreen.sty
│           ├── moderncvcolorgrey.sty
│           ├── moderncvcolororange.sty
│           ├── moderncvcolorpurple.sty
│           ├── moderncvcolorred.sty
│           ├── moderncvcompatibility.sty
│           ├── moderncvdebugtools.sty
│           ├── moderncvfooti.sty
│           ├── moderncvheadiii.sty
│           ├── moderncvheadii.sty
│           ├── moderncvheadi.sty
│           ├── moderncvheadiv.sty
│           ├── moderncvheadvi.sty
│           ├── moderncvheadv.sty
│           ├── moderncviconsawesome.sty
│           ├── moderncviconsletters.sty
│           ├── moderncviconsmarvosym.sty
│           ├── moderncvstylebanking.sty
│           ├── moderncvstylecasual.sty
│           ├── moderncvstyleclassic.sty
│           ├── moderncvstyleempty.sty
│           ├── moderncvstylefancy.sty
│           ├── moderncvstyleoldstyle.sty
│           └── tweaklist.sty
├── tlpkg
│   ├── texlive.tlpdb
│   └── tlpobj
│       ├── 00texlive.installation.tlpobj
│       ├── framed.tlpobj
│       └── moderncv.tlpobj
└── web2c
    └── tlmgr.log

tree's output for moderncv v1.5.1 installed manually:

$ tree ~/texmf/
/home/nodraak/texmf/
├── tex
│   └── latex
│       ├── base
│       │   └── moderncv.cls
│       ├── framed
│       │   └── framed.sty
│       └── moderncv
│           ├── moderncvcollection.sty
│           ├── moderncvcolorblack.sty
│           ├── moderncvcolorblue.sty
│           ├── moderncvcolorgreen.sty
│           ├── moderncvcolorgrey.sty
│           ├── moderncvcolororange.sty
│           ├── moderncvcolorpurple.sty
│           ├── moderncvcolorred.sty
│           ├── moderncvcompatibility.sty
│           ├── moderncviconsawesome.sty
│           ├── moderncviconsletters.sty
│           ├── moderncviconsmarvosym.sty
│           ├── moderncvstylebanking.sty
│           ├── moderncvstylecasual.sty
│           ├── moderncvstyleclassic.sty
│           ├── moderncvstyleempty.sty
│           ├── moderncvstyleoldstyle.sty
│           └── tweaklist.sty
├── tlpkg
│   ├── texlive.tlpdb
│   └── tlpobj
│       ├── 00texlive.installation.tlpobj
│       └── framed.tlpobj
└── web2c
    └── tlmgr.log

Fresh system install from yesterday:

Nodraak commented 7 years ago

I believe here is the diff that introduced the bug (I grep'ed for \cvitemwithcomment in both version and diff'ed the result):

2,4c2,4
<   \savebox{\cvitemwithcommentmainbox}{{\bfseries#3}}%
<   \setlength{\cvitemwithcommentmainlength}{\widthof{\usebox{\cvitemwithcommentmainbox}}}%
<   \setlength{\cvitemwithcommentcommentlength}{\maincolumnwidth-\separatorcolumnwidth-\cvitemwithcommentmainlength}%
---
>   \savebox{\cvitemwithcommentbox}{{#3}}%
>   \setlength{\cvitemwithcommentskilllength}{\widthof{\usebox{\cvitemwithcommentbox}}}%
>   \setlength{\cvitemwithcommentcommentlength}{\maincolumnwidth-\separatorcolumnwidth-\cvitemwithcommentskilllength}%
6c6
<     \begin{minipage}[t]{\cvitemwithcommentmainlength}\bfseries#3\end{minipage}%
---
>     \begin{minipage}[t]{\cvitemwithcommentskilllength}\usebox{\cvitemwithcommentbox}\end{minipage}%

I conclude that \usebox prevent the use of line break. Here is a random stackoverflow link that seems to be relevant.

I think this is the commit that introduced the use of \usebox: f50d1cff324df184eb069b9aa21ea72e6c281bc0

mira-t commented 6 years ago

I can confirm I am having the same problem. It also applies to the cventry command.

michaelaye commented 5 years ago

Does anybody have a workaround?

WPettersson commented 4 years ago

Try loading the makecell package (\usepackage{makecell} in the preamble), then inside the braces you want to have a newline, change {this is a very very very very long line} to {\makecell[tl]{this is a very very very \\ very long line}}. The [tl] means justify to top and left, you can use top, centre, bottom, left, or right for these (vertical justification comes first).

cscheeder commented 1 year ago

Workaround works. Is there a way to have automatic linebreaks within the comment?