Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

tabular multicolumn problem

1,019 views
Skip to first unread message

Jobst Hoffmann

unread,
Nov 3, 2008, 12:18:56 PM11/3/08
to
Hi all,

if I create a LaTeX-file like

--------8<---------------------------------------------
\documentclass{article}
\begin{document}

\begin{tabular}{cc}
\multicolumn{2}{c}{a}
\end{tabular}

\begin{tabular}{cc}
\input{mc}
\end{tabular}

\end{document}
--------8<---------------------------------------------

and a file mc.tex
--------8<---------------------------------------------
\multicolumn{2}{c}{a}
--------8<---------------------------------------------

the first tabular environment is formatted corrected, but the formatting
of the second tabular environment fails with an error message like

(./mc.tex
! Misplaced \omit.
\multispan ->\omit
\@multispan
l.1 \multicolumn{2}{c}{a}

?

Is there someone who can explain the behaviour to me (btw. inputting
other things into tabular environment works fine) and give a hint to
avoid that error?

Thanks in advance!
Jobst

Ulrike Fischer

unread,
Nov 3, 2008, 12:46:22 PM11/3/08
to

\multicolumn must be the very first thing in a cell. You can't put
commands like \input inbetween.

--
Ulrike Fischer

Heiko Oberdiek

unread,
Nov 3, 2008, 3:15:41 PM11/3/08
to
Ulrike Fischer <ne...@nililand.de> wrote:

> > \begin{tabular}{cc}
> > \input{mc}
> > \end{tabular}

> > and a file mc.tex


> > --------8<---------------------------------------------
> > \multicolumn{2}{c}{a}
> > --------8<---------------------------------------------
> >
> > the first tabular environment is formatted corrected, but the formatting
> > of the second tabular environment fails with an error message like
> >
> > (./mc.tex
> > ! Misplaced \omit.
> > \multispan ->\omit
> > \@multispan
> > l.1 \multicolumn{2}{c}{a}
> >
> > ?
> >
> > Is there someone who can explain the behaviour to me (btw. inputting
> > other things into tabular environment works fine) and give a hint to
> > avoid that error?
>
> \multicolumn must be the very first thing in a cell. You can't put
> commands like \input inbetween.

Especially LaTeX's version of \input is not expandable and such
non-expandable stuff will be the first thing in the cell.
The original \input as TeX primitive is expandable. That can be used
(LaTeX stores it in \@@input). But the syntax is the syntax of the
original TeX primitive and it doesn't provide LaTeX's error handling
for non-existing files.

\begin{tabular}{cc}
\csname @@input\endcsname mc %
\end{tabular}

But I think, a better solution would be, if the \begin and \end stuff
is also put into the file mc.tex.

Yours sincerely
Heiko <ober...@uni-freiburg.de>

Jobst Hoffmann

unread,
Nov 4, 2008, 3:12:59 PM11/4/08
to

Thank you for your advices with \@@input, that's what I asked for. You
are right with the better solution but the original problem is much more
complicated and so this is not applicable.

Yours sincerely
Jobst

Emily Rigdon

unread,
Oct 18, 2014, 5:25:38 PM10/18/14
to
You all made my day! This obscure rule about \multicolumn solved my problem exactly! I just rewrote my code so I could not be inputting lines that started with that line. I would have never figured this out by chance, and the debugging was already giving me a headache.
This may not have been the solution for the OP, but it sure was for me!
Thank you, thank you so much!
0 new messages