ifthenelse inside a caption

312 views
Skip to first unread message

kipibenkipod

unread,
Feb 24, 2009, 1:34:03 PM2/24/09
to LaTeX Users Group
Hi,
I'm trying to use this simple code:
\caption{\ifthenelse{\equal{1}{1}}{1}{2}}

and I get:
! Undefined control sequence.
<argument> \equal

I use this ifthenelse in another newcommand and use the newcommand in
the caption.
Searching the net didn't give much.
What should I do in order to solve this?

Thanks,
Kfir

jon

unread,
Feb 25, 2009, 2:11:05 AM2/25/09
to LaTeX Users Group
On Feb 24, 1:34 pm, kipibenkipod <lavi.k...@gmail.com> wrote:
> Hi,
> I'm trying to use this simple code:
> \caption{\ifthenelse{\equal{1}{1}}{1}{2}}
>
> and I get:
> ! Undefined control sequence.
> <argument> \equal

undefined control sequence? have you loaded the ifthen package?

anyway, \caption is a fragile command, so i doubt it likes what
you're trying to do. however, if you use the optional argument as
well, perhaps your problem will disappear. (how complicated is your
real example?)

this works for me:

\documentclass{article}
\usepackage{ifthen}
\begin{document}

\begin{figure}
\caption[toc entry]{\ifthenelse{\equal{1}{1}}{1}{2}}
\end{figure}

\end{document}

cheers,
jon.

Kfir Lavi

unread,
Feb 25, 2009, 6:18:20 AM2/25/09
to LaTeX Users Group
Solved!
Thanks Jon.
My problem was a bit more complicated, but I just added the optional
argument to \caption and now everything works fine.
I really appreciate your help.
Thanks,
Kfir
Reply all
Reply to author
Forward
0 new messages