mikew@wheeler.wrcr.unr.edu (Mike Whitbeck) (12/06/89)
I would like the captions under tables to be limited in horizontal extent to the width of the table. I think this looks better than what I get by default. Also I have several small tables which I would like to squeeze onto one page. A sample follows: ------------------------------------------------------ \documentstyle{article} \begin{document} \begin{table}[p] % \begin{center} \begin{tabular}{|c|c|c|}\hline 24 & bladder & Initial \\ hour & pump & value \\ \hline \hline .69 & .69 & .66 \\ .7 & .69 & .69 \\ .8 & .69 & .69 \\ .7 & .69 & .69 \\ .7 & .69 & .69 \\ \hline \hline \end{tabular} % \end{center} \caption{NO3 recovery (mg/l) from run 16327PL\label{XXX}} \end{table} \end{document} ------------------------------------------------------ Note that as is the caption is wider than the table-- how can I get the caption (in a box?) just the width of the table. Table widths may vary some. This LaTeX file was in fact written with an awk script extracting raw data from a database file; I would like to keep the process 'automated' rather than do hand-tuning if possible. Thanks in advance. ___________________________________________________________ |Mike Whitbeck | | |Desert Research Inst. | mikew@wheeler.wrc.unr.edu | |POB 60220 | | |RENO, NV 89506 | 702-673-7348 | |__________________________|______________________________|
bts@sas.UUCP (Brian T. Schellenberger) (12/13/89)
[Email isn't worth the paper it's printed on . . .]
Just create a macro which puts the tabular in a box and gets its width;
requires diving into TeX (untested) (and sketchy, but should give the
idea if you know plain TeX any; maybe someone else can develop this
better . . .
\newbox\boxbox
\newbox\boxtoo
\newenvironment{boxtab}[1]
{\def\boxcap{#1} \setbox\boxbox=\bgroup}
{\egroup \setbox\boxtoo=\vbox{\hsize=\wd\boxbox\boxcap}
\begin{table} \boxbox \caption{\boxtoo} \end{table}
}
\begin{boxtab}{caption}
this & that \\
and & more
\end{boxtab}
--
-- Brian, the Man from Babble-on. ...!mcnc!rti!sas!bts
-- (Brian Schellenberger)
"No one will ever write a song called 'Nitro Burning Funny Cars'"
-- THE DEAD MILKMEN, "Nitro Burning Funny Cars"