\ang
中提供的角度处理函数siunitx
以弧格式打印角度,其中度、弧分和弧秒以分号分隔:
\ang{1;2;3}
是否可以以类似于\SIlist
和\SIrange
函数的方式定义一个用于角度量列表和范围的宏来处理数字列表和范围?
答案1
首先要说的是:
% arara: pdflatex
\documentclass{article}
\usepackage{siunitx}
\usepackage{xparse}
\NewDocumentCommand\angRange{O{} m m}{\SIrange[parse-numbers=false, #1]{\ang[parse-numbers=true]{#2}}{\ang[parse-numbers=true]{#3}}{}}
\begin{document}
\noindent
\angRange{2.67}{6;7;6.5} \\
\angRange[number-angle-product = \,]{2.67}{6;7;6.5} \\
\angRange{6;7;6.5}{-1;;} \\
\angRange[arc-separator = \,]{6;7;6.5}{-1;;} \\
\angRange{-1;;}{;;-3} \\
\sisetup{add-arc-degree-zero}
\angRange{-1;;}{;;-3} \\
\sisetup{add-arc-minute-zero}
\angRange{-1;;}{;;-3} \\
\sisetup{add-arc-second-zero}
\angRange{-1;;}{;;-3} \\
\angRange{45.697}{6;7;6.5} \\
\angRange[angle-symbol-over-decimal]{45.697}{6;7;6.5} \\
\angRange{2}{4} \\
\angRange[range-units = brackets]{2}{4} \\
%\angRange[range-units = repeat][]{2}{4} \\ % should not be used as it makes no sense here
%\angRange[range-units = single][]{2}{4}\\ % should not be used as it makes no sense here
\SIrange[range-units = single]{2}{4}{\degree}
\end{document}