\documentclass{article}
\usepackage{romannum}
\begin{document}
\newcounter{proximoMes}
\setcounter{proximoMes}{2}
\newcounter{qtdDiasI}
\setcounter{qtdDiasI}{5}
qtdDias\Romannum{\inteval{\value{proximoMes}-1}} % output: qtdDiasI
\Roman{qtdDias\Romannum{\inteval{\value{proximoMes}-1}}} % output: I
\end{document}
最后一行的 \Roman{ } 命令不显示计数器值;而是显示“I”。如何让 Roman 命令识别计数器名称并显示值“V”?
答案1
\Romannum 不可扩展。但 expl3 包含一个将整数表达式转换为罗马数字的函数:
\documentclass{article}
\ExplSyntaxOn
\newcommand\inttoRoman{}
\cs_set_eq:NN\inttoRoman\int_to_Roman:n
\ExplSyntaxOff
\begin{document}
\newcounter{proximoMes}
\setcounter{proximoMes}{2}
\newcounter{qtdDiasI}
\setcounter{qtdDiasI}{5}
\Roman{qtdDias\inttoRoman{\value{proximoMes}-1}} % output: V
\end{document}