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

ifthenelse + \hline = "Misplaced \noalign"

426 views
Skip to first unread message

Felix Natter

unread,
Jun 30, 2003, 10:07:25 AM6/30/03
to
hi,

when I run \hline in the true-branch of a \ifthenelse
inside a tabular (\Constructor is called in a tabular-environment[1])

\newcommand*{\Constructor}[8][xxx]{%
\ifthenelse{1=1}{\hline}{}
}
(macro is simplified)

then I get this error:

! Misplaced \noalign.
\hline ->\noalign
{\ifnum 0=`}\fi \hrule \@height \arrayrulewidth \futurelet...

\\Constructor ...line \ifthenelse {1=1}{\hline }{}

It works fine if I just do "\hline" unconditionally in \Constructor.


[1]: this is the tabular-environment:
\begin{tabular}{|p{2.5cm}|p{4.5cm}|p{3.5cm}|p{3.5cm}|p{3.5cm}|p{3.5cm}|p{3.5cm}|}
\hline
\multirow{2}*{Method} & \multirow{2}*{Description} & \multicolumn{3}{c}{Parameters}\vline &
\multirow{2}*{Return value} & \multirow{2}*{Comments} \\
\cline{3-5} & & in & out & in+out & & \\
\hline
=> \Constructor is called here

thanks,

--
Felix Natter
Linux from *scratch* (www.gnu.org/software/emacs)
E-Mail: fna...@gmx.net

Ulrike Fischer

unread,
Jun 30, 2003, 11:42:17 AM6/30/03
to
Felix Natter <fna...@gmx.net> schrieb:

It would much easier to help you if you would sent a complete minimal
document that shows your problem instead of some scraps of code.

Ulrike Fischer

Felix Natter

unread,
Jun 30, 2003, 3:18:49 PM6/30/03
to
Ulrike Fischer <nililand...@t-online.de> writes:

yep, here it is:

\documentclass{article}

\usepackage{ifthen}

\begin{document}

\newcommand*{\mytabrow}[2]{%
#1 & #2 \\
\ifthenelse{1=1}{\hline}{}
}

\begin{tabular}{c|c}
first column & second column \\
\mytabrow{one}{two}
\end{tabular}

\end{document}

thanks,
--
Felix Natter
I love secs... for programming

Morten Høgholm

unread,
Jun 30, 2003, 3:44:00 PM6/30/03
to
Felix Natter wrote:
>
> yep, here it is:
>
> \documentclass{article}
>
> \usepackage{ifthen}
>
> \begin{document}
>
> \newcommand*{\mytabrow}[2]{%
> #1 & #2 \\
> \ifthenelse{1=1}{\hline}{}
> }
>
> \begin{tabular}{c|c}
> first column & second column \\
> \mytabrow{one}{two}
> \end{tabular}
>
> \end{document}
>
Try this instead:

\newcommand*{\mytabrow}[2]{%
#1 & #2

\ifthenelse{1=2}{\\\hline}{\\}%
}
--
Morten Høgholm.

Beware of my cheesy address!

www.student.cbs.dk/moho01ab

Ulrike Fischer

unread,
Jul 1, 2003, 4:22:43 AM7/1/03
to
Felix Natter <fna...@gmx.net> schrieb:


>>
>> It would much easier to help you if you would sent a complete minimal
>> document that shows your problem instead of some scraps of code.
>
> yep, here it is:
>
> \documentclass{article}
>
> \usepackage{ifthen}
>
> \begin{document}
>
> \newcommand*{\mytabrow}[2]{%
> #1 & #2 \\
> \ifthenelse{1=1}{\hline}{}
> }
>
> \begin{tabular}{c|c}
> first column & second column \\
> \mytabrow{one}{two}
> \end{tabular}
>
> \end{document}

Morton did give you the right advice. Roughly the rule is:

Don't start if-then-else-clauses with \hline (or \multicolumn). Both
commands can be used only at some places in the tabular (they want to
be directly after a \\, \hline or &) and get confused by the macro and
the ifthen-command.

Ulrike Fischer

0 new messages