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}모든 \ifxs가 "true" 분기에서 실행된다면 모든 것이 예상대로 작동합니다.

\newif그렇다면 조건부로 정의된 s 의 사용을 어떻게 처리해야 할까요 ?

답변1

두 번째에서는 \ifx\entrytest\entrycurrent\ifsomething정의되지 않았으므로첫 번째 \fi일치 \ifx하고 두 번째는 \fi제자리에 없습니다.

어떤 것을 조건부로 만드는 것은 매크로 이름이 아닙니다. 유일한 토큰은한정된기본 조건 수 중 하나와 동일합니다.

무엇 \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

하지만 처음부터 왜 이런 일을 하려는지는 불분명합니다.

관련 정보