3

I have problems with the linespace inside a longtable environment when forcing a linebreak. Following code should illustrate the problem.

\documentclass[11pt,paper=a4,11pt,parskip=half,draft]{scrartcl}

\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}

\usepackage{longtable}
\usepackage{tabularx}
\usepackage{ragged2e}
\usepackage{xcolor}

\usepackage{blindtext}

\definecolor{darkblue}{HTML}{212650}
\definecolor{grey}{HTML}{666666}

\newcommand{\itemdate}[1]{{\sffamily #1}}
\newcommand{\itemhead}[1]{{\sffamily\textcolor{darkblue}{\bfseries #1}}}
\newcommand{\itemplace}[1]{{\sffamily\itshape\footnotesize #1}}
% don't know why this cannot be local scope only ???!!!!
\newcommand{\iteminfo}[1]{\scriptsize #1}

% http://tex.stackexchange.com/a/7348/46403
% ragged2e packages provides text hyphenation in columns
\newcolumntype{L}[1]{>{\raggedright\hspace{0pt}\arraybackslash}p{#1}}   % left with dimension
\newcolumntype{J}[1]{>{\justifying\hspace{0pt}\arraybackslash}p{#1}}    % justify with dimension

\newcommand{\colwidth}[1]{%
    \dimexpr #1\textwidth-2\tabcolsep%
}%

\begin{document}

\begin{longtable}[!htbp]{|@{}L{\colwidth{0.2}}|L{\colwidth{0.8}}@{}|}

    \hline
    \itemdate{Itemdate 1} &
    \itemhead{Itemhead 1} \newline
    \itemplace{Itemplace 1} \vspace{3pt}\newline
    \iteminfo{\textbf{Iteminfo 1.1}: \blindtext[1]}
    \vspace{3pt}\newline%
    \iteminfo{\textbf{Iteminfo 1.2}: \blindtext[1]} \\

    \hline
    \itemdate{Itemdate 2} &
    \itemhead{Itemhead 2} \newline
    \itemplace{Itemplace 2} \\

    \hline
    \itemdate{Itemdate 3} &
    \itemhead{Itemhead 3} \newline
    \itemplace{Itemplace 3} \\
\end{longtable}

\end{document}

Also available at https://www.overleaf.com/2029617ptbycv#/5121602/

I hope this demonstrates the problem well enough.

If you look at the spacing between Itemhead 1 and Itemplace 1, this is the linespacing I would like to have.

The spacing between Itemhead 2 and Itemplace 2 as well as Itemhead 3 and Itemplace 3 is in my opinion too wide for a single newline. It should be singlespaced.

Right now I have no idea what forces latex to use a wider linespread between the Itemhead and Itemplace lines in row 2 and 3. Is must have something to do with the text following the Itemplace line. Because if I call \iteminfo after the \itemplace command, it shows that strange behaviour.

I am using MacTex 2014 on OSX 10.10.1.

This is how it looks like on OSX 10.10.1 Preview-App This is how it looks like on OSX 10.10.1 Preview-App

4
  • This is really strange. I'm going to update all my packages and attach a image illustrating the effect. Thank's for your other hints.
    – hetsch
    Dec 20 '14 at 11:09
  • After updating all packages the same effect is still there.
    – hetsch
    Dec 20 '14 at 11:24
  • The same happens in Adobe Acrobat Pro on OSX 10.10.1 and Acrobat Reader XI on Windows 7 and also on the webeditor link posted above. @Mico May I ask which pdf reader you are using?
    – hetsch
    Dec 20 '14 at 11:28
  • I can confirm that the spacing is as shown above, for me, on my Ubuntu TeXLive system. Dec 20 '14 at 11:37
5

You should always include end of paragraph (not \newline) if you have size changes. An entire paragraph is set with the baselinespacing in force at the end of the paragraph, so you were getting inconsistent settings.

\documentclass[11pt,paper=a4,11pt,parskip=half,draft]{scrartcl}

\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}

\usepackage{longtable}
\usepackage{tabularx}
\usepackage{ragged2e}
\usepackage{xcolor}

\usepackage{blindtext}

\definecolor{darkblue}{HTML}{212650}
\definecolor{grey}{HTML}{666666}

\newcommand{\itemdate}[1]{{\sffamily #1}}
\newcommand{\itemhead}[1]{{\sffamily\textcolor{darkblue}{\bfseries #1}}\par}
\newcommand{\itemplace}[1]{{\sffamily\itshape\footnotesize #1\par}}
% don't know why this cannot be local scope only ???!!!!
\newcommand{\iteminfo}[1]{{\scriptsize #1\par}}

% http://tex.stackexchange.com/a/7348/46403
% ragged2e packages provides text hyphenation in columns
\newcolumntype{L}[1]{>{\raggedright\hspace{0pt}\arraybackslash}p{#1}}   % left with dimension
\newcolumntype{J}[1]{>{\justifying\hspace{0pt}\arraybackslash}p{#1}}    % justify with dimension

\newcommand{\colwidth}[1]{%
    \dimexpr #1\textwidth-2\tabcolsep%
}%

\begin{document}

\begin{longtable}[!htbp]{|@{}L{\colwidth{0.2}}|L{\colwidth{0.8}}@{}|}

    \hline
    \itemdate{Itemdate 1} &
    \itemhead{Itemhead 1}
    \itemplace{Itemplace 1}
    \iteminfo{\textbf{Iteminfo 1.1}: \blindtext[1]}
    \iteminfo{\textbf{Iteminfo 1.2}: \blindtext[1]} \\

    \hline
    \itemdate{Itemdate 2} &
    \itemhead{Itemhead 2}
    \itemplace{Itemplace 2} \\

    \hline
    \itemdate{Itemdate 3} &
    \itemhead{Itemhead 3}
    \itemplace{Itemplace 3} \\
\end{longtable}

\end{document}
3
  • I'd omit the [!htbp] location specifier...
    – Mico
    Dec 20 '14 at 11:44
  • Thank you for the solution! This makes it clear to me what was going wrong!
    – hetsch
    Dec 20 '14 at 11:46
  • @david-carlisle What I've read now is that \par adjusts \baselineskip of that paragraph. In the example above using \par adds a last blank line after the last sentence which i want to avoid. My question would be if there exists another latex command which also sets the correct baselineskip value, like par, but does not start a newline (to avoid the blank line at every last paragraph ...)? I've tried to work with \par\vspace{-\baselineskip}, but this doesn't remove the last blank line.
    – hetsch
    Dec 20 '14 at 16:50
4

The reason you're getting different spacing results is because (a) you're using \newline instead of \par to insert line breaks and (b) different font sizes are used for items of type Itemhead (\normalsize), Itemplace (\footnotesize), and Iteminfo (\scriptsize).

The interline space that is used in a (logical) paragraph depends on the fontsize that's in effect at the end of the current paragraph. Importantly, \newline inserts a line break but it does not initiate a new paragraph. Thus, in the Itemhead1/Itemplace1/Iteminfo1 group, the spacing between Itemhead1 and Itemplace1 is what's appropriate for \scriptsize material (and thus quite tight) as \scriptsize is in effect at the end of the "paragraph". This effect is obscured because you have \vspace{3pt} instructions ahead of each Iteminfo element.

Conversely, in the case of Itemhead2/Itemplace2 and Itemhead3/Itemplace 3, the paragraph's final font size is \footnotesize, and you thus get (slightly) wider spacing than for the first group.

If you absolutely, positively must get the very tight spacing that's appropriate for \scriptsize material, you can get this result by inserting the instruction \scriptsize immediately after \itemplace{Itemplace 2}. However, I think you're better off replacing all \newline instructions with \par and getting rid of the \vspace{3pt instructions.

1
  • Mico, thank you for your explanation. I accepted David answer because he was faster an I can only accept one ... Thanks for all!
    – hetsch
    Dec 20 '14 at 11:48

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.