Debian Codegraph @

texmf-dist/tex/latex/lwarp/lwarp-siunitx-v2.sty

raw
1 %%
2 %% This is file `lwarp-siunitx-v2.sty',
3 %% generated with the docstrip utility.
4 %%
5 %% The original source files were:
6 %%
7 %% lwarp.dtx (with options: `siunitx-v2')
8 %% This is a generated file.
9 %% Copyright 2016-2026 Brian Dunn
10 %%
11 %% This work may be distributed and/or modified under the
12 %% conditions of the LaTeX Project Public License, either version 1.3
13 %% of this license or (at your option) any later version.
14 %% The latest version of this license is in
15 %% http://www.latex-project.org/lppl.txt
16 %% and version 1.3 or later is part of all distributions of LaTeX
17 %% version 2005/12/01 or later.
18
19 \RequirePackage{xcolor}% for \convertcolorspec
20
21 \LWR@ProvidesPackagePass{siunitx}[=v2]% 2021-04-17
22
23 \AtBeginDocument{% in case textcomp was not loaded
24 \DeclareSIUnit\bohr{\textit{a}\textsubscript{0}}
25 \DeclareSIUnit\clight{\textit{c}\textsubscript{0}}
26 \DeclareSIUnit\elementarycharge{\textit{e}}
27 \DeclareSIUnit\electronmass{\textit{m}\textsubscript{e}}
28 \DeclareSIUnit\hartree{\textit{E}\textsubscript{h}}
29 \DeclareSIUnit\planckbar{\LWR@siunitx@textplanckbar}
30 }% AtBeginDocument
31
32 \AtBeginDocument{
33 \HTMLnewcolumntype{S}[1][]{>{\begingroup\sisetup{#1}}c<{\endgroup}}
34 \HTMLnewcolumntype{s}[1][]{>{\begingroup\sisetup{#1}}c<{\endgroup}}
35 }
36
37
38 \ExplSyntaxOn
39 \AtBeginDocument{
40 \cs_set_protected:Npn \__siunitx_print_text:
41 {
42 \LetLtxMacro\@ensuredmath\LWR@origensuredmath% lwarp
43 \tl_replace_all:Nnn \l__siunitx_print_arg_tl { - }
44 { \textminus }
45 \__siunitx_print_text_aux:
46 \tl_replace_all:Nnn \l__siunitx_print_arg_tl { \mp }
47 { \ensuremath { \mp } }
48 \tl_remove_all:Nn \l__siunitx_print_arg_tl { \mathord }
49 \cs_set_eq:NN \PrintSubscript \__siunitx_print_text_sub:n
50 \cs_set_eq:NN \PrintSuperscript \__siunitx_print_text_super:n
51 \__siunitx_print_text_aux:NnN
52 _ { math_subscript } \__siunitx_print_text_sub:n
53 _ { active } \__siunitx_print_text_sub:n
54 ^ { math_superscript } \__siunitx_print_text_super:n
55 ^ { active } \__siunitx_print_text_super:n
56 \q_recursion_tail ? ?
57 \q_recursion_stop
58 \l__siunitx_print_arg_tl
59 }
60 }
61 \cs_new_protected:Npn \LWR@HTML@__siunitx_print_aux:
62 {
63 \text
64 {
65 \__siunitx_ensure_ltr:n
66 {
67 \color@begingroup
68 \__siunitx_print_color:
69 \__siunitx_font_shape:
70 \__siunitx_font_weight:
71 \use:c
72 {
73 __siunitx_ \l__siunitx_print_type_tl _
74 text \l__siunitx_font_family_tl :
75 }
76 {
77 \LWR@findcurrenttextcolor% lwarp
78 \ifdefstring{\LWR@tempcolor}{000000}% lwarp
79 {\__siunitx_print_text:}% lwarp
80 {% lwarp
81 \LWR@textcurrentcolor{% lwarp
82 \__siunitx_print_text:
83 }% lwarp
84 }% lwarp
85 }
86 \color@endgroup
87 }
88 }
89 }
90 \LWR@formatted{__siunitx_print_aux:}
91
92 \cs_new_protected:Npn \LWR@HTML@__siunitx_set_math_fam:n #1 {
93 \group_begin:
94 \ensuremath
95 {
96 \use:c { math #1 }
97 {
98 \int_const:cn { c__siunitx_math #1 _int } { \fam }
99 }
100 }
101 \group_end:
102 }
103 \LWR@formatted{__siunitx_set_math_fam:n}
104
105 \cs_new_protected:Npn \LWR@HTML@__siunitx_combined_output:n #1 {
106 \group_begin:% lwarp
107 \bool_if:NTF \l__siunitx_number_parse_bool
108 {
109 \tl_clear:N \l__siunitx_number_out_tl
110 \bool_set_false:N \l__siunitx_number_compound_bool
111 \__siunitx_number_output_parse:n {#1}
112 }
113 {
114 \__siunitx_unit_output_pre_print:
115 \begingroup% lwarp
116 \boolfalse{mathjax}% lwarp
117 \LWR@subsingledollar% lwarp
118 {% alt text
119 \textbackslash( % space
120 \LWR@HTMLsanitizedetokenized{%
121 \detokenize{#1}%
122 } \textbackslash)% lwarp
123 }
124 {siunitx}% addl hashing
125 {%
126 \__siunitx_print:nn { number } {%
127 \LWR@origensuredmath{#1}%
128 }%
129 }% lwarp
130 \endgroup% lwarp
131 \__siunitx_unit_output_print:
132 }
133 \group_end:% lwarp
134 }
135 \LWR@formatted{__siunitx_combined_output:n}
136 \cs_new_protected:Npn \LWR@HTML@__siunitx_range_numbers_aux:n #1
137 {
138 \bool_if:NTF \l__siunitx_number_parse_bool
139 {
140 \tl_clear:N \l__siunitx_number_out_tl
141 \tl_clear:N \l__siunitx_number_out_saved_tl
142 \bool_set_false:N \l__siunitx_number_compound_bool
143 \__siunitx_number_output_parse:n {#1}
144 \bool_if:NT \l__siunitx_number_compound_bool
145 { \msg_error:nnx { siunitx } { multi-part-range } {#1} }
146 }
147 {
148 \__siunitx_unit_output_pre_print:
149 \begingroup% lwarp
150 \boolfalse{mathjax}% lwarp
151 \LWR@subsingledollar% lwarp
152 {% alt text
153 \textbackslash( % space
154 \LWR@HTMLsanitizedetokenized{%
155 \detokenize{#1}%
156 } \textbackslash)% lwarp
157 }%
158 {siunitx}% addl hashing
159 {%
160 \__siunitx_print:nn { number } {%
161 \LWR@origensuredmath{#1}%
162 } % lwarp
163 }% lwarp
164 \endgroup% lwarp
165 \__siunitx_unit_output_print:
166 }
167 }
168 \LWR@formatted{__siunitx_range_numbers_aux:n}
169 \cs_new_protected:Npn \LWR@HTML@__siunitx_angle_print_direct_aux:nn #1#2 {
170 \tl_if_empty:nF {#1}
171 {
172 \tl_set:Nn \l__siunitx_unit_tl {#2}
173 \begingroup% lwarp
174 \boolfalse{mathjax}% lwarp
175 \LWR@subsingledollar{% lwarp
176 \textbackslash( % space
177 \LWR@HTMLsanitizedetokenized{%
178 \detokenize{#1}%
179 } \textbackslash)% lwarp
180 }%
181 {siunitx}%
182 {%
183 \__siunitx_print:nn { number } {
184 \LWR@origensuredmath{#1}%
185 }% lwarp
186 }% lwarp
187 \endgroup% lwarp
188 \__siunitx_unit_output_print:
189 }
190 }
191 \LWR@formatted{__siunitx_angle_print_direct_aux:nn}
192 \cs_new_protected:Npn \LWR@HTML@__siunitx_number_output_quotient_fraction: {
193 \bool_set_true:N \l__siunitx_number_compound_bool
194 \__siunitx_number_output_quotient_aux_i:
195 \tl_set_eq:NN \l__siunitx_number_out_tl
196 \l__siunitx_number_numerator_tl
197 \tl_put_right:NV \l__siunitx_number_out_tl \l__siunitx_output_quotient_tl
198 \tl_put_right:NV \l__siunitx_number_out_tl
199 \l__siunitx_number_denominator_tl
200 \__siunitx_number_output_single_aux:
201 }
202 \LWR@formatted{__siunitx_number_output_quotient_fraction:}
203 \cs_new_protected:Npn \LWR@HTML@__siunitx_unit_format_fraction_fraction: {
204 \__siunitx_unit_format_fraction_symbol_aux:
205 \int_compare:nNnT { \l__siunitx_unit_denominator_int } > { 1 }
206 {
207 \bool_if:NT \l__siunitx_unit_denominator_bracket_bool
208 {
209 \tl_put_left:NV \l__siunitx_unit_denominator_tl \l__siunitx_bracket_open_tl
210 \tl_put_right:NV \l__siunitx_unit_denominator_tl \l__siunitx_bracket_close_tl
211 }
212 }
213 \tl_set_eq:NN \l__siunitx_unit_tl \l__siunitx_unit_numerator_tl
214 \tl_put_right:NV \l__siunitx_unit_tl \l__siunitx_per_symbol_tl
215 \tl_put_right:NV \l__siunitx_unit_tl \l__siunitx_unit_denominator_tl
216 }
217 \LWR@formatted{__siunitx_unit_format_fraction_fraction:}
218 \cs_new_protected:Npn \LWR@HTML@__siunitx_angle_print_astronomy_aux: {
219 \prop_get:NnNT \l__siunitx_number_out_prop { mantissa-integer }
220 \l__siunitx_tmpa_tl
221 { \__siunitx_print:nV { number } \l__siunitx_tmpa_tl }
222 \ifnumcomp{\value{LWR@lateximagedepth}}{>}{0}% lwarp
223 {% lateximage
224 \hbox_set:Nn \l__siunitx_angle_marker_box
225 {
226 \__siunitx_print:nn { number } { { \l__siunitx_output_decimal_tl } }
227 }
228 \hbox_set:Nn \l__siunitx_angle_unit_box
229 {
230 \__siunitx_print:nV { unit } \l__siunitx_unit_tl
231 \skip_horizontal:n { -\scriptspace }
232 }
233 \__siunitx_angle_print_astronomy_aux:n { marker }
234 \__siunitx_angle_print_astronomy_aux:n { unit }
235 \hbox_set:Nn \l__siunitx_angle_marker_box
236 {
237 \box_use:N \l__siunitx_angle_marker_box
238 \box_use:N \l__siunitx_angle_unit_box
239 }
240 \dim_compare:nNnTF
241 { \l__siunitx_angle_marker_dim } > { \l__siunitx_angle_unit_dim }
242 { \__siunitx_angle_print_astronomy_marker: }
243 { \__siunitx_angle_print_astronomy_unit: }
244 }% lateximage
245 {% not a lateximage
246 \__siunitx_print:nn { number } { { \l__siunitx_output_decimal_tl } }
247 \__siunitx_print:nV { unit } \l__siunitx_unit_tl
248 }% not a lateximage
249 \prop_get:NnNT \l__siunitx_number_out_prop { mantissa-decimal }
250 \l__siunitx_tmpa_tl
251 { \__siunitx_print:nV { number } \l__siunitx_tmpa_tl }
252 }
253 \LWR@formatted{__siunitx_angle_print_astronomy_aux:}
254 \cs_new_protected:Npn \LWR@HTML@__siunitx_textsuperscript:n #1 {\textsuperscript{#1}}
255 \LWR@formatted{__siunitx_textsuperscript:n}
256
257 \cs_new_eq:NN \LWR@HTML@__siunitx_print_text_super:n \textsuperscript
258 \LWR@formatted{__siunitx_print_text_super:n}
259
260 \cs_new_eq:NN \LWR@HTML@__siunitx_print_text_sub:n \textsubscript
261 \LWR@formatted{__siunitx_print_text_sub:n}
262
263 \cs_new_protected:Npn \LWR@HTML@__siunitx_number_format_final_exponent: {
264 \prop_get:NnN \l__siunitx_number_out_prop { exponent }
265 \l__siunitx_tmpa_tl
266 \tl_if_empty:NTF \l__siunitx_output_exponent_tl
267 {
268 \tl_set:Nx \l__siunitx_tmpa_tl
269 { ^ { \exp_not:V \l__siunitx_tmpa_tl } }
270 \tl_put_left:NV \l__siunitx_tmpa_tl \l__siunitx_exponent_base_tl
271 }
272 {
273 \tl_set:Nx \l__siunitx_tmpa_tl
274 {
275 \LWR@origensuredmath{% lwarp
276 \exp_not:V \l__siunitx_output_exponent_tl
277 }% lwarp
278 \exp_not:N \mathord
279 \exp_not:V \l__siunitx_tmpa_tl
280 }
281 }
282 \prop_put:NnV \l__siunitx_number_out_prop { exponent-result }
283 \l__siunitx_tmpa_tl
284 }
285 \LWR@formatted{__siunitx_number_format_final_exponent:}
286
287 \cs_new_protected:Npn \LWR@HTML@__siunitx_number_format_final_combined: {
288 \__siunitx_number_format_brackets:n { mantissa }
289 \prop_get:NnN \l__siunitx_number_out_prop { mantissa-result }
290 \l__siunitx_tmpa_tl
291 \tl_if_empty:NT \l__siunitx_output_exponent_tl
292 {
293 \tl_put_right:Nx \l__siunitx_tmpa_tl
294 {
295 \exp_not:N \LWR@origensuredmath% lwarp
296 {
297 \bool_if:NTF \l__siunitx_tight_bool
298 { { \exp_not:V \l__siunitx_exponent_product_tl } }
299 { { } \exp_not:V \l__siunitx_exponent_product_tl { } }
300 }
301 }
302 }
303 \prop_get:NnN \l__siunitx_number_out_prop { exponent-result }
304 \l__siunitx_tmpb_tl
305 \tl_put_right:NV \l__siunitx_tmpa_tl \l__siunitx_tmpb_tl
306 \prop_put:NnV \l__siunitx_number_out_prop { result }
307 \l__siunitx_tmpa_tl
308 \prop_put:Nnn \l__siunitx_number_out_prop
309 { result-bracket-exponent } { true }
310 }
311 \LWR@formatted{__siunitx_number_format_final_combined:}
312
313 \cs_new_protected:Npn \LWR@HTML@__siunitx_number_output_parts_aux: {
314 \bool_if:NTF \l__siunitx_multi_repeat_bool
315 {
316 \prop_if_in:NnT \l__siunitx_number_out_prop { mantissa-result }
317 {
318 \__siunitx_number_output_parts_aux:n { mantissa }
319 \__siunitx_number_output_parts_aux:n { complex }
320 }
321 \prop_get:NnNT \l__siunitx_number_out_prop { exponent-result }
322 \l__siunitx_tmpa_tl
323 {
324 \prop_if_in:NnT \l__siunitx_number_out_prop { mantissa-result }
325 {
326 \tl_put_left:Nx \l__siunitx_tmpa_tl
327 {
328 \exp_not:N \LWR@origensuredmath
329 {
330 \bool_if:NTF \l__siunitx_tight_bool
331 { { \exp_not:V \l__siunitx_exponent_product_tl } }
332 { { } \exp_not:V \l__siunitx_exponent_product_tl { } }
333 }
334 }
335 \prop_put:NnV \l__siunitx_number_out_prop { exponent }
336 \l__siunitx_tmpa_tl
337 }
338 \__siunitx_number_output_parts_print:n { exponent }
339 }
340 }
341 { \__siunitx_number_output_single: }
342 }
343 \LWR@formatted{__siunitx_number_output_parts_aux:}
344
345 \cs_new_protected:Npn \LWR@HTML@__siunitx_unit_output_print: {
346 \int_compare:nNnF { \l__siunitx_unit_prefix_int } = { 0 }
347 {
348 \tl_set:Nx \l__siunitx_tmpa_tl
349 {
350 \bool_if:NTF \l__siunitx_tight_bool
351 {
352 \exp_not:N \LWR@origensuredmath% lwarp
353 { { \exp_not:V \l__siunitx_exponent_product_tl } }
354 }
355 {
356 \exp_not:N \LWR@origensuredmath% lwarp
357 { { } \exp_not:V \l__siunitx_exponent_product_tl { } }
358 }
359 \int_use:N \l__siunitx_unit_prefix_base_int
360 ^ { \int_use:N \l__siunitx_unit_prefix_int }
361 }
362 \__siunitx_print:nV { number } \l__siunitx_tmpa_tl
363 }
364 \tl_if_empty:NF \l__siunitx_unit_tl
365 {
366 \__siunitx_unit_output_number_sep:
367 \__siunitx_print:nV { unit } \l__siunitx_unit_tl
368 }
369 }
370 \LWR@formatted{__siunitx_unit_output_print:}
371
372 \cs_new_protected:Npn \LWR@HTML@__siunitx_range_exponent:
373 {
374 \bool_if:NT \l__siunitx_process_fixed_bool
375 {
376 \tl_set_eq:NN \l__siunitx_tmpa_tl \l__siunitx_exponent_product_tl
377 \bool_if:NT \l__siunitx_tight_bool
378 {
379 \tl_set:Nx \l__siunitx_tmpa_tl
380 { \exp_not:N \mathord \exp_not:o \l__siunitx_tmpa_tl }
381 }
382 \tl_set:Nx \l__siunitx_tmpa_tl
383 {
384 \exp_not:N \LWR@origensuredmath {% lwarp
385 { } \exp_not:o \l__siunitx_tmpa_tl { }
386 }
387 10 \exp_not:N \PrintSuperscript
388 { \int_use:N \l__siunitx_process_fixed_int }
389 }
390 \__siunitx_print:nV { number } \l__siunitx_tmpa_tl
391 }
392 }
393 \LWR@formatted{__siunitx_range_exponent:}
394
395 \cs_new_protected:Npn \LWR@HTML@__siunitx_table_print_S_reserved_exponent_product:
396 {
397 \tl_set_eq:NN \l__siunitx_tmpb_tl \l__siunitx_exponent_product_tl
398 \bool_if:NT \l__siunitx_tight_bool
399 {
400 \tl_set:Nx \l__siunitx_tmpb_tl
401 { \exp_not:N \mathord \exp_not:o \l__siunitx_tmpb_tl }
402 }
403 \tl_set:Nx \l__siunitx_tmpa_tl
404 {
405 \exp_not:N \LWR@origensuredmath { { } \exp_not:o \l__siunitx_tmpb_tl { } }
406 \exp_not:o \l__siunitx_tmpa_tl
407 }
408 }
409 \LWR@formatted{__siunitx_table_print_S_reserved_exponent_product:}
410
411 \cs_new_protected:Npn \LWR@HTML@__siunitx_number_output_product_aux: {
412 \bool_set_true:N \l__siunitx_number_compound_bool
413 \__siunitx_number_preprocess:V \l__siunitx_number_arg_tl
414 \bool_if:NF \l__siunitx_error_bool
415 {
416 \tl_if_empty:NTF \l__siunitx_number_multi_tl
417 { \__siunitx_number_output_parse_aux: }
418 { \__siunitx_number_output_quotient: }
419 \tl_if_empty:NF \l__siunitx_number_next_tl
420 {
421 \bool_if:NTF \l__siunitx_tight_bool
422 {
423 \__siunitx_print:nn { number }
424 { \LWR@origensuredmath { \l__siunitx_output_product_tl } }
425 }
426 {
427 \__siunitx_print:nn { number }
428 { \LWR@origensuredmath { { } \l__siunitx_output_product_tl { } } }
429 }
430 \__siunitx_number_output_parse:V \l__siunitx_number_next_tl
431 }
432 }
433 }
434 \LWR@formatted{__siunitx_number_output_product_aux:}
435
436 \cs_set_protected:Npn \__siunitx_set_math_fam:n #1 {
437 \group_begin:
438 \hbox_set:Nn \l__siunitx_tmp_box
439 {
440 \LWR@origensuredmath% lwarp
441 {
442 \use:c { math #1 }
443 {
444 \int_const:cn { c__siunitx_math #1 _int } { \fam }
445 }
446 }
447 }
448 \group_end:
449 }
450
451 \cs_set_protected:Npn \__siunitx_range_numbers:nn #1#2
452 {
453 \__siunitx_range_numbers_aux:n {#1}
454 \text{\l__siunitx_range_phrase_tl}% lwarp
455 \__siunitx_range_numbers_aux:n {#2}
456 }
457
458 \cs_set_protected:Npn \__siunitx_range_unit:nnnn #1#2#3#4 {
459 \__siunitx_unit_parse_options:nn {#1} {#2}
460 \bool_if:NTF \l__siunitx_range_repeat_bool
461 {
462 \__siunitx_unit_in:nn {#1} {#2}
463 \__siunitx_range_numbers_aux:n {#3}
464 \text{\l__siunitx_range_phrase_tl}% lwarp
465 \__siunitx_range_numbers_aux:n {#4}
466 }
467 {
468 \bool_if:NT \l__siunitx_process_fixed_bool
469 { \bool_set_true:N \l__siunitx_process_drop_exponent_bool }
470 \bool_if:NT \l__siunitx_range_brackets_bool
471 { \__siunitx_print:nV { number } \l__siunitx_bracket_open_tl }
472 \__siunitx_range_numbers:nn {#3} {#4}
473 \bool_if:NT \l__siunitx_range_brackets_bool
474 { \__siunitx_print:nV { number } \l__siunitx_bracket_close_tl }
475 \__siunitx_range_exponent:
476 \__siunitx_unit_output_number_sep:
477 \__siunitx_unit_output:nn {#1} {#2}
478 }
479 }
480
481 \ExplSyntaxOff
482
483 \AtBeginDocument{
484 \sisetup{
485 detect-mode=true,
486 per-mode=symbol, % fraction is not seen by pdftotext
487 text-celsius = {\LWR@siunitx@textcelsius},
488 text-degree = {\LWR@siunitx@textdegree},
489 text-arcminute = {\LWR@siunitx@textprime} ,
490 text-arcsecond = {\LWR@siunitx@textdblprime} ,
491 }
492 }
493
494 \LWR@origRequirePackage{lwarp-common-mathjax-siunitx}
495
496 \AtBeginDocument{
497 \CustomizeMathJax{\def\LWRsiunitxrangephrase{\unicode{x2013}}}
498 }
499
500
501 \endinput
502 %%
503 %% End of file `lwarp-siunitx-v2.sty'.