ifx 条件にネストされた、条件付きで定義された newif を処理しますか?

ifx 条件にネストされた、条件付きで定義された newif を処理しますか?

次の MWE を検討してください。

\documentclass[11pt]{book}

\def\entrytest{WORD}
\def\entrycurrent{NOWORD}
% \def\entrycurrent{WORD}

\ifx\entrytest\entrycurrent
  \newif\ifsomething
  \somethingfalse
\fi

\ifx\entrytest\entrycurrent
  \ifsomething\typeout{Yes}\else\typeout{No}\fi
\fi

\begin{document}
\end{document}

\ifsomething\typeout...今回のケースでは、 はそれをラップするによって「保護」されていると予想していました\ifxが、何かがおかしいようです。コードが次のエラーで停止します。

...
No
! Extra \fi.
l.15 \fi

? 

もちろん、\def\entrycurrent{WORD}すべてが\ifx「true」ブランチで実行される場合、すべてが期待どおりに動作します。

\newifでは、条件付きで定義されている可能性のある sの使用をどのように処理すればよいのでしょうか?

答え1

2番目の では\ifx\entrytest\entrycurrent\ifsomethingは定義されていないので、初め \fi一致しており\ifx、2番目は\fi場違いです。

マクロ名が条件文になるのではなく、トークンが条件文になるだけです。定義されたこれは、プリミティブ条件カウントの 1 つに相当します。

それ\newif\ifsomething

\let\ifsomething\iffalse
\def\somethingtrue{\let\ifsomething\iftrue}
\def\somethingfalse{\let\ifsomething\iffalse}

おそらく次のようなものが欲しいでしょう

\newif\ifsomething
\somethingtrue

\ifx\entrytest\entrycurrent
  \somethingfalse
\fi

\ifx\entrytest\entrycurrent
  \ifsomething\typeout{Yes}\else\typeout{No}\fi
\fi

しかし、そもそもなぜこれをやるのかは不明です。

関連情報