
Existe uma maneira no LaTeX de detectar se algo tem um comprimento com uma função no formato:
\NewDocumentCommand\iflength{m m m}{%CODE HERE%}
onde:
- o primeiro parâmetro é o que será testado
- o segundo é o verdadeiro ramo
- o terceiro é o ramo falso
Código de teste
\documentclass[preview = true, varwidth = true]{standalone}
\NewDocumentCommand\iflength{m m m}{
%CODE HERE
}
\newlength{\mylength}
\setlength{\mylength}{10pt plus 1pt minus 1pt}
\newcommand{\commandlength}{10pt plus 1pt minus 1pt}
\newcommand{\commandstring}{xxx}
\begin{document}
\iflength{\mylength}{true}{false} % should be true
\iflength{\commandlength}{true}{false} % should be false (ideally, but ok if true)
\iflength{\commandstring}{true}{false} % should be false
\end{document}