OSDN Git Service

fix #46244
[luatex-ja/luatexja.git] / src / patches / lltjp-siunitx.sty
1 %
2 % lltjp-siunitx.sty 2022-12-12
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 \AtBeginDocument{
38     \cs_if_exist:NT \TblrNum
39     { \RenewDocumentCommand \TblrNum { m }
40       {
41         \__tblr_siunitx_process:Nn
42           { \cs_set_eq:NN \__siunitx_table_collect_begin:w
43                           \ltj_orig__siunitx_table_collect_begin:w
44             \tablenum}
45           {#1}
46       }
47     }
48   }
49 }% siunitx v3.00 end
50 {% siunitx v2.xx
51 \cs_generate_variant:Nn \tl_if_in:NnT { coT }
52 \cs_new:Nn \__ltj_siunix_patch_inner:n {
53   \cs_if_exist:cT { #1_tl } {
54     \tl_if_in:coT { #1_tl } { \tex_char:D } {
55           \tl_replace_all:cnn { #1_tl } { \tex_char:D } { \ltjalchar }
56         }
57   }
58 }
59 \cs_new:Nn \__ltj_siunix_patch_inner_math:n {
60    \__ltj_siunix_patch_inner:n { l__siunitx_#1_math }
61    \__ltj_siunix_patch_inner:n { l__siunitx_#1_text }
62 }
63 \AtBeginDocument {
64   \__ltj_siunix_patch_inner:n { c__siunitx_minus }
65   \__ltj_siunix_patch_inner:n { c__siunitx_mu }
66   \__ltj_siunix_patch_inner_math:n { angstrom }
67   \__ltj_siunix_patch_inner_math:n { arcminute }
68   \__ltj_siunix_patch_inner_math:n { arcsecond }
69   \__ltj_siunix_patch_inner_math:n { ohm }
70 }
71
72 %%%% new table column: S and s
73 \bool_new:N \l__ltj_siunitx_table_collect_relax_bool
74 \cs_set_protected:Npn \__siunitx_table_collect_begin_s: {
75   \bool_set_false:N \l__ltj_siunitx_table_collect_relax_bool
76   \cs_set_eq:NN \__siunitx_table_collect_token:N
77     \__siunitx_table_collect_token_s:N
78   \cs_set_eq:NN \__siunitx_table_print: \__siunitx_table_print_s:
79   \__siunitx_table_collect_init_s:
80   \__siunitx_table_collect_get:
81 }
82
83 \cs_set_protected:Npn \__siunitx_table_collect_not_braced:N #1
84   {
85         \token_if_eq_meaning:NNTF #1 \tex_relax:D {
86       \bool_if:NTF \l__ltj_siunitx_table_collect_relax_bool {
87                 \__siunitx_table_collect_not_braced_aux_i:N #1
88           } {
89             \bool_set_true:N \l__ltj_siunitx_table_collect_relax_bool
90           }
91         } {
92     \token_if_eq_meaning:NNF #1 \ltjfakeboxbdd {
93     \token_if_eq_meaning:NNF #1 \pltx@next@inhibitglue {
94     \token_if_eq_meaning:NNF #1 \tex_ignorespaces:D
95       {
96         \token_if_eq_meaning:NNF #1 \tex_unskip:D
97           { \__siunitx_table_collect_not_braced_aux_i:N #1 }
98       }
99         }}}
100     \__siunitx_table_collect_next:
101   }
102
103 \AtBeginDocument
104   {
105     \@ifpackageloaded { mdwtab }
106       {
107         \cs_set_protected:Npn \__siunitx_table_collect_not_braced:N #1
108           { 
109                 \token_if_eq_meaning:NNTF #1 \tex_relax:D {
110               \bool_if:NTF \l__ltj_siunitx_table_collect_relax_bool {
111                         \__siunitx_table_collect_not_braced_aux_i:N #1
112                   } {
113                     \bool_set_true:N \l__ltj_siunitx_table_collect_relax_bool
114                   }
115                 } {
116             \token_if_eq_meaning:NNF #1 \ltjfakeboxbdd {
117             \token_if_eq_meaning:NNF #1 \pltx@next@inhibitglue {
118             \token_if_eq_meaning:NNF #1 \tex_ignorespaces:D
119               {
120                 \token_if_eq_meaning:NNF #1 \tex_unskip:D
121                   {
122                     \token_if_eq_meaning:NNF #1 \tab@setcr
123                       {
124                         \token_if_eq_meaning:NNF #1 \@maybe@unskip
125                           { \__siunitx_table_collect_not_braced_aux_i:N #1 }
126                       }
127                   }
128               }
129             }}}
130             \__siunitx_table_collect_next:
131           }
132       }
133       { }
134   }
135 }
136 \ExplSyntaxOff
137 \endinput