OSDN Git Service

patch for siunitx
authorHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Sun, 20 May 2018 04:21:17 +0000 (13:21 +0900)
committerHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Sun, 20 May 2018 04:21:17 +0000 (13:21 +0900)
src/ltj-latex.sty
src/patches/lltjp-siunitx.sty [new file with mode: 0644]
test/test26-siunitx.tex [new file with mode: 0644]

index 0176d44..981a95a 100644 (file)
   % \RequirePackage だと fontspec にオプション指定したときにエラー出る
 }
 
+\@ifpackageloaded{siunitx}{%
+  \chardef\ltj@patch@siunitx@execute\z@\input{lltjp-siunitx.sty}%
+}{%
+  \AtBeginOfPackageFile*{siunitx}{\input{lltjp-siunitx.sty}}%
+}
+\AtEndOfPackageFile*{siunitx}{\csname __ltj_siunitx_patch:\endcsname}
 
 %%------------------ all done
 \ltj@latex@AtEnd
diff --git a/src/patches/lltjp-siunitx.sty b/src/patches/lltjp-siunitx.sty
new file mode 100644 (file)
index 0000000..738760c
--- /dev/null
@@ -0,0 +1,34 @@
+%
+% lltjp-siunitx.sty
+%
+
+\NeedsTeXFormat{LaTeX2e}
+
+\RequirePackage{luatexja}
+\ExplSyntaxOn
+\cs_generate_variant:Nn \tl_if_in:NnT { coT }
+\cs_new:Nn \__ltj_siunix_patch_inner:n {
+  \cs_if_exist:cT { #1_tl } {
+    \tl_if_in:coT { #1_tl } { \tex_char:D } {
+         \tl_replace_all:cnn { #1_tl } { \tex_char:D } { \ltjalchar }
+       }
+  }
+}
+\cs_new:Nn \__ltj_siunix_patch_inner_math:n {
+   \__ltj_siunix_patch_inner:n { l__siunitx_#1_math }
+   \__ltj_siunix_patch_inner:n { l__siunitx_#1_text }
+}
+\cs_new:Nn \__ltj_siunitx_patch: {
+  \AtBeginDocument {
+    \__ltj_siunix_patch_inner:n { c__siunitx_minus }
+    \__ltj_siunix_patch_inner:n { c__siunitx_mu }
+    \__ltj_siunix_patch_inner_math:n { angstrom }
+    \__ltj_siunix_patch_inner_math:n { arcminute }
+    \__ltj_siunix_patch_inner_math:n { arcsecond }
+    \__ltj_siunix_patch_inner_math:n { ohm }
+  }
+}
+\ifdefined\ltj@patch@siunitx@executed\__ltj_siunitx_patch:\fi
+
+\ExplSyntaxOff
+\endinput
diff --git a/test/test26-siunitx.tex b/test/test26-siunitx.tex
new file mode 100644 (file)
index 0000000..07a6ca4
--- /dev/null
@@ -0,0 +1,19 @@
+\documentclass{scrbook}
+  %\usepackage{luatexja}
+  \usepackage{fontspec}
+  \usepackage{luatexja-fontspec}
+  \usepackage[
+    mode=text,
+    detect-all,
+]{siunitx}
+  %\usepackage{luatexja-fontspec}
+\makeatletter
+\typeout{\meaning\@begindocumenthook}
+\begin{document}
+  \ifdefined\gtfamily\gtfamily\fi Ω
+  {\ExplSyntaxOn\makeatletter
+   \ttfamily\meaning\@begindocumenthook}
+  
+  \SI{-2.5e-10}{mol.L^{-1}}\SI{1}{\micro\metre\angstrom\arcminute\arcsecond\ohm}
+  \vrule\SI{}{\ohm}\vrule
+  \end{document}
\ No newline at end of file