[Tugindia] Using conditionals

S. venkataraman svenkat at ignou.ac.in
Mon Sep 15 07:10:36 CEST 2008


On Sat, Sep 13, 2008 at 11:12 PM, Kannan Moudgalya <kannan at iitb.ac.in>wrote:

> Hi,
>
> I want to know how to use the conditionals in LaTeX.  For example, if I
> have the \multicols option on, I want the width of the inserted figures
> to be \linewidth.  If this option is off, the width should become
> 0.5\linewidth.  Thanks.
>
> Kannan
> _______________________________________________
> Home:        http://www.tug.org.in/
> TeX FAQ:     http://www.tex.ac.uk/faq
> unsubscribe: http://tug.org/mailman/listinfo/tugindia
>

Hi!
See if the followingwing will help.
\documentclass{article}
\usepackage{ifthenelse}
\newboolean{multcolson}
\setboolean{multcolson}{false}%default value is false
\newlength{\myfigwidth}
\ifthenelse{\boolean{multcolson}}%
{%if the boolean is true
\setlength{\myfigwidth}{0.5\linewidth}
}
{%if the boolean is false
\setlength{\myfigwidth}{\linewidth}
}
\begin{document}
-------
\includegraphics[width=\myfigwidth]{fig.eps}
--------------
\end{document}
You can set the value of multcolson to true
if you want using  the command
\setboolean{multcolson}{true}
whenever you want.
Hope this helps.
Regards,
S. Venkataraman


More information about the tugindia mailing list