¿Detectar si algo tiene una longitud?

¿Detectar si algo tiene una longitud?

¿Hay alguna forma en LaTeX de detectar si algo tiene una longitud con una función de la forma:

\NewDocumentCommand\iflength{m m m}{%CODE HERE%}

dónde:

  • el primer parámetro es lo que se va a probar
  • la segunda es la verdadera rama
  • la tercera es la rama falsa

código de prueba

\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}

información relacionada