代码
\documentclass{article}
\usepackage{expl3}
\usepackage{siunitx}
\setlength\parindent{0pt}
\begin{document}
\ExplSyntaxOn
\fp_new:N \mynumber
\fp_set:Nn \mynumber{5}
\fp_div:Nn \mynumber{2}
\mynumber
\\
\num{\mynumber}
\ExplSyntaxOff
\end{document}
印刷:
+2.500000000e0
2.500 000 000
我怎样才能打印它:
+2.500000000e0
2.5
?
答案1
使用
\fp_eval:n
或\fp_to_decimal:N
(“相同”),或\fp_to_scientific:N
创建可以作为siunitx
输入的 TeX 输出:
\documentclass{article}
\usepackage{expl3}
\usepackage{siunitx}
\begin{document}
\ExplSyntaxOn
\fp_new:N \mynumber
\fp_set:Nn \mynumber{5}
\fp_div:Nn \mynumber{2}
\fp_eval:n \mynumber \par
\fp_to_decimal:N \mynumber \par
\fp_to_scientific:N \mynumber \par
\num{\fp_to_decimal:N\mynumber}
\ExplSyntaxOff
\end{document}