\documentclass[luatex,fontsize=8pt,paper=b5,fleqn]{jlreq} \usepackage{hyperref} \usepackage{gckanbun} \usepackage{luwa-ul} \usepackage{caption} \usepackage[most]{tcolorbox} \usepackage{fp} \usepackage{lltjext} \usepackage{luatexja-ruby} \usepackage{KKsymbols} % You can omit these font settings. \RequirePackage[no-math]{fontspec} \RequirePackage[no-math,match,scale=1]{luatexja-fontspec} \RequirePackage[hiragino-pro,deluxe,expert]{luatexja-preset} \setmainfont{HiraMinPro-W3}[BoldFont=HiraMinPro-W6]\setmainjfont{HiraMinPro-W3}[BoldFont=HiraMinPro-W6] \renewfontfamily{\sffamily}{HiraKakuPro-W3}[BoldFont=HiraKakuPro-W6] \renewfontfamily{\mcfamily}{HiraMinPro-W3}[BoldFont=HiraMinPro-W6] \renewfontfamily{\gtfamily}{HiraKakuPro-W3}[BoldFont=HiraKakuPro-W6] \providefontfamily{\mgfamily}{HiraMaruPro-W4} \newfontfamily{\sfhira}{HiraKakuPro-W3}[BoldFont=HiraKakuPro-W6]\newjfontfamily{\sfhiraj}{HiraKakuPro-W3}[BoldFont=HiraKakuPro-W6] \newfontfamily{\mchira}{HiraMinPro-W3}[BoldFont=HiraMinPro-W6]\newjfontfamily{\mchiraj}{HiraMinPro-W3}[BoldFont=HiraMinPro-W6] \newfontfamily{\gthira}{HiraKakuPro-W3}[BoldFont=HiraKakuPro-W6,FontFace={eb}{\shapedefault}{HiraKakuStd-W8}]\newjfontfamily{\gthiraj}{HiraKakuPro-W3}[BoldFont=HiraKakuPro-W6,FontFace={eb}{\shapedefault}{HiraKakuStd-W8}] \newfontfamily{\mghira}{HiraMaruPro-W4}\newjfontfamily{\mghiraj}{HiraMaruPro-W4} \renewcommand{\sffamily}{\sfhira\sfhiraj} \renewcommand{\mcfamily}{\mchira\mchiraj} \renewcommand{\gtfamily}{\gthira\gthiraj} \renewcommand{\mgfamily}{\mghira\mghiraj} %%% \usepackage{listings} \lstset{ basicstyle=\ttfamily\small, keywordstyle=\color{blue}, commentstyle=\color{gray}, stringstyle=\color{red}, breaklines=true, breakatwhitespace=false, columns=flexible } \usepackage{hyperref} \hypersetup{ luatex, pdfencoding=auto, colorlinks=true, linkcolor=black, citecolor=black, urlcolor=DeepSkyBlue3, pdfborder={0 0 0}, } \colorlet{grayLight}{white!80!black} \NewTCBListing{SourceCode}{ m m !o !O{DeepSkyBlue3} }{% enhanced, colback=black!70, colframe=Snow4, toptitle=-1mm, bottomtitle=-1mm, righttitle=-1mm, lefttitle=-1mm, arc=.5mm, title={\tcbox[on line, arc=.5mm, boxsep=0pt, boxrule=0pt, top=1mm, bottom=0.8mm, left=2mm, right=2.2mm, colback=gray!80, coltext=white]{\raisebox{-0.1ex}{\vphantom{羅}\vphantom{j}#1}}},fonttitle=\gtfamily\footnotesize,boxrule=0.8pt, breakable,before upper={\color{white}},top=-0.5mm,bottom=-0.5mm, after title=\IfNoValueTF{#3}{}{{\hfill\tcbox[on line, arc=.5mm, boxsep=0pt, boxrule=0pt, top=1mm, bottom=0.8mm, left=2mm, right=2.2mm, colback=white!80!black, coltext=#4]{\raisebox{-0.1ex}{\vphantom{羅}\vphantom{j}#3}}}}, listing only, listing options={ language={#2}, basicstyle=\ttfamily, keywordstyle=\ttfamily\color{white}, stringstyle=\itshape\color{white}, commentstyle=\small\gtfamily\color{DeepSkyBlue2}, showspaces=false,showtabs=false, breaklines=true,breakindent=0pt, showstringspaces=false, columns=fullflexible, tabsize=2, numbers=left,numbersep=1.5pt, numberstyle=\scriptsize\gtfamily\color{gray}, } } \NewTColorBox{OutPut}{ m !o !O{DeepSkyBlue3} }{% enhanced, colframe=Snow4, toptitle=-1mm, bottomtitle=-1mm, righttitle=-1mm, lefttitle=-1mm, arc=.5mm, colback=white, title={\tcbox[on line, arc=.5mm, boxsep=0pt, boxrule=0pt, top=1mm, bottom=0.8mm, left=2mm, right=2.2mm, colback=gray!40, coltext=DeepSkyBlue3]{\raisebox{-0.1ex}{\vphantom{羅}\vphantom{j}#1}}},fonttitle=\gtfamily\footnotesize,boxrule=0.8pt, breakable,top=-0.5mm,bottom=-0.5mm, after title=\IfNoValueTF{#2}{}{{\hfill\tcbox[on line, arc=.5mm, boxsep=0pt, boxrule=0pt, top=1mm, bottom=0.8mm, left=2mm, right=2.2mm, colback=white!80!black, coltext=#3]{\raisebox{-0.1ex}{\vphantom{羅}\vphantom{j}#2}}}}, bottom=2mm, top=2mm, } \makeatletter \RequirePackage{luatexja} \def\ascb@textgt#1{\textgt{#1}} \def\ascb@gtfamily{\gtfamily} \def\ascb@zw#1#2{#1\zw} \DeclareTColorBox{simple}{ o m O{.5} O{} }% {empty, left=2mm, right=2mm, top=-1mm, attach boxed title to top left={xshift=\ascb@zw{1.2}{11pt}}, boxed title style={empty,left=-2mm,right=-2mm}, colframe=black, coltitle=black, coltext=black, breakable, before upper={\setlength{\parindent}{1em}\relax}, underlay unbroken={\draw[black,line width=#3pt](title.east) -- (title.east-|frame.east) -- (frame.south east) -- (frame.south west) -- (title.west-|frame.west) -- (title.west); }, underlay first={\draw[black,line width=#3pt](title.east) -- (title.east-|frame.east) -- (frame.south east) ; \draw[black,line width=#3pt] (frame.south west) -- (title.west-|frame.west) -- (title.west); }, underlay middle={\draw[black,line width=#3pt](frame.north east) -- (frame.south east) ; \draw[black,line width=#3pt](frame.south west) -- (frame.north west) ;}, underlay last={\draw[black,line width=#3pt](frame.north east) -- (frame.south east) -- (frame.south west) -- (frame.north west) ;}, fonttitle=\ascb@gtfamily, IfValueTF={#1}{title=\hspace*{.1em}【#2】〈#1〉\hspace*{.1em}}{title=\hspace*{.1em}【#2】\hspace*{.1em}},#4} \makeatother \title{\texttt{gckanbun} Package Documentation (Reworked)} \author{% \parbox[r]{8cm}{% Original ver. : Munehiro Yamamoto\\ Modified ver. : Kosei Kawaguchi a.k.a. KKTeX }} \date{Version 2.1.0 (2025/11/12)} \begin{document} \begin{titlepage} \maketitle \end{titlepage} \newpage \tableofcontents \newpage \section{概要} このリワークは、gckanbunパッケージを、日本における漢文組版においてより高い品質を担保できるように改変したものです。オリジナルの作者様である山本宗宏(Munehiro Yamamoto)さんとの協議により、メンテナーを形式上私川口晃世(KKTeX)が引き継ぐこととなりました。 gckanbunパッケージはそのルビや返り点の制御構造において非常に優れていたため、大枠はオリジナルのそれを踏襲し、必要最低限の拡張及び変更にとどめています。また、本パッケージに関する山本さんの記事として、 \begin{quotation} \url{https://qiita.com/munepi/items/5e6ac49fa5c025123305} \end{quotation} \noindent もぜひご参照ください。 \section{変更点} 私は本パッケージを作成するにあたり、既存のgckanbunパッケージを以下を満たすように改変しました。 \begin{itemize} \item[\seihou{1}] \hspace{1em}再読文字に対応するコマンドの提供。 \item[\seihou{2}] \hspace{1em}横書き環境でも正しく動くようにする。 \item[\seihou{3}] \hspace{1em}一レ点などの特別な返り点に対処するためのコマンドを提供する。 \item[\seihou{4}] \hspace{1em}行間に対してルビの「大きさ」が反映されるように変更。(それに伴い、オリジナルで生じていた文字サイズ変更に伴うルビと本文の被りが生じる問題を解消。) \item[\seihou{5}] \hspace{1em}筆者の作成した(TeX Live にも収録されている)luwa-ul パッケージと併用し易い仕様にする。 \end{itemize} \section{設置・依存性} \subsection{読み込み} 適切な場所に\texttt{gckanbun.sty}のファイルを設置し、\verb|\usepackage{gckanbun}|とかけば読み込みは完了です。 本パッケージはLuaLaTeXでも(u)pLaTeXでも使用が可能です。 \subsection{オプション} パッケージオプションは\verb|prefix=|(デフォルト値:\verb|gckanbun|)となっていて、\texttt{gckanbun}パッケージが提供する3つのコマンド\verb|\gckanbunruby|、\verb|\gckanbunokurigana|、\verb|\gckanbunkaeriten| をそれぞれ\verb|ruby|、\verb|okurigana|、\verb|kaeriten| として提供します。このオプションにより、他のパッケージで提供されるルビ振りコマンド \verb|\ruby| との衝突を避けられます。 \namiKK{以下の説明においては、\texttt{prefix}を空白として指定したものと仮定してコマンド名を表記しています。必要に応じて補って読んでください。} \section{各種コマンド} \subsection{概観} 漢文組版において必要十分であるコマンドは、 \begin{itemize} \item 返り点 \item 振り仮名 \item 送り仮名 \item 再読振り仮名 \item 再読送り仮名 \item 一レ点、上レ点、甲レ点、天レ点 \item ハイフン \end{itemize} \noindent です。これらに対し、本パッケージでは、それぞれ \begin{itemize} \item \verb|\kaeriten|、\verb|\返り| \item \verb|\furigana|、\verb|\振り| \item \verb|\okurigana|、\verb|\送り| \item \verb|\furigana|、\verb|\振り|のオプショナル引数 \item \verb|\okurigana|、\verb|\送り|のオプショナル引数 \item \verb|\IchiRe|、\verb|\JyouRe|、\verb|\KouRe|、\verb|\TenRe| \item \verb|\KanHyphen| \end{itemize} \noindent が対応しています。 このうち、\texttt{prefix}が適用されるのは\verb|\kaeriten|、\verb|\furigana|、\verb|\okurigana|のみであることに注意が必要です。 \subsection{使用方法} \subsubsection{\textbackslash kaeriten、\textbackslash 返り} これらの2種類のコマンドは全く同一のコマンドです。 \begin{SourceCode}{Input}{TeX} 雖\返り{レ}\\ 雖\返り{\IchiRe} \end{SourceCode} \begin{OutPut}{Output}[横書き] 雖\返り{レ}鬼\\ 雖\返り{\IchiRe}鬼 \end{OutPut} のような出力になります。 \subsubsection{\textbackslash furigana、\textbackslash 振り、\textbackslash okurigana、\textbackslash 送り} \verb|\furigana|、\verb|\振り|は同一、\verb|\okurigana|、\verb|\送り|は同一です。 \begin{SourceCode}{Input}{TeX} \振り{雖}{いへど}\送り{モ}\\ \振り{所}{ゆ}\返り{二}\振り{\KanHyphen}{ゑ}\振り{以}{ん}\\ \振り{猶}{な}[ごと]\送り{ホ}[キヲ] \end{SourceCode} \begin{OutPut}{Output}[横書き] \振り{雖}{いへど}\送り{モ}\\ \振り{所}{ゆ}\返り{二}\振り{\KanHyphen}{ゑ}\振り{以}{ん}\\ \振り{猶}{な}[ごと]\送り{ホ}[キヲ] \end{OutPut} これらのコマンドにはスターオプションがありますが、これは振り仮名や送り仮名を\verb|\smash|に入れるか入れないかを変更するためのオプションです。通常の使用時はオプションなしで使います。 \section{注意} このパッケージによって提供されるコマンドは、基本的に「局所的な横書きないし縦書き」に対する出力を保証しません。というのも局所的に縦書きにするためのコマンドである\verb|\tate|などの内部の環境と通常の縦書き環境の仕様は大きく異なるためです。 \section{通常の漢文} 通常の漢文を打つ際には、 \begin{itemize} \item ルビはモノルビ仕様 \item 必ず\verb|\振り|→\verb|\送り|→\verb|\返り|の順番にコマンドを配置 \end{itemize} \noindent の2点に注意します。 縦書き環境における出力は以下のようになります。漢詩でなければ、通常の文章と同様の打ち方で問題ありません。 漢文に傍線を引く場合、luwa-ulパッケージが最適です。自動でルビを検出し、下線を適切に持ち上げてくれます。 \begin{SourceCode}{Input}{TeX} \documentclass[luatex,fontsize=8pt,paper=b5,tate]{jlreq} \usepackage{luwa-ul,KKsymbols} \usepackage{gckanbun} \begin{document}\Huge% 今夫\送り{レ}江戸\振り{者}{は}、世之所\送り{ノ}\返り{レ}称\送り{スル}名都\振り{大}{だい}\振り{邑}{いふ}、冠蓋之所\返り{レ}集\送り{マル}\LineNumbering{\kakko{2}}[.5em]\dashKK{舟車之\振り{所}{ところ}\送り{ニシテ}\返り{レ}\振り{湊}{あつ}\送り[intrusion=post]{マル}}、実\送り{ニ}\振り{為}{た}\送り{ル}\返り{二}天下之大都会\返り{一}也。 而\送り{レドモ}\LineNumbering{\ichimoji{C}}\nolinebreak\underLineKK{其地之為名、訪之於古、未之聞}。 豈\送り{二}非\送り{ズ}\返り{三}古今相\送り{ヒ}去\送り{ルコト}\振り{日}{ひび}\送り{ニ}遠\送り{ク}、事之相\送り{ヒ}変\送り{ズルコト}愈多\送り{ク}、求\送り{ムルモ}\返り{二}其\送り{ノ}所\送り{ヲ}\返り{\IchiRe}欲\送り{スル}\返り{レ}聞\送り{カント}而不\送り{ルコト}可\送り{カラ}\返り{レ}得、亦\送り{タ}\振り{猶}{な}[ごと]\送り{ホ}[キヲ]\返り{二}今之於\送り{ケルガ}\返り{\JyouRe}古\送り{ニ}也。 \end{document} \end{SourceCode} \begin{OutPut}{Output}[縦書き] \begin{center} \includegraphics[width=.7\linewidth]{whole-vert-sample.pdf} \end{center} \end{OutPut} \section{漢詩} 漢詩を打つ場合には、\verb|\makebox|と\verb|intrusion|オプションを使います。\verb|intrusion|オプションを指定すると、ルビ文字が親文字の幅を超えた時に前後の領域に「侵入」する形で配置されます。 しかし、漢文はほとんどの文字に何らかのルビが振られるため、普段から侵入を許可する仕様にするとかえって読みづらいです。したがって、本当に必要な時にだけこのオプションを使うべきです。 漢詩において、各句の最初と最後の字が水平方向に揃っていないと見栄えを損なってしまいます。そこで、gckanbunパッケージでは\verb|\makebox|と\verb|intrusion|オプションの組み合わせによって漢詩を組版することを推奨します。 \begin{description} \item[\texttt{\textbackslash 振り}] \verb|intrusion=pre/post/both| の3種類 \item[\texttt{\textbackslash 送り}] \verb|intrusion=post/both| の2種類 \item[\texttt{\textbackslash 返り}] \verb|intrusion=post/both| の2種類 \end{description} \noindent が各コマンドで提供されるオプションであることに注意し、 \begin{SourceCode}{Input}{TeX} \documentclass[luatex,fontsize=8pt,paper=b5,tate]{jlreq} \usepackage{luwa-ul,KKsymbols} \usepackage{gckanbun} \begin{document}\Huge% \makebox[8em][t]{% \振り[intrusion=pre]{春}{しゅん}\hfill% \振り{眠}{みん}\hfill% 不\返り{レ}\hfill% \振り{覚}{おぼ}\送り{エ}\返り{レ}\hfill% \振り{暁}{あかつき}\送り[intrusion=post]{ヲ}% } \makebox[8em][t]{% \振り{処}{しょ}\hfill% \振り{処}{しょ}\hfill% 聞\送り{ク}\返り{二}\hfill% \underLineKK{\振り{啼}{てい}\hfill% 鳥\送り{ヲ}\返り[intrusion=post]{一}}% } \makebox[8em][t]{% \振り{夜}{や}\hfill% \振り{来}{らい}\hfill% 風\hfill% 雨\送り{ノ}\hfill% 声% } \makebox[8em][t]{% 花\hfill% \振り{落}{お}\送り{ツルコト}\hfill% 知\送り{ル}\hfill% \振り{多}{た}\hfill% \振り[intrusion=post]{少}{しょう}% } \end{document} \end{SourceCode} \begin{OutPut}{Output}[縦書き] \begin{center} \includegraphics[width=.7\linewidth]{kanshi-sample.pdf} \end{center} \end{OutPut} 以上のように「漢字1文字ごとに\verb|\hfill|を挿入」することによって適切な空きを確保し、その上で句の最初の文字に(必要ならば)\verb|intrusion=pre|、最後の文字に\verb|intrusion=post|とします。ただし、たとえば「\verb|鳥\送り{ヲ}\返り{一}|」のような1まとまりにおいて、\verb|\送り|と\verb|\返り|の両方に対して\verb|intrusion=post|をつける必要はありません。「一番最後の」要素に対してのみ\verb|intrusion=post|をつければ十分です。 \section{ライセンス} 本パッケージをMITライセンスで配布します。条件なども全て以下のライセンス表記に準拠します。 \begin{simple}[gckanbun package]{ライセンス全文}\setlength{\parindent}{0em} This package is licensed under the terms of the MIT License. Copyright (c) 2017-2025 Munehiro Yamamoto \\ Copyright (c) 2025 Kosei Kawaguchi Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \end{simple} \section{Version History} \begin{itemize} \item \textbf{v2.0.0 (2025/11/04)} --- Initial public release as a reworked version. \item \textbf{v2.1.0 (2025/11/12)} --- Modefied package documentation. Also, KKTeX added some options for KANSHI typesetting. \end{itemize} \section{Source Code} \begin{lstlisting} %%% License %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % This package is licensed under the terms of the MIT License. % Copyright (c) 2017-2025 Munehiro Yamamoto % Copyright (c) 2025 Kosei Kawaguchi % Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: % The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. % THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % 2025/11/04 % 再読送り仮名のボックスの取る幅を毎度リセットするように修正。 % 2025/11/08 % 再読返り点の出力位置および\KanHyphenの仕様を変更。 \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{gckanbun}[2025/11/12, Version 2.1.0] %% declare package errors \def\gcknbn@error{\PackageError{gckanbun}} \def\gcknbn@warning{\PackageWarning{gckanbun}} \def\gcknbn@warningnoline{\PackageWarningNoLine{gckanbun}} \def\gcknbn@info{\PackageInfo{gckanbun}} \RequirePackage{keyval,etoolbox} \DeclareOption*{\gcknbn@setkey} \def\gcknbn@setkey{\expandafter\@gcknbn@setkey\expandafter{\CurrentOption}} \def\@gcknbn@setkey{\setkeys{gcknbn}} \def\gcknbn@prefix{gckanbun}%%given for each commands \define@key{gcknbn}{prefix}{\gdef\gcknbn@prefix{#1}} \ExecuteOptions{prefix} \ProcessOptions\relax %% auto-detect engine \RequirePackage{ifuptex} \RequirePackage{ifluatex} \ifluatex \@ifpackageloaded{luatexja}{}{% \gcknbn@error{Please load package 'luatexja' when loading this package.}} \else\ifuptex \def\zw{zw}\def\zh{zh} \else\ifptex \def\zw{zw}\def\zh{zh} \else \gcknbn@error{Package 'gckanbun' currently supports (u)pLaTeX and LuaLaTeX.} \fi\fi\fi %% 縦書き判定 \newif\ifgcknbn@tdir \gcknbn@tdirfalse \@ifundefined{iftdir}{\let\iftdir\iffalse}{}% \ifluatex \@ifundefined{ltjgetparameter}{}{% \ifnum\ltjgetparameter{direction}=3 % \gcknbn@tdirtrue \fi }% \else \iftdir \gcknbn@tdirtrue \fi\fi \newcommand*\gcknbn@kanjiskip@fill{% \ifluatex \ltjsetparameter{kanjiskip=\fill}% \else \kanjiskip=\fill\relax \fi } \newlength{\gcknbn@adjust@yokotate} \NewDocumentCommand{\gcknbn@adjust@yokotate@use}{}{% \ifgcknbn@tdir \setlength{\gcknbn@adjust@yokotate}{-1.75ex}% \else% \setlength{\gcknbn@adjust@yokotate}{-1.3ex}% \fi% } \newlength{\gcknbn@adjust@kaeri} \NewDocumentCommand{\gcknbn@adjust@kaeri@use}{}{% \ifgcknbn@tdir \setlength{\gcknbn@adjust@kaeri}{.35\zw}% \else% \setlength{\gcknbn@adjust@kaeri}{.15\zw}% \fi% } %% ルビ %% * グループルビ %% * 漢文訓点に対するふりがな(モノルビ) \let\gcknbn@rubybox@text\relax \let\gcknbn@rubybox@text@s\relax \newdimen\gcknbn@rubybox@width \newdimen\gcknbn@furigana@width \gcknbn@furigana@width\z@ \newdimen\gcknbn@furigana@width@s \gcknbn@furigana@width@s\z@ \newdimen\gcknbn@dima % pre,post,bothをとれる。 \newdimen\gcknbn@intr@pre \newdimen\gcknbn@intr@post \define@key{gcknbn@ruby}{intrusion}{\edef\gcknbn@ruby@intr@mark{#1}} \DeclareDocumentCommand{\gcknbn@ruby}{ s O{} m m O{\vphantom{羅} }}{% \gcknbn@adjust@yokotate@use% \global\gcknbn@furigana@width\z@% \global\gcknbn@furigana@width@s\z@% \global\def\gcknbn@ruby@intr@mark{}% \leavevmode% \begingroup% \setkeys{gcknbn@ruby}{#2}% \gcknbn@dima\f@size\p@\relax \divide\gcknbn@dima by \tw@% \def\tiny{\@setfontsize\tiny{\gcknbn@dima}{\z@}}% \setbox\z@=\hbox{#3}\setbox\@ne=\hbox{\tiny#4}% \setbox\tw@=\hbox{\tiny#5}% \ifdim\wd\@ne>\wd\tw@%侵入量計算 \ifdim\wd\@ne>\zw% \global\gcknbn@intr@pre=\dimexpr(\wd\@ne-\zw)/2\relax%再読なし前方 \global\gcknbn@intr@post=\dimexpr(\wd\@ne-\zw)/2\relax%再読なし後方 \else% \global\gcknbn@intr@pre=0em\relax% \global\gcknbn@intr@post=0em\relax% \fi% \else% \ifdim\wd\tw@>\zw% \global\gcknbn@intr@pre=\dimexpr(\wd\tw@-\zw)/2\relax%再読あり前方 \global\gcknbn@intr@post=\dimexpr(\wd\tw@-\zw)/2\relax%再読あり後方 \else% \global\gcknbn@intr@pre=0em\relax% \global\gcknbn@intr@post=0em\relax% \fi% \fi% \ifdefstring{\gcknbn@ruby@intr@mark}{pre}{% \kern-\gcknbn@intr@pre% }{% \ifdefstring{\gcknbn@ruby@intr@mark}{both}{% \kern-\gcknbn@intr@pre% }{% % それ以外は何もなし }}% \gdef\gcknbn@rubybox@text{#4}% \gdef\gcknbn@rubybox@text@s{#5}% \global\gcknbn@rubybox@width=\wd\z@\relax% \IfBooleanTF{#1}{\gcknbn@furigana@okurigana@SMASH}{\gcknbn@furigana@okurigana}% } \def\gcknbn@furigana@okurigana{% \futurelet\@let@token\gcknbn@@furigana@okurigana} \def\gcknbn@furigana@okurigana@SMASH{% \futurelet\@let@token\gcknbn@@furigana@okurigana@SMASH} \def\gcknbn@@furigana@okurigana{% \ifx\@let@token\gcknbn@okurigana% \global\gcknbn@furigana@width=\wd\@ne\relax% \global\gcknbn@furigana@width@s=\wd\tw@\relax% \dimen\z@=\wd\z@% \raisebox{\gcknbn@adjust@yokotate}{\hbox{% \vbox{\hbox to \dimen\z@{\box\@ne\hss}% \nointerlineskip\hbox to \dimen\z@{\hfil\box\z@\hfil}% \nointerlineskip\hbox to \dimen\z@{\box\tw@\hss}% }}}% \else \ifdim\wd\z@>\wd\@ne% \dimen\z@=max{\wd\z@,\wd\@ne,\wd\tw@} \dimen\z@=\wd\z@% \else% \dimen\z@=\wd\@ne% \fi% \ifdim\dimen\z@<\wd\tw@% \dimen\z@=\wd\tw@% \fi% \penalty\@lowpenalty% \raisebox{\gcknbn@adjust@yokotate}{\hbox{% \vbox{\hbox to \dimen\z@{\tiny\hfil\gcknbn@rubybox@text\hfil}% \nointerlineskip\hbox to \dimen\z@{\hfil\box\z@\hfil}% \nointerlineskip\hbox to \dimen\z@{\hss\box\tw@\hss}% }}}% \fi% \ifdefstring{\gcknbn@ruby@intr@mark}{post}{% \kern-\gcknbn@intr@post% }{% \ifdefstring{\gcknbn@ruby@intr@mark}{both}{% \kern-\gcknbn@intr@post% }{% % それ以外は何もなし }}% \endgroup} \def\gcknbn@@furigana@okurigana@SMASH{% \ifx\@let@token\gcknbn@okurigana% \global\gcknbn@furigana@width=\wd\@ne\relax% \global\gcknbn@furigana@width@s=\wd\tw@\relax% \dimen\z@=\wd\z@% \raisebox{\gcknbn@adjust@yokotate}{\smash{\hbox{% \vbox{\hbox to \dimen\z@{\box\@ne\hss}% \nointerlineskip\hbox to \dimen\z@{\hfil\box\z@\hfil}% \nointerlineskip\hbox to \dimen\z@{\box\tw@\hss}% }}}}% \else% \ifdim\wd\z@>\wd\@ne\dimen\z@=\wd\z@\else\dimen\z@=\wd\@ne\fi% \penalty\@lowpenalty% \raisebox{\gcknbn@adjust@yokotate}{\smash{\hbox{% \vbox{\hbox to \dimen\z@{\tiny\hfil\gcknbn@rubybox@text\hfil}% \nointerlineskip\hbox to \dimen\z@{\hfil\box\z@\hfil}% \nointerlineskip\hbox to \dimen\z@{\hss\box\tw@\hss}% }}}}% \fi \ifdefstring{\gcknbn@ruby@intr@mark}{post}{% \kern-\gcknbn@intr@post% }{% \ifdefstring{\gcknbn@ruby@intr@mark}{both}{% \kern-\gcknbn@intr@post% }{% % それ以外は何もなし }}% \endgroup} %% 訓点 \newdimen\gcknbn@okurigana@width \gcknbn@okurigana@width\z@ \newdimen\gcknbn@okurigana@width@s \gcknbn@okurigana@width@s\z@ \newdimen\gcknbn@kaeriten@width \gcknbn@kaeriten@width\z@ % post,bothをとれるが挙動は一緒 \define@key{gcknbn@okurigana}{intrusion}{\edef\gcknbn@okuri@intr@mark{#1}} %%訓点送り仮名 \DeclareDocumentCommand{\gcknbn@okurigana}{ s O{} m O{\vphantom{羅}} }{% \nobreak\leavevmode% \gcknbn@adjust@yokotate@use% \global\gcknbn@okurigana@width\z@% \global\gcknbn@okurigana@width@s\z@% \global\def\gcknbn@okuri@intr@mark{}% \begingroup% \setkeys{gcknbn@okurigana}{#2}% \gcknbn@dima\f@size\p@\relax \divide\gcknbn@dima by \tw@% \def\tiny{\@setfontsize\tiny{\gcknbn@dima}{\z@}}% \setbox\z@=\hbox{\tiny #3}% \setbox\@ne=\hbox{\tiny #4}% \ifdim\gcknbn@furigana@width>0.9999\zw\relax% \global\gcknbn@okurigana@width=\dimexpr\gcknbn@furigana@width + \wd\z@ - 1\zw\relax% \else% \global\gcknbn@okurigana@width=\dimexpr\wd\z@ - .5\zw\relax% \fi% \ifdim\gcknbn@furigana@width@s>0.9999\zw\relax% \global\gcknbn@okurigana@width@s=\dimexpr\gcknbn@furigana@width@s + \wd\@ne - 1\zw\relax% \else% \global\gcknbn@okurigana@width@s=\dimexpr\wd\@ne - .5\zw\relax% \fi% \IfBooleanTF{#1}{% \smash{\hbox{% \raisebox{\gcknbn@adjust@yokotate}{\vbox{\hbox to \gcknbn@okurigana@width{% \ifdim\gcknbn@furigana@width>0.9999\zw\relax% \hspace*{\dimexpr\gcknbn@furigana@width - 1\zw\relax}% \else% \hspace*{-.5\zw}% \fi% \box\z@}% \nointerlineskip% \hbox to \gcknbn@okurigana@width{\hfil\vphantom{\char\euc"A1A1%" }\hfil}% \nointerlineskip% \hbox to \gcknbn@okurigana@width@s{% \ifdim\gcknbn@furigana@width@s>0.9999\zw\relax% \hspace*{\dimexpr\gcknbn@furigana@width@s - 1\zw\relax}% \else% \hspace*{-.5\zw}% \fi% \box\@ne}% }}}}}% {% \hbox{% \raisebox{\gcknbn@adjust@yokotate}{\vbox{\hbox to \gcknbn@okurigana@width{% \ifdim\gcknbn@furigana@width>0.9999\zw\relax \hspace*{\dimexpr\gcknbn@furigana@width - 1\zw\relax}% \else \hspace*{-.5\zw}% \fi \box\z@}% \nointerlineskip% \hbox to \gcknbn@okurigana@width{\hfil\vphantom{\char\euc"A1A1%" }\hfil}% \nointerlineskip% \hbox to \gcknbn@okurigana@width@s{% \ifdim\gcknbn@furigana@width@s>0.9999\zw\relax \hspace*{\dimexpr\gcknbn@furigana@width@s - 1\zw\relax}% \else% \hspace*{-.5\zw}% \fi% \box\@ne}% }}}% }% \global\gcknbn@furigana@width=\z@\relax% \gcknbn@okurigana@intr% \gcknbn@okurigana@kaeriten% } \def\gcknbn@okurigana@kaeriten{% \futurelet\@let@token\gcknbn@@okurigana@kaeriten} \def\gcknbn@@okurigana@kaeriten{% \ifx\@let@token、 \gcknbn@okurigana@kutoten@skip \global\gcknbn@okurigana@width=\z@ \else\ifx\@let@token。 \gcknbn@okurigana@kutoten@skip \global\gcknbn@okurigana@width=\z@ \else\ifx\@let@token\gcknbn@kaeriten \gcknbn@okurigana@kaeriten@skip \else% \ifdefstring{\gcknbn@okuri@intr@mark}{post}{% \kern-\gcknbn@intr@post% }{% \ifdefstring{\gcknbn@okuri@intr@mark}{both}{% \kern-\gcknbn@intr@post% }{% % それ以外は何もなし }}% \fi\fi\fi \endgroup} \def\gcknbn@okurigana@kutoten@skip{% \ifgcknbn@tdir\hspace*{-\gcknbn@okurigana@width}\else\fi% } \def\gcknbn@okurigana@kaeriten@skip{% \ifdim\gcknbn@okurigana@width>\gcknbn@okurigana@width@s% \hspace*{-\gcknbn@okurigana@width}% \else% \hspace*{-\gcknbn@okurigana@width@s}% \fi } \def\gcknbn@okurigana@intr{% \ifdim\gcknbn@okurigana@width>\gcknbn@okurigana@width@s% \global\gcknbn@intr@post=\gcknbn@okurigana@width% \else% \global\gcknbn@intr@post=\gcknbn@okurigana@width@s% \fi } %%訓点返り点 \newcommand*\gcknbn@kaeriten{% \@ifnextchar-{\gcknbn@tateten@kaeriten@hh}{% \@ifnextchar‐{\gcknbn@tateten@kaeriten@zh}{% \gcknbn@@kaeriten}}} % \gcknbn@@kaeriten} % post,bothをとれるが挙動は一緒 \define@key{gcknbn@kaeriten}{intrusion}{\edef\gcknbn@kaeri@intr@mark{#1}} \NewDocumentCommand\gcknbn@@kaeriten{ O{} m }{% \nobreak\leavevmode \gcknbn@adjust@kaeri@use% \global\def\gcknbn@kaeri@intr@mark{}% \setkeys{gcknbn@kaeriten}{#1}% \begingroup \gcknbn@dima\f@size\p@\relax \divide\gcknbn@dima by \tw@ \def\tiny{\@setfontsize\tiny{\gcknbn@dima}{\z@}}% \setbox\z@=\hbox{\tiny #2}% \global\gcknbn@kaeriten@width=\wd\z@\relax \ifdim\wd\z@>\gcknbn@intr@post% \global\gcknbn@intr@post=\wd\z@% \fi% \smash{\lower\gcknbn@adjust@kaeri\hbox{\box\z@\hss}}% \endgroup% \gcknbn@kaeriten@kutoten% } \def\gcknbn@kaeriten@kutoten{\futurelet\@let@token\gcknbn@@kaeriten@kutoten} \def\gcknbn@@kaeriten@kutoten{% \ifx\@let@token、 \gcknbn@kaeriten@kutoten@skip \global\gcknbn@kaeriten@width=\z@ \else\ifx\@let@token。 \gcknbn@kaeriten@kutoten@skip \global\gcknbn@kaeriten@width=\z@ \else% \gcknbn@kaeriten@okurigana@skip \ifdefstring{\gcknbn@kaeri@intr@mark}{post}{% \kern-\gcknbn@intr@post% }{% \ifdefstring{\gcknbn@kaeri@intr@mark}{both}{% \kern-\gcknbn@intr@post% }{% % それ以外は何もなし }}% \fi\fi } \def\gcknbn@kaeriten@kutoten@skip{% \ifgcknbn@tdir% \hspace*{-\gcknbn@kaeriten@width}% \fi } \def\gcknbn@okurigana@kutoten@skip{% \hspace*{-\gcknbn@okurigana@width}} \def\gcknbn@kaeriten@okurigana@skip{% \ifdim\gcknbn@okurigana@width>\gcknbn@kaeriten@width \hspace*{\dimexpr\gcknbn@okurigana@width - \gcknbn@kaeriten@width}% \fi \ifdim\gcknbn@okurigana@width<\gcknbn@okurigana@width@s% \hspace*{\gcknbn@okurigana@width@s - \gcknbn@kaeriten@width}% \else \fi } \def\gcknbn@tateten@kaeriten@hh-{\gcknbn@@tateten@kaeriten} \def\gcknbn@tateten@kaeriten@zh‐{\gcknbn@@tateten@kaeriten} \newcommand*\gcknbn@@tateten@kaeriten[1]{% \nobreak\leavevmode \begingroup \gcknbn@dima\f@size\p@\relax \divide\gcknbn@dima by \tw@ \def\tiny{\@setfontsize\tiny{\gcknbn@dima}{\z@}}% \setbox\z@=\hbox{\tiny\char"3190}%" \global\gcknbn@kaeriten@width=\wd\z@\relax \smash{\lower.35\zw\hbox{% \vbox{\hbox to \gcknbn@kaeriten@width{\hfil\box\z@\hfil}% \vspace*{-.1\zw}% \nointerlineskip\hbox to \gcknbn@kaeriten@width{\tiny\hfil#1\hfil}}}}% \endgroup} %% Finaly, provide \ruby, \okurigana, \kaeriten \expandafter\let\csname\gcknbn@prefix ruby\endcsname\gcknbn@ruby \expandafter\let\csname\gcknbn@prefix okurigana\endcsname\gcknbn@okurigana \expandafter\let\csname\gcknbn@prefix kaeriten\endcsname\gcknbn@kaeriten %% 短縮マクロ \expandafter\let\csname 振り\endcsname\gcknbn@ruby \expandafter\let\csname 送り\endcsname\gcknbn@okurigana \expandafter\let\csname 返り\endcsname\gcknbn@kaeriten \NewDocumentCommand{\IchiRe}{}{% \ifgcknbn@tdir \hspace{-.5ex}一\hspace{-1.9ex}レ% \else% \raisebox{.5ex}{一}\llap{レ}% \fi% } \NewDocumentCommand{\JyouRe}{}{% \ifgcknbn@tdir 上\hspace{-.7ex}レ% \else% \raisebox{1.7ex}{上}\llap{レ}% \fi% } \NewDocumentCommand{\KouRe}{}{% \ifgcknbn@tdir 甲\hspace{-.4ex}レ% \else% \raisebox{1.9ex}{甲}\llap{レ}% \fi% } \NewDocumentCommand{\TenRe}{}{% \ifgcknbn@tdir 天\hspace{-.4ex}レ% \else% \raisebox{1.9ex}{天}\llap{レ}% \fi% } \NewDocumentCommand{\KanHyphen}{}{\symbol{"2015}} \endinput \end{lstlisting} \end{document}