Why does combining some command of the xstring package causes errors? e.g. when I compile the following MWE:
\documentclass{article}
\usepackage{xstring}
\begin{document}
\section{A}
\StrCompare{\StrChar{bbbb}{4}}{\StrChar{aaaa}{3}}% are 4th character of first argument with 3th character of second argument differ ---> result 1 (yes and in first position)
\end{document}
it return the error:
! Undefined control sequence.
\xs_StrChar__ ...ef \xs_arg_ii {#2}\edef \xs_call
{\noexpand \xs_testopt {\n...
l.5 ...mpare{\StrChar{bbbb}{4}}{\StrChar{aaaa}{3}}
% are 4th character of fir...
?


xstring's commands are not expandable, so they can't be nested. You need to do in separate steps, something like\StrChar{bbbb}{4}[\resultA], then\StrChar{aaaa}{3}[\resultB], and then\StrCompare{\resultA}{\resultB}. The application is different, but the solution is basically the same as here – Phelype Oleinik Dec 01 '19 at 15:10