
次のコードを実行したいのですが、2番目のテストは失敗します。
! Argument of \@secondoftwo has an extra }.
何が欠けているのでしょうか?
\documentclass{article}
\usepackage{xstring,ifthen}
\newcommand{\mytest}[1]{%
\newcommand{\s}{\StrChar{#1}{3}}
\newcommand{\x}{c}
3rd charactor of input is: \s ~equal to \x \\
1st test: \IfStrEq{\x}{c}{true}{false} \\
2nd test: \IfStrEq{\s}{c}{true}{false}
}
\begin{document}
\mytest{abcd}
\end{document}
助けていただければ幸いです。ありがとう、マルテ
答え1
3番目のキャラクターとして定義するので\s
はなく、複雑な指示のセットとして定義します印刷3番目の文字。
より優れた機能を使用するxstring
:
\documentclass{article}
\usepackage{xstring}
\newcommand{\mytest}[1]{%
\StrChar{#1}{3}[\maltetest]%
Third charactor of input is: \maltetest\ equals c\\
Test: \IfStrEq{\maltetest}{c}{true}{false}%
}
\begin{document}
\mytest{abcd}
\end{document}
この方法では、\maltetest
入力文字列の 3 番目の文字が正確に含まれることになります。