1

The code for the two images below is identical except for the colors and the 4pt in the bounding box in the bottom image. In the bottom image the diagonal line touches the corner of the blue area; in the top image it does not touch the corner of the purple area. I'd like to know where the 4pt comes from, i.e. what LaTeX length contains it.

Basically, I'd like to be able to know the distance between the bottom of the diagonal line and the purple area in the top graph regardless of the environment (font sizes, lengths people have chosen, etcetera) so that I can automatically move whatever content is in the tikz image in the top left corner of the tabular by the same amount; I'm not looking for an ad hoc fix.

I've looked in various places for an answer to no avail.

PDF OUTPUT

\documentclass[12pt]{article}

\usepackage[svgnames]{xcolor}
\usepackage{tikz}
\usepackage{colortbl}


\begin{document}


\begin{tabular}{rccc}% 
\cellcolor{Yellow}%
\begin{tikzpicture}[]
\path[use as bounding box]  (0,0) -- (4,0) -- (4,4) -- (0,4) -- cycle;
\draw (4cm+\tabcolsep,0)--(2cm+\tabcolsep,2);
 \end{tikzpicture}
& L & R\\
U& \cellcolor{Purple} abra & & \\
\end{tabular}

\vspace*{3cm}

\begin{tabular}{rccc}% 
\cellcolor{Orange}%
\begin{tikzpicture}[]
% NOTE 4pt ON NEXT LINE

\path[use as bounding box]  (0,4pt) -- (4,4pt) -- (4,4) -- (0,4) -- cycle;
\draw (4cm+\tabcolsep,0)--(2cm+\tabcolsep,2);
\end{tikzpicture}
& L & R\\
U& \cellcolor{Blue} abra & & \\
\end{tabular}

\end{document}
3

This space is controlled by arraystretch (not a length, but a multiplier which defaults to 1) times the depth of \strutbox. Observe that setting arraystretch to zero, \renewcommand*{\arraystretch}{0} removes the spacing.

\number\dp\strutbox gives 285084 scaled points, and 285084/65536 is approximately 4.35 pt.

Note also that the array package used by colortbl adds \extrarowheight which would change the spacing in general.

  • I knew one could change arraystretch, which would also remove the space below L and R, which I don't want. But you did provide the answer to my question, i.e. \dp\strutbox! Thank you! – JPi Jul 16 '14 at 2:36

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.