以下 MWE:
\documentclass{article}
\usepackage{siunitx}
\listfiles
\begin{document}
% \SI{a}{\cm} % Invalid token 'a' in numerical input
\SI[parse-numbers = false]{a}{\cm}
\end{document}
(一切都从这里开始:正确使用 `siunitx` 方式排版复杂表达式)
有人可以建议siunitx
排版这种表达的正确方法是什么吗?
Overleaf 上编译:
This is pdfTeX, Version 3.14159265-2.6-1.40.21 (TeX Live 2020) (preloaded format=pdflatex 2020.9.10) 24 JUN 2021 16:31
entering extended mode
\write18 enabled.
%&-line parsing enabled.
**main.tex
(/compile/main.tex
LaTeX2e <2020-02-02> patch level 5
L3 programming layer <2020-07-17> (/usr/local/texlive/2020/texmf-dist/tex/latex
/base/article.cls
Document Class: article 2019/12/20 v1.4l Standard LaTeX document class
(/usr/local/texlive/2020/texmf-dist/tex/latex/base/size10.clo
File: size10.clo 2019/12/20 v1.4l Standard LaTeX file (size option)
)
\c@part=\count168
\c@section=\count169
\c@subsection=\count170
\c@subsubsection=\count171
\c@paragraph=\count172
\c@subparagraph=\count173
\c@figure=\count174
\c@table=\count175
\abovecaptionskip=\skip47
\belowcaptionskip=\skip48
\bibindent=\dimen134
) (/usr/local/texlive/2020/texmf-dist/tex/latex/siunitx/siunitx.sty (/usr/local
/texlive/2020/texmf-dist/tex/latex/l3kernel/expl3.sty
Package: expl3 2020-07-17 L3 programming layer (loader)
(/usr/local/texlive/2020/texmf-dist/tex/latex/l3backend/l3backend-pdfmode.def
File: l3backend-pdfmode.def 2020-06-29 L3 backend support: PDF mode
\l__kernel_color_stack_int=\count176
\l__pdf_internal_box=\box45
)) (/usr/local/texlive/2020/texmf-dist/tex/latex/l3packages/xparse/xparse.sty
Package: xparse 2020-05-15 L3 Experimental document command parser
(/usr/local/texlive/2020/texmf-dist/tex/latex/l3packages/xparse/xparse-generic.
tex
\l__xparse_current_arg_int=\count177
\g__xparse_grabber_int=\count178
\l__xparse_m_args_int=\count179
\l__xparse_v_nesting_int=\count180
))
Package: siunitx 2020/02/25 v2.8b A comprehensive (SI) units package
(/usr/local/texlive/2020/texmf-dist/tex/latex/amsmath/amstext.sty
Package: amstext 2000/06/29 v2.01 AMS text
(/usr/local/texlive/2020/texmf-dist/tex/latex/amsmath/amsgen.sty
File: amsgen.sty 1999/11/30 v2.0 generic functions
\@emptytoks=\toks15
\ex@=\dimen135
)) (/usr/local/texlive/2020/texmf-dist/tex/latex/tools/array.sty
Package: array 2019/08/31 v2.4l Tabular extension package (FMi)
\col@sep=\dimen136
\ar@mcellbox=\box46
\extrarowheight=\dimen137
\NC@list=\toks16
\extratabsurround=\skip49
\backup@length=\skip50
\ar@cellbox=\box47
) (/usr/local/texlive/2020/texmf-dist/tex/latex/l3packages/l3keys2e/l3keys2e.st
y
Package: l3keys2e 2020-05-15 LaTeX2e option processing using LaTeX3 keys
)
\l__siunitx_tmp_box=\box48
\l__siunitx_tmp_dim=\dimen138
\l__siunitx_tmp_int=\count181
\l__siunitx_number_mantissa_length_int=\count182
\l__siunitx_number_uncert_length_int=\count183
\l__siunitx_round_int=\count184
\l__siunitx_process_decimal_int=\count185
\l__siunitx_process_uncertainty_int=\count186
\l__siunitx_process_fixed_int=\count187
\l__siunitx_process_integer_min_int=\count188
\l__siunitx_process_precision_int=\count189
\l__siunitx_group_min_int=\count190
\l__siunitx_angle_marker_box=\box49
\l__siunitx_angle_unit_box=\box50
\l__siunitx_angle_marker_dim=\dimen139
\l__siunitx_angle_unit_dim=\dimen140
\l__siunitx_unit_int=\count191
\l__siunitx_unit_denominator_int=\count192
\l__siunitx_unit_numerator_int=\count193
\l__siunitx_unit_prefix_int=\count194
\l__siunitx_unit_prefix_base_int=\count195
\l__siunitx_unit_prefix_gram_int=\count196
\l__siunitx_number_product_int=\count197
\c__siunitx_one_fill_skip=\skip51
\l__siunitx_table_unit_align_skip=\skip52
\l__siunitx_table_exponent_dim=\dimen141
\l__siunitx_table_integer_dim=\dimen142
\l__siunitx_table_mantissa_dim=\dimen143
\l__siunitx_table_marker_dim=\dimen144
\l__siunitx_table_result_dim=\dimen145
\l__siunitx_table_uncert_dim=\dimen146
\l__siunitx_table_fill_pre_dim=\dimen147
\l__siunitx_table_fill_post_dim=\dimen148
\l__siunitx_table_fill_mid_dim=\dimen149
\l__siunitx_table_pre_box=\box51
\l__siunitx_table_post_box=\box52
\l__siunitx_table_mantissa_box=\box53
\l__siunitx_table_result_box=\box54
\l__siunitx_table_number_align_skip=\skip53
\l__siunitx_table_text_align_skip=\skip54
(/usr/local/texlive/2020/texmf-dist/tex/latex/translator/translator.sty
Package: translator 2019-05-31 v1.12a Easy translation of strings in LaTeX
(/usr/local/texlive/2020/texmf-dist/tex/latex/graphics/keyval.sty
Package: keyval 2014/10/28 v1.15 key=value parser (DPC)
\KV@toks@=\toks17
))) (/compile/output.aux)
\openout1 = `output.aux'.
LaTeX Font Info: Checking defaults for OML/cmm/m/it on input line 7.
LaTeX Font Info: ... okay on input line 7.
LaTeX Font Info: Checking defaults for OMS/cmsy/m/n on input line 7.
LaTeX Font Info: ... okay on input line 7.
LaTeX Font Info: Checking defaults for OT1/cmr/m/n on input line 7.
LaTeX Font Info: ... okay on input line 7.
LaTeX Font Info: Checking defaults for T1/cmr/m/n on input line 7.
LaTeX Font Info: ... okay on input line 7.
LaTeX Font Info: Checking defaults for TS1/cmr/m/n on input line 7.
LaTeX Font Info: ... okay on input line 7.
LaTeX Font Info: Checking defaults for OMX/cmex/m/n on input line 7.
LaTeX Font Info: ... okay on input line 7.
LaTeX Font Info: Checking defaults for U/cmr/m/n on input line 7.
LaTeX Font Info: ... okay on input line 7.
(/usr/local/texlive/2020/texmf-dist/tex/latex/translator/translator-basic-dicti
onary-English.dict
Dictionary: translator-basic-dictionary, Language: English
)
(/usr/local/texlive/2020/texmf-dist/tex/latex/siunitx/siunitx-abbreviations.cfg
File: siunitx-abbreviations.cfg 2017/11/26 v2.7k siunitx: Abbreviated units
)
LaTeX Font Info: External font `cmex10' loaded for size
(Font) <7> on input line 7.
LaTeX Font Info: External font `cmex10' loaded for size
(Font) <5> on input line 7.
[1
{/usr/local/texlive/2020/texmf-var/fonts/map/pdftex/updmap/pdftex.map}] (/compi
le/output.aux)
*File List*
article.cls 2019/12/20 v1.4l Standard LaTeX document class
size10.clo 2019/12/20 v1.4l Standard LaTeX file (size option)
siunitx.sty 2020/02/25 v2.8b A comprehensive (SI) units package
expl3.sty 2020-07-17 L3 programming layer (loader)
l3backend-pdfmode.def 2020-06-29 L3 backend support: PDF mode
xparse.sty 2020-05-15 L3 Experimental document command parser
xparse-generic.tex
amstext.sty 2000/06/29 v2.01 AMS text
amsgen.sty 1999/11/30 v2.0 generic functions
array.sty 2019/08/31 v2.4l Tabular extension package (FMi)
l3keys2e.sty 2020-05-15 LaTeX2e option processing using LaTeX3 keys
translator.sty 2019-05-31 v1.12a Easy translation of strings in LaTeX
keyval.sty 2014/10/28 v1.15 key=value parser (DPC)
translator-basic-dictionary-English.dict
siunitx-abbreviations.cfg 2017/11/26 v2.7k siunitx: Abbreviated units
***********
)
Here is how much of TeX's memory you used:
3239 strings out of 480906
87402 string characters out of 5908280
306653 words of memory out of 5000000
18870 multiletter control sequences out of 15000+600000
536497 words of font info for 35 fonts, out of 8000000 for 9000
1141 hyphenation exceptions out of 8191
38i,4n,46p,229b,768s stack positions out of 5000i,500n,10000p,200000b,80000s
</usr/local/texlive/2020/texmf-dist/fonts/type1/public/amsfonts/cm/cmr10.pfb>
Output written on /compile/output.pdf (1 page, 11105 bytes).
PDF statistics:
12 PDF objects out of 1000 (max. 8388607)
7 compressed objects within 1 object stream
0 named destinations out of 1000 (max. 500000)
1 words of extra memory for PDF output out of 10000 (max. 10000000)
答案1
对于 v2,您将需要强制重置数学模式字体:v3 不需要这样做,因为它有更好的打印方法。
\documentclass{article}
\usepackage{siunitx}[=v2]
\listfiles
\begin{document}
\SI[parse-numbers = false]{\text{\ensuremath{a}}}{\cm}
\end{document}
这也将在 v3 中起作用,但它有点过度:你不需要构造\text{\ensuremath{...}}
。