論理演算子を使用した \ifdefstring は可能ですか?

論理演算子を使用した \ifdefstring は可能ですか?
        \ifdefstring{command}{str1 OR str2}{yes}{no}

上記のようなものを実現する必要があります。\ifdefstring の文字列部分に論理演算子を使用することは可能ですか?

パッケージ :etoolbox

コマンド = 文字列型

etoolboxこのプロジェクトに追加し、\ifdefstring ソースを使用しました:https://github.com/posquit0/Awesome-CV

答え1

ブール式を構築できます:

\documentclass{article}
\usepackage{etoolbox}

\makeatletter
\newcommand{\ifdefstringor}[2]{%
  \begingroup\edef\x{\endgroup
    \noexpand\ifboolexpr{
      test {\noexpand\ifdefstring{\noexpand#1}{\@firstoftwo#2}}
      or
      test {\noexpand\ifdefstring{\noexpand#1}{\@secondoftwo#2}}
    }%
  }\x
}
\makeatother

\newcommand{\fooA}{str1}
\newcommand{\fooB}{str2}
\newcommand{\fooC}{str3}

\begin{document}

\ifdefstringor{\fooA}{{str1}{str2}}{yes}{no}

\ifdefstringor{\fooB}{{str1}{str2}}{yes}{no}

\ifdefstringor{\fooC}{{str1}{str2}}{yes}{no}

\ifdefstringor{\fooD}{{str1}{str2}}{yes}{no}

\end{document}

ここに画像の説明を入力してください

関連情報