Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}
share|improve this question

1 Answer 1

up vote 3 down vote accepted

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.

share|improve this answer
    
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 at 2:36

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.