[texhax] question about \if
Vafa Khalighi
vafakhlgh at gmail.com
Fri Nov 12 13:18:08 CET 2010
Thanks heaps, Heiko
On Fri, Nov 12, 2010 at 10:57 PM, Heiko Oberdiek <
heiko.oberdiek at googlemail.com> wrote:
> On Fri, Nov 12, 2010 at 10:30:17PM +1100, Vafa Khalighi wrote:
>
> > To be more specific, this is what I have in mind:
> >
> > \newcommand{\setmaindir}[1]{\if#1RTL\pagedir TRT\else \if#1LTR\pagedir
> > TLT\fi\fi}
> >
> > so that
> >
> > \setmaindir{RTL} gives \pagedir TRT and
> > \setmaindir{LTR} gives \pagedir TLT
>
> \makeatletter
> \newcommand*{\my at pagedir@RTL}{\pagedir TRT}
> \newcommand*{\my at pagedir@LTR}{\pagedir TLT}
> \newcommand*{\setmaindir}[1]{%
> \ifcsname my at pagedir@#1\endcsname
> \csname my at pagedir@#1\expandafter\endcsname
> \else
> \PackageError{...}%
> {Invalid argument `#1' for \string\setmaindir}%
> \@ehc
> \fi
> }
> \makeatother
>
> Without e-TeX replace \ifcsname by
> \expandafter\ifx\csname ...\endcsname\relax
> or without the side effect of defining undefined
> commands with meaning \relax:
> \RequirePackage{ltxcmds}
> ...
> \newcommand*{\setmaindir}[1]{%
> \ltx at IfUndefined{}{%
> \csname my at pagedir@#1\endcsname
> }{%
> \PackageError{...}{...}\@ehc
> }%
> }%
> or without the package
> \newcommand*{\setmaindir}[1]{%
> \begingroup\expandafter\expandafter\expandafter\endgroup
> \expandafter\ifx\csname my at pagedir@#1\endcsname\relax
> \csname my at pagedir@#1\expandafter\endcsname
> \else
> \PackageError...
> \fi
> }
>
> Yours sincerely
> Heiko Oberdiek
> _______________________________________________
> TeX FAQ: http://www.tex.ac.uk/faq
> Mailing list archives: http://tug.org/pipermail/texhax/
> More links: http://tug.org/begin.html
>
> Automated subscription management: http://tug.org/mailman/listinfo/texhax
> Human mailing list managers: postmaster at tug.org
>
--
I prefer the most bloodcurdling death to living with humility. The only
country I am faithful to, is IRAN. Do not denigrate my last moments...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://tug.org/pipermail/texhax/attachments/20101112/0b66bd1d/attachment.html>
More information about the texhax
mailing list