
LaTeX 中有沒有一種方法可以偵測某個東西是否具有以下形式的函數的長度:
\NewDocumentCommand\iflength{m m m}{%CODE HERE%}
在哪裡:
- 第一個參數是要測試的東西
- 第二個是真正的分支
- 第三個是假枝
測試程式碼
\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}