[OS X TeX] Where is the mistake?

Ross Moore ross at ics.mq.edu.au
Wed Apr 15 23:20:54 CEST 2009


Hello Gewitterbukk,

On 16/04/2009, at 12:54 AM, Gewitterbukk wrote:

> Howdy!
>
> I'd like to design an environment to match the captionwidth to the  
> tablewidth. The caption should be above the table.

There are several mistakes in the coding below.

> Here the code.
>
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
> \newlength{\Tabellenbreite}
> \newcommand{\Tabelle}[3]{%
> 	\settowidth{\Tabellenbreite}{#3}%
> 	\setcapwidth[c]{\Tabellenbreite}%
> 	\caption[#1]{#2}%
> 	#3%
> }
> \newsavebox{\Tabellenbox}
> \newsavebox{\ParA}
> \newsavebox{\ParB}
> \newenvironment{TabelleSetztCaptionBreite}[2]{%
> 	\sbox{\ParA}{#1}%
> 	\sbox{\ParB}{#2}%
> 	\begin{lrbox}{\Tabellenbox}%
> }{%
> 	\end{lrbox}%
> 	\global\setbox\Tabellenbox=\box\Tabellenbox%
> 	\aftergroup\SetzeTabellenbox{\usebox{\ParA}}{\usebox{\ParB}}%

This line cannot possibly work.
It puts the  \SetzeTabellenbox  after the closing group,
without its arguments...


> }
> \newcommand{\SetzeTabellenbox}[2]{%
> 	\Tabelle{#1}{#2}{\usebox{\Tabellenbox}}}

   ... as it most surely needs!

Furthermore, the box registers set by  \sbox{\ParA}{#1}
and  \sbox{\ParB}{#2}  are set locally, not globally.
Hence after the grouping has closed, the results of
   \usebox{\ParA}   and   \usebox{\ParB}
will not be what you want.

You can get the command + arguments to be executed outside
the grouping, but not by using  \sbox  and  \usebox
as you are trying to do. Besides, the boxes will have been
set at the point of \sbox , at which time the caption width
is not known. So even then you will not get what you want.


Instead, you simply want to pass the arguments to be outside
the environment, which could be done with a global definition;
e.g. \gdef .

But why do you need it to be done "outside the environment"?

The following environment definition seems to work OK for me:

>>> \newenvironment{TabelleSetztCaptionBreite}[2]{%
>>> 	\newcommand{\ParA}{#1}%
>>> 	\newcommand{\ParB}{#2}%
>>> 	\begin{lrbox}{\Tabellenbox}%
>>> }{%
>>> 	\end{lrbox}%
>>> 	\SetzeTabellenbox{\ParA}{\ParB}%
>>> }



>
> \begin{table}
> 	\centering
> 	\begin{TabelleSetztCaptionBreite}{Caption-Eintrag}{Dies ist eine  
> Tabelle und so weiter und so weiter und so weiter \dots}
> 		\begin{tabular}{*{10}{l}}
> 			1 & 2 & 3 & 4 & 6 & 7 & 8 & 9 & 10\\
> 			1 & 2 & 3 & 4 & 6 & 7 & 8 & 9 & 10\\
> 			1 & 2 & 3 & 4 & 6 & 7 & 8 & 9 & 10\\
> 		\end{tabular}
> 	\end{TabelleSetztCaptionBreite}
> \end{table}
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
>
> Ideas?
>
> The error message is
>
>
> ! Incomplete \iffalse; all text was ignored after line 107.

Because you have created a token stream that looks like:

  ...{\usebox{\ParA}}{\usebox{\ParB}}...\endgroup\SetzeTabellenbox ...

where that final \SetzeTabellenbox  will pick up the next 2 tokens
as its arguments, whatever these may be.
Presumably one is an \if...  command, that is then going to be executed
completely out of the context for what it was designed to be used for.

>
> ! Emergency stop.
>
> ! ==> Fatal error occurred, no output PDF file produced!

TeX is completely confused by your document's coding,
which is making inappropriate use of LaTeX structures that
you don't even need.


>
>
> Thanks a lot!

I had to look back at previous messages from you, to determine
which document-class you are trying to use.

Please include the preamble of your document with any example code
that you post.  At least include enough of it so that your example
can be smoothly run by others without having to go searching for
any missing bits.


Hope this helps,

	Ross

------------------------------------------------------------------------
Ross Moore                                       ross at maths.mq.edu.au
Mathematics Department                           office: E7A-419
Macquarie University                             tel: +61 (0)2 9850 8955
Sydney, Australia  2109                          fax: +61 (0)2 9850 8114
------------------------------------------------------------------------






More information about the macostex-archives mailing list