Skip to content

Instantly share code, notes, and snippets.

@zr-tex8r
Created July 11, 2020 13:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zr-tex8r/681b30cacbcc80180272750a6d984435 to your computer and use it in GitHub Desktop.
Save zr-tex8r/681b30cacbcc80180272750a6d984435 to your computer and use it in GitHub Desktop.
expl3:スペース区切りでモノルビ指定
% https://oku.edu.mie-u.ac.jp/tex/mod/forum/discuss.php?d=2899&parent=16984
\documentclass[uplatex]{jsarticle}
\usepackage{xparse}
\usepackage{okumacro}
\ExplSyntaxOn %!!!!!!!!!!!!!!!!!!!!!!!! expl3 code BEGIN
\seq_new:N \l__sruby_body_seq
\seq_new:N \l__sruby_ruby_seq
\cs_new_protected:Nn \__sruby_do:nn
{
\seq_set_split:Nnn \l__sruby_body_seq { ~ } {#1}
\seq_set_split:Nnn \l__sruby_ruby_seq { ~ } {#2}
\int_step_inline:nn { \seq_count:N \l__sruby_body_seq }
{
\ruby
{ \seq_item:Nn \l__sruby_body_seq { ##1 } }
{ \seq_item:Nn \l__sruby_ruby_seq { ##1 } }
}
}
\NewDocumentCommand \spacedruby { m m }
{ \__sruby_do:nn {#1} {#2} }
\ExplSyntaxOff %!!!!!!!!!!!!!!!!!!!!!!!! expl3 code END
\begin{document}
\spacedruby{明 朝 体}{みん ちょう たい}
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment