OSDN Git Service

Releases 20240514.0
[luatex-ja/luatexja.git] / src / patches / lltjp-siunitx.sty
1 %
2 % lltjp-siunitx.sty 2022-12-14
3 %
4
5 \NeedsTeXFormat{LaTeX2e}
6
7 \RequirePackage{siunitx}
8 \makeatletter
9 \ExplSyntaxOn
10 \cs_if_exist:NTF \siunitx_print_text:n {% siunitx v3.00
11 \cs_set_protected:Npn \siunitx_print_text:n #1
12   {
13     \text
14       {
15         \ltj@allalchar % <--- LuaTeX-ja
16         \bool_if:NT \l__siunitx_print_text_family_bool
17           {
18             \fontfamily { \familydefault }
19             \selectfont
20           }
21         \bool_if:NT \l__siunitx_print_text_series_bool
22           {
23             \fontseries { \seriesdefault }
24             \selectfont
25           }
26         \bool_if:NT \l__siunitx_print_text_shape_bool
27           {
28             \fontshape { \shapedefault }
29             \selectfont
30           }
31         \__siunitx_print_text_replace:n {#1}
32       }
33   }
34 \cs_set_eq:NN \ltj_orig__siunitx_table_collect_begin:w \__siunitx_table_collect_begin:w
35 \cs_set_protected:Npn \__siunitx_table_collect_begin:w #1 \relax
36   { \ltj_orig__siunitx_table_collect_begin:w }
37 \RenewDocumentCommand \tablenum { O { } m }
38   {
39     \mode_leave_vertical:
40     \group_begin:
41       \keys_set:nn { siunitx } {#1}
42       \siunitx_cell_begin:w
43         \relax \ignorespaces #2
44       \siunitx_cell_end:
45     \group_end:
46   }
47 }% siunitx v3.00 end
48 {% siunitx v2.xx
49 \cs_generate_variant:Nn \tl_if_in:NnT { coT }
50 \cs_new:Nn \__ltj_siunix_patch_inner:n {
51   \cs_if_exist:cT { #1_tl } {
52     \tl_if_in:coT { #1_tl } { \tex_char:D } {
53           \tl_replace_all:cnn { #1_tl } { \tex_char:D } { \ltjalchar }
54         }
55   }
56 }
57 \cs_new:Nn \__ltj_siunix_patch_inner_math:n {
58    \__ltj_siunix_patch_inner:n { l__siunitx_#1_math }
59    \__ltj_siunix_patch_inner:n { l__siunitx_#1_text }
60 }
61 \AtBeginDocument {
62   \__ltj_siunix_patch_inner:n { c__siunitx_minus }
63   \__ltj_siunix_patch_inner:n { c__siunitx_mu }
64   \__ltj_siunix_patch_inner_math:n { angstrom }
65   \__ltj_siunix_patch_inner_math:n { arcminute }
66   \__ltj_siunix_patch_inner_math:n { arcsecond }
67   \__ltj_siunix_patch_inner_math:n { ohm }
68 }
69
70 %%%% new table column: S and s
71 \bool_new:N \l__ltj_siunitx_table_collect_relax_bool
72 \cs_set_protected:Npn \__siunitx_table_collect_begin_s: {
73   \bool_set_false:N \l__ltj_siunitx_table_collect_relax_bool
74   \cs_set_eq:NN \__siunitx_table_collect_token:N
75     \__siunitx_table_collect_token_s:N
76   \cs_set_eq:NN \__siunitx_table_print: \__siunitx_table_print_s:
77   \__siunitx_table_collect_init_s:
78   \__siunitx_table_collect_get:
79 }
80
81 \cs_set_protected:Npn \__siunitx_table_collect_not_braced:N #1
82   {
83         \token_if_eq_meaning:NNTF #1 \tex_relax:D {
84       \bool_if:NTF \l__ltj_siunitx_table_collect_relax_bool {
85                 \__siunitx_table_collect_not_braced_aux_i:N #1
86           } {
87             \bool_set_true:N \l__ltj_siunitx_table_collect_relax_bool
88           }
89         } {
90     \token_if_eq_meaning:NNF #1 \ltjfakeboxbdd {
91     \token_if_eq_meaning:NNF #1 \pltx@next@inhibitglue {
92     \token_if_eq_meaning:NNF #1 \tex_ignorespaces:D
93       {
94         \token_if_eq_meaning:NNF #1 \tex_unskip:D
95           { \__siunitx_table_collect_not_braced_aux_i:N #1 }
96       }
97         }}}
98     \__siunitx_table_collect_next:
99   }
100
101 \AtBeginDocument
102   {
103     \@ifpackageloaded { mdwtab }
104       {
105         \cs_set_protected:Npn \__siunitx_table_collect_not_braced:N #1
106           { 
107                 \token_if_eq_meaning:NNTF #1 \tex_relax:D {
108               \bool_if:NTF \l__ltj_siunitx_table_collect_relax_bool {
109                         \__siunitx_table_collect_not_braced_aux_i:N #1
110                   } {
111                     \bool_set_true:N \l__ltj_siunitx_table_collect_relax_bool
112                   }
113                 } {
114             \token_if_eq_meaning:NNF #1 \ltjfakeboxbdd {
115             \token_if_eq_meaning:NNF #1 \pltx@next@inhibitglue {
116             \token_if_eq_meaning:NNF #1 \tex_ignorespaces:D
117               {
118                 \token_if_eq_meaning:NNF #1 \tex_unskip:D
119                   {
120                     \token_if_eq_meaning:NNF #1 \tab@setcr
121                       {
122                         \token_if_eq_meaning:NNF #1 \@maybe@unskip
123                           { \__siunitx_table_collect_not_braced_aux_i:N #1 }
124                       }
125                   }
126               }
127             }}}
128             \__siunitx_table_collect_next:
129           }
130       }
131       { }
132   }
133 }
134 \ExplSyntaxOff
135 \endinput