Tricky table problem

Tricky table problem

Post by Ernst-Udo Wallenbor » Fri, 05 Mar 1999 04:00:00



Hi,

i want to set tables the following way (Oxford University Press
does it this way, an i like the design):

                      Table 1: The table is centered,
                      the caption has the same  width
                      as the table.
                      -------------------------------
                      head            col1      col2
                      -------------------------------
                      line 1           1         2
                      line 2           3         4(a)
                      -------------------------------
                      (a) is a footnote.

With the teTeX-0.9 (13jan99) i have on my machine (IRIX 6.3)
i can say

\newcommand{\str}{\mbox{\rule[-4pt]{0pt}{16pt}}}
\newcounter{storefootnote}%
\newcommand{\thtable}[7]{%
\setcounter{storefootnote}{\value{footnote}}%
\newsavebox{#1}%
\newlength{#2}%
\savebox{#1}{\begin{tabular}{#6}#7\end{tabular}}%
\settowidth{#2}{\usebox{#1}}%
\savebox{#1}{\begin{minipage}{#2}%
\makeatletter%


\makeatother%
\renewcommand{\footnoterule}{}%
\renewcommand{\thempfootnote}{\alph{mpfootnote}}%
\renewcommand{\thefootnote}{\thempfootnote}%
\begin{spacing}{0.8}%
\begin{tabular}{#6}#7\end{tabular}%
\end{spacing}%
\end{minipage}%

Quote:}%

\begin{table}[htbp]%
  \begin{center}%
    \begin{minipage}{#2}%
      \caption[#4]{#5}%
      \label{#3}\vspace{\baselineskip}%
    \end{minipage}%
    \begin{minipage}{#2}%
      \usebox{#1}%
    \end{minipage}%
  \end{center}%
\end{table}%
\setcounter{footnote}{\value{storefootnote}}%

Quote:}

and this is ugly, but works. Other teTeXes break this
(0.9 from november 98 as on SuSE 6.0 specifically), apparently
because one can not use commands in command definitions, and thus

\thtable{\tabledata}%
{\tabledatawidth}%
{tab:table-data}%
{Table. Short caption.}%
{Table. Long caption. Includes math $E=mc^2$ and citations \cite
as well as units as in \unit[627.51]{\kilo cal\per mol}.}%
{rdd}%
{
  \hline\str
  Line 1
  & \multicolumn{1}{c}{Column 1\footnote{One, \cite{One}}}
  & \multicolumn{1}{c}{Column 2\footnote{Two, \cite{Two}}} \\
  $a/\unit{\metre}$     & 1.00(2) & 2.01(1)\\
  $b/\unit{\metre}$     & 1.20(3) & 1.98(1)\\
  $c/\unit{\metre}$     & 1.19(3) & 3.21(1)\\
\hline }

results in an error message.
The other option is a new environment

\newcommand{\str}{\mbox{\rule[-4pt]{0pt}{16pt}}}%
\newcounter{storefootnote}%
\newsavebox{\cleantablebox}%
\newlength{\cleantablewidth}%
\newcommand{\cleancaptionone}{}%
\newcommand{\cleancaptiontwo}{}%
\newcommand{\cleanlabel}{}%
\newenvironment{cleantable}[3]{%
  \renewcommand{\cleanlabel}{#1}%
  \renewcommand{\cleancaptionone}{#2}%
  \renewcommand{\cleancaptiontwo}{#3}%
  \setcounter{storefootnote}{\value{footnote}}%
  \begin{table}[htbp]%
    \begin{center}%
      \setcaptionwidth{\cleantablewidth}%
      \caption[\cleancaptionone]{\cleancaptiontwo}%
      \label{\cleanlabel}%
    \end{center}%
    \begin{center}%
      \begin{minipage}{\cleantablewidth}%
        \makeatletter%


        \makeatother%
        \renewcommand{\footnoterule}{}%
        \renewcommand{\thempfootnote}{\alph{mpfootnote}}%
        \renewcommand{\thefootnote}{\thempfootnote}%
        }{%
      \end{minipage}%
    \end{center}%
  \end{table}%
  \setcounter{footnote}{\value{storefootnote}}%
  }%

but now i have to say

\begin{lrbox}{\cleantablebox}
\begin{tabular}{rdd}
  \hline\str
  Line 1
  & \multicolumn{1}{c}{Column 1\footnote{One, \cite{One}}}
  & \multicolumn{1}{c}{Column 2\footnote{Two, \cite{Two}}} \\
  $a/\unit{\metre}$     & 1.00(2) & 2.01(1)\\
  $b/\unit{\metre}$     & 1.20(3) & 1.98(1)\\
  $c/\unit{\metre}$     & 1.19(3) & 3.21(1)\\
\end{tabular}
\end{lrbox}
\settowidth{\cleantablewidth}{\usebox{\cleantablebox}}%  
\begin{cleantable}{tab:table-data}%
{Table. Short caption.}%
{Table. Long caption. Includes math $E=mc^2$ and citations \cite
as well as units as in \unit[627.51]{\kilo cal\per mol}.}%
\begin{tabular}{rdd}
  \hline\str
  Line 1
  & \multicolumn{1}{c}{Column 1\footnote{One, \cite{One}}}
  & \multicolumn{1}{c}{Column 2\footnote{Two, \cite{Two}}} \\
  $a/\unit{\metre}$     & 1.00(2) & 2.01(1)\\
  $b/\unit{\metre}$     & 1.20(3) & 1.98(1)\\
  $c/\unit{\metre}$     & 1.19(3) & 3.21(1)\\
\end{tabular}
\end{cleantable}

so i have to copy the tabular and remove the footnotes manually.
I'd like to avoid this. I played around a bit
with above definition, but i can't get two things
(a) \cleantablewidth known at \setcaptionwidth{\cleantablewidth}
(b) footnotes as above
working at the same time. Either i end up with a way too
narrow caption or i lose the footnotes of the table.

The basic point is that in the newcommand above the tabular
body is known because it's an argument. In a newenvironment
the body is  between
\begin{lrbox}

Quote:}{

\end{lrbox}
and thus only a box with the body in it is known. If there
was a way to access the stuff between \begin{} and \end{}
within the environment definition, there would be a way to
do what i want. But i don't know how.

Any suggestions?

--
Ernst-Udo Wallenborn
Laboratorium fuer Physikalische Chemie
ETH Zuerich

 
 
 

Tricky table problem

Post by Donald Arsene » Fri, 05 Mar 1999 04:00:00



>                      Table 1: The table is centered,
>                      the caption has the same  width
>                      as the table.
>                      -------------------------------
>                      head            col1      col2
>                      -------------------------------
>                      line 1           1         2
>                      line 2           3         4(a)
>                      -------------------------------
>                      (a) is a footnote.

threeparttable.sty

Quote:>and this is ugly, but works. Other teTeXes break this
>(0.9 from november 98 as on SuSE 6.0 specifically), apparently
>because one can not use commands in command definitions, and thus

This is incorrect.  If it breaks in other cases, it must be that you loaded
the definitions differently.  In particular, I noticed that you used
\makeatletter inside a macro before using an internal command in that macro:
that won't have any effect.  The treatment of "at" as a "letter" happens
as the characters are read from the input file, not when commands are executed.

Quote:>  \setcounter{storefootnote}{\value{footnote}}%

I have never found automatic numbering of table-notes to be flexible
enough.  In tabls.sty you type \tnote{a} to mark the note.



 
 
 

1. Tricky table problem

Hallo,

In the table posted below I try to calculate the exact width by using
the calc-package in order to get the minipage it's included in
and therefore the caption exactly as wide as the table. But it turns
out, that minipage and caption are to wide.
Can somebody help me with this? I don't have any further ideas.

Thanks in advance, Johannes

\documentclass{article}%
\usepackage{array,booktabs,calc,}%
\newcolumntype{N}{>{\scriptsize}l}%
\begin{document}%
\newlength{\onea}%
\settowidth{\onea}{\footnotesize\sffamily{12$\times$}}%
\newlength{\oneb}%
\settowidth{\oneb}{\scriptsize\sffamily{Temp.}}%
\newlength{\onec}%
\settowidth{\onec}{\scriptsize\sffamily{Inc.\,Time}}%
\newlength{\oned}%
\settowidth{\oned}{\footnotesize\sffamily{Initial Denaturation}}%
\newlength{\one}%
\setlength{\one}{\onea+\oneb+\onec+\oned+\tabcolsep*6}%
\begin{table}
\centering
\begin{minipage}{\one}
\caption{\label{table:SDMPCR}Cycling parameters used  for site
directed mutagenesis in pET\,11a, carrying \textit{hsp33} and
mutants;}%
\footnotesize\sffamily

\toprule

&\multicolumn{1}{N}{Inc.\,Time}

\cmidrule(r){1-1}\cmidrule(lr){2-2}\cmidrule(lr){3-3}\cmidrule(l){4-4}
2$\times$
&95
&0.5
&Initial Denaturation\\
\bottomrule
\end{tabular}
\end{minipage}
\end{table}%
\end{document}

Sent via Deja.com http://www.deja.com/
Before you buy.

2. Fixing bad imports

3. tricky syntax change with backslash problems

4. DECstation 5000/200 and mixed-size memory modules

5. tricky problem with halign

6. Compiling INFORM adventures on a IIGS

7. Tricky PSTricks?

8. C# COM Wrapper

9. Need help with tricky macro

10. tabularx question, probably tricky

11. tricky tabular arrangements

12. Q: A tricky footnote

13. Tricky Leaders ...