I am using LaTeX 2.09 (upgrading is unfortunately not an option) and am having
a bit of trouble with the tabular environment. With the following code,
the top of the word 'HELLO' touches the horizontal line. Is there any way
to prevent this from occuring?
\documentstyle[12pt]{article}
\begin{document}
\begin{tabular}{l}\hline
{\large HELLO}
\end{tabular}
\end{document}
Ron
|> I am using LaTeX 2.09 (upgrading is unfortunately not an option) and am having
|> a bit of trouble with the tabular environment. With the following code,
|> the top of the word 'HELLO' touches the horizontal line. Is there any way
|> to prevent this from occuring?
Put a \strut in the large line:
|> \documentstyle[12pt]{article}
|> \begin{document}
|> \begin{tabular}{l}\hline
|> {\large\strut HELLO}
^^^^^^
|> \end{tabular}
|> \end{document}
--
Andreas Schwab "And now for something
sch...@issan.informatik.uni-dortmund.de completely different"
1. Do not use \large, \Large, ... in a `tabular'
2. If you really think that the \large is necessary, you can put a
\strut before "HELLO".
-bernd
PS: Hint: Use as few lines as possible in a `tabular' to get a
professional looking one... use white space instead...
\halign, the TeX primitive on which the tabular environment is built,
works this way by default. It leaves "just enough" room. (The hight
and depth of each row is actually determined by the \strut that LaTeX
will place in it). It's up to you to add additional space to improve the
appearance. In fact, Knuth even discusses this issue in the TeXbook -
he suggests looking for the additional space as "a mark of quality"
(page 246).
Anyway, here's some code I wrote to use in this situation. It should
work with either LaTeX209 (for which I wrote it) or LaTeX2e. You'll
have to either place it in a style file or surround it by
\makeatletter/\makeatother commands:
--------------------------------------------------
%
% \bigstrut[x] produces a strut which is \bigstrutjot (2pt by default)
% higher, lower, or both than the standard array/table strut. Designed
% to be used in table entries that are adjacent to \hline's - this isn't
% normally an issue for arrays because they are "opened up" by \jot
% anyway.
%
% \bigstrut[t] adds height; \bigstrut[b] adds depth. Just \bigstrut
% adds both.
%
% Spaces after the \bigstrut are ignored, even if it has an optional
% argument. Spaces before the \bigstrut are generally ignored (by a
% single \unskip).
%
\newdimen\bigstrutjot \bigstrutjot2pt
\def\bigstrut{\relax\@ifnextchar [{\@bigstrut}{\@bigstrut[x]}}
\def\@bigstrut[#1]{\unskip\@tempdima\ht\@arstrutbox
\@tempdimb\dp\@arstrutbox
\ifx #1b\else \advance\@tempdima by \bigstrutjot\fi
\ifx #1t\else \advance\@tempdimb by \bigstrutjot\fi
\hbox{\vrule \@height\@tempdima \@depth\@tempdimb
\@width\z@}\ignorespaces}
--------------------------------------------------
The way you use this is to place \bigstrut at the beginning of a row
that's adjacent to a \hline. Use \bigstrut[t] if there's an \hline
above but none below; \bigstrut[b] if there's one below but not above;
and just \bigstrut if there are \hline's in both positions.
\bigstrut discards spaces after it, and usually is able to discard
spaces before it. It may get this wrong every once in a while, in which
case you'll see some odd spacing in the output. Since you can actually
put \bigstrut anywhere in the row, just move it someplace else.
-- Jerry
> I am using LaTeX 2.09 (upgrading is unfortunately not an option) and
> am having a bit of trouble with the tabular environment. With the
> following code, the top of the word 'HELLO' touches the horizontal
> line. Is there any way to prevent this from occuring?
There are lots of ways of doing this.
If you absolutely refuse to get hold of other packages, then something
like
\hline\noalign{\kern2pt}
might do the job assuming that you're not using vertical rules as well.
(This just leaves a vertical gap after the line, so the vertical rules
will be interrupted.)
If you have the standard `array' package described in the LaTeX
Companion, then USE IT. It's dead good (honest) and fixes all sorts of
things which the old package didn't do right. This is one of those
things. By setting \extrarowheight to something appropriate. I've just
run a quick test, and
\setlength{\extrarowheight}{3pt}
looks like the right choice to me.
If you really want perfect results, then use my `mdwtab' package, which
is lying around on CTAN, and say
\begin{tabular}{l} \hlx{hv} % instead of the first \hline
\large Some text! \\ \hlx{vh} % instead of a final \hline
\end{tabular}
and an appropriate amount of space will be inserted automagically.
--
[mdw]
`When our backs are against the wall, we shall turn and fight.'
-- John Major