[texhax] Equating conditionals
VAFA KHALIGHI
vafaklg at gmail.com
Sat Sep 17 06:51:52 CEST 2011
I found my answer:
\documentclass{article}
\makeatletter
\def\eqnewif#1#2{%
\count@\escapechar \escapechar\m at ne
\let#1\iffalse
\let#2\iffalse
\eq at if#1#2\iftrue
\eq at if#1#2\iffalse
\escapechar\count@}
\def\eq at if#1#2#3{%
\expandafter\def\csname\expandafter\@gobbletwo\string#1%
\expandafter\@gobbletwo\string#3\endcsname
{\let#1#3
\let#2#3}
\expandafter\def\csname\expandafter\@gobbletwo\string#2%
\expandafter\@gobbletwo\string#3\endcsname
{\let#2#3
\let#1#3}
}
\eqnewif{\if at RTL}{\if at rl}
\@RTLtrue
\def\test{\if at rl RTL\else LTR\fi}
\makeatother
\begin{document}
\test
\end{document}
On Sat, Sep 17, 2011 at 12:47 PM, VAFA KHALIGHI <vafaklg at gmail.com> wrote:
> I want to have a macro \eqnewif{#1}{#2} that if \if#1 is already defined by
> \newif, then \if#1 and \if#2 is the same thing such that \#1true is the same
> as \#2true and \#1false is the same as \#2false. This is what I have done:
>
> \documentclass{article}
>
> \makeatletter
>
> \newcommand*{\eq at newif}[2]{%
>
> \expandafter\let\csname if#2\expandafter\endcsname\csname if#1\endcsname}
>
> \def\eqnewif#1#2{\expandafter\newif\csname if#2\endcsname\eq at newif
> {#1}{#2}}
>
> \newif\if at RTL
>
> \eqnewif{@RTL}{@rl}
>
> \@RTLtrue
>
> \def\test{\if at rl RTL\else LTR\fi}
>
> \makeatother
>
> \begin{document}
>
> \test
>
> \end{document}
>
>
> but it returns LTR instead RTL however if I move \def\test.. before
> \@RTLtrue , then it behaves as I expect. How should I fix this?
>
>
> Thanks
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://tug.org/pipermail/texhax/attachments/20110917/dbc806f4/attachment.html>
More information about the texhax
mailing list