Last active
July 11, 2020 13:03
-
-
Save k16shikano/4414bb5f5fe473e6a11fe80da36babd3 to your computer and use it in GitHub Desktop.
スペース区切りでモノルビ指定
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% https://oku.edu.mie-u.ac.jp/tex/mod/forum/discuss.php?d=2899&parent=16984 | |
\documentclass[uplatex]{jsarticle} | |
\usepackage{xparse} | |
\usepackage{okumacro} | |
\ExplSyntaxOn | |
\seq_new:N \l__body_seq | |
\seq_new:N \l__ruby_seq | |
\cs_new_protected:Npn \xx_set_tl:nn #1 #2 { | |
\seq_set_split:Nnn \l__body_seq { ~ } { #1 } | |
\seq_set_split:Nnn \l__ruby_seq { ~ } { #2 } | |
\xx_do_recur:n {} | |
} | |
\cs_new:Nn \xx_do_recur:n { | |
\seq_pop_left:NN \l__body_seq \l_tempa_tl | |
\seq_pop_left:NN \l__ruby_seq \l_tempb_tl | |
\quark_if_no_value:NTF \l_tempa_tl | |
{ \quark_if_no_value:NTF \l_tempb_tl | |
{ } | |
{ \ruby {\tl_use:N \l_tempb_tl / \seq_use:Nn \l__ruby_seq { / } } } } | |
{ \quark_if_no_value:NTF \l_tempb_tl | |
{ \tl_use:N \l_tempa_tl / \seq_use:Nn \l__body_seq { / } } | |
{ \ruby{ \tl_use:N \l_tempa_tl }{ \tl_use:N \l_tempb_tl } / \xx_do_recur:n {} } } | |
} | |
\makeatletter | |
\NewDocumentCommand{\spacedruby}{m m}{% | |
\xx_set_tl:nn { #1 } { #2 } | |
} | |
\makeatother | |
\ExplSyntaxOff | |
\begin{document} | |
\spacedruby{明 朝 体}{み ん ちょうたい} | |
\end{document} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment