3

My goal is to get equal line spacing between text and array environments. This mostly works without any modification, except for one case: If the array environment consists of more than one line, the spacing thereafter is different.
* There is more space if another array environment follows (cf. column 4), and
* there is slightly less space if text follows (cf. column 5).

I tried to fix it myself (see \fixSpacingAfterMultilineArray), but this alleviates only the case where an array follows, and worsens the problem whenever text follows.

So my questions are:
* Why is the spacing different after a multiline array environment?
* How can I achieve consistent spacing after the array environment, regardless of the content that follows?

MWE code:

\documentclass{article}

\newcommand{\minip}[1]{%
  \noindent%
  \begin{minipage}[t]{1.3cm}#1\end{minipage}%
}

\newcommand{\arr}[1]{
  \setlength{\arraycolsep}{0pt}%
  \begin{array}[t]{l}#1\end{array}%
  % \par\fixSpacingAfterMultilineArray%
}

\newcommand{\fixSpacingAfterMultilineArray}{%
  % array with two lines has a depth of at least 15.60004pt
  \ifdim\prevdepth>15.6pt%
    \vspace{-1pt}%
  \fi%
}

\begin{document}

\minip{ Col1 TEXT TEXT TEXT}
\minip{ Col2 \arr{ ARR1} \arr{ ARR1} \arr{ ARR1}}
\minip{ Col3 \arr{ ARR1} \arr{ ARR1} TEXT }
\minip{ Col4 \arr{ ARR2 \\ ARR2} \arr{ ARR1}}
\minip{ Col5 \arr{ ARR2 \\ ARR2} TEXT}
\minip{ Col6 TEXT TEXT TEXT}

\end{document}

MWE output: enter image description here

3
  • What you are looking for is \arraystretch. See tex.stackexchange.com/questions/56101/… Jan 22, 2015 at 20:59
  • @John Kormylo do you mean changing \arraystretch at a specific location?
    – lujomu
    Jan 22, 2015 at 21:34
  • Note you are missing a % after { the problem is that the box with the array hides the baseline of the bottom row, l3coffins aim to fix that, meanwhile you can add a \strut to the last row so you know that has a known depth then you can adjust the space from a known baseline. Jan 22, 2015 at 22:17

1 Answer 1

6

You need to force \baselineskip rather than \lineskip to be used by allowing for the depth of the last row (assumed to be that of \strut)

enter image description here

\documentclass{article}
\usepackage{array}

\newcommand{\minip}[1]{%
  \noindent%
  \begin{minipage}[t]{1.3cm}\raggedright#1\end{minipage}%
}

\newcommand{\arr}[1]{%
  \setlength{\arraycolsep}{0pt}%
  \begin{array}[t]{l}#1\end{array}%
  \par
\vskip-\dp\strutbox
\nointerlineskip\null
}


\begin{document}

\minip{ Col1 TEXT TEXT TEXT}
\minip{ Col2 \arr{ ARR1} \arr{ ARR1} \arr{ ARR1}}
\minip{ Col3 \arr{ ARR1} \arr{ ARR1} TEXT }
\minip{ Col4 \arr{ ARR2 \\ ARR2} \arr{ ARR1}}
\minip{ Col5 \arr{ ARR2 \\ ARR2} TEXT}
\minip{ Col6 TEXT TEXT TEXT}

\end{document}
0

You must log in to answer this question.

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