diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/CJK/ruby.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/CJK/ruby.sty | 154 |
1 files changed, 154 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/CJK/ruby.sty b/Master/texmf-dist/tex/latex/CJK/ruby.sty new file mode 100644 index 00000000000..980855fbe85 --- /dev/null +++ b/Master/texmf-dist/tex/latex/CJK/ruby.sty @@ -0,0 +1,154 @@ +% This is the file ruby.sty of the CJK package +% for displaying ruby (i.e. furigana). +% +% created by Werner Lemberg <wl@gnu.org> +% +% Version 4.6.0 (11-Aug-2005) + +\NeedsTeXFormat{LaTeX2e}[1995/06/01] +\def\fileversion{4.6.0} +\def\filedate{2005/08/11} +\ProvidesPackage{ruby}[\filedate\space\fileversion] + + +\RequirePackage{CJK}[1996/11/20] + +\newif\ifruby@overlap@ +\newif\ifruby@CJK@ + +\DeclareOption{overlap}{\ruby@overlap@true} +\DeclareOption{nooverlap}{\ruby@overlap@false} +\DeclareOption{CJK}{\ruby@CJK@true} +\DeclareOption{latin}{\ruby@CJK@false} + +\ExecuteOptions{overlap, CJK} + +\ProcessOptions + + +% we suppress any unwanted spaces produced by linefeeds. + +\endlinechar \m@ne + +% to get a small separation between adjacent lines. + +\lineskiplimit 1pt + + +\newdimen\ruby@width +\edef\ruby@kern{\kern -5sp\kern 5sp} + +\newcommand{\rubysize}{0.4} +\newcommand{\rubysep}{-0.5ex} +\newcommand{\rubyoverlap}{\ruby@overlap@true} +\newcommand{\rubynooverlap}{\ruby@overlap@false} +\newcommand{\rubyCJK}{\ruby@CJK@true} +\newcommand{\rubylatin}{\ruby@CJK@false} + + +% #1 is the base character; #2 is the ruby. + +\DeclareRobustCommand{\ruby}[2]{ + {\@tempdimc \f@size\p@ + \@tempdimc \rubysize\@tempdimc + \sbox\z@{\vrule\@height.7\baselineskip\@depth\z@\@width\z@ #1} + \sbox\@tempboxa{\fontsize{\@tempdimc}{1.2\@tempdimc}\selectfont + \vrule\@height\z@\@depth.3\baselineskip\@width\z@ #2} + + \@tempdimb\ruby@width + + \global\ruby@width \wd\@tempboxa + \global\advance\ruby@width -\wd\z@ + \global\divide\ruby@width \tw@ + \ifdim\ruby@width > \z@ + \else + \global\ruby@width \z@ + \fi + + % we first compute the box of the ruby with its base character(s). + \ifruby@overlap@ + \setbox\@tempboxa \vbox{ + \hbox to \wd0{\hss \box\@tempboxa \hss} + \nointerlineskip + \kern\rubysep + \box\z@} + \else + \ifdim\ruby@width > \z@ + \@tempdima \wd\@tempboxa + \else + \@tempdima \wd\z@ + \fi + \setbox\@tempboxa \vbox{ + \hbox to \@tempdima{\hss \box\@tempboxa \hss} + \nointerlineskip + \kern\rubysep + \hbox to \@tempdima{\hss \box\z@ \hss}} + \fi + + % are we at the beginning of a paragraph? + \ifvmode + \leavevmode + \ifruby@overlap@ + \kern\ruby@width + \fi + \else + + % has previous character a ruby? + \ifnum\lastkern = 5% \ruby@kern + \kern\@tempdimb + \ifruby@CJK@ + \nobreak + \CJKglue + \nobreak + \fi + \ifruby@overlap@ + \kern\ruby@width + \fi + \else + + \ifruby@CJK@ + + % is previous character an ordinary CJK character? + \ifnum\lastkern = \@ne% \CJK@CJK + \ifdim\ruby@width > \z@ + \nobreak + \CJKglue + \nobreak + \else + \CJKglue + \fi + \else + + % is previous character a punctuation character? + \ifnum\lastkern = \tw@% \CJK@kern + \nobreak + \CJKglue + \nobreak + \fi + \fi + \fi + \fi + \fi + + \box\@tempboxa + + \ruby@kern + \ifdim\ruby@width > \z@ + \ifruby@overlap@ + \else + \global\ruby@width\z@ + \fi + \else + \global\ruby@width\z@ + \fi} + + \ifruby@CJK@ + \ignorespaces + \fi} + + +% reset endline character. + +\endlinechar `\^^M + +\endinput |