% \iffalse meta-comment % This is file `outoruby.dtx'. %% Copyright (c) 2025 kkotsi %% This file is distributed under the GNU General Public Licence Version 3. %% https://www.gnu.org/licenses/gpl-3.0.html %% Repository: https://codeberg.org/kkotsi/outoruby % % The outoruby package: Ruby with line break support for Japanese text. % % This package provides the \outoruby command, which support line breaks when typesetting ruby anotations. % It automatically switches between appropriate rubby form at the beginning and end of lines according to JIS X 4051 and JLReq. % This package depends on pxrubrica and supports any engine that it supports. % % To generate outoruby.sty, run the following command: % tex outoruby.dtx % To generate outoruby.pdf, run following commands (outoruby.sty needed): % uplatex outoruby.dtx % uplatex outoruby.dtx % uplatex outoruby.dtx % makeindex -s gind.ist outoruby.idx % makeindex -s gglo.ist outoruby.glo -o outoruby.gls % uplatex outoruby.dtx % uplatex outoruby.dtx % dvipdfmx outoruby % \fi % \makeatother %% %% \CharacterTable %% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z %% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z %% Digits \0\1\2\3\4\5\6\7\8\9 %% Exclamation \! Double quote \" Hash (number) \# %% Dollar \$ Percent \% Ampersand \& %% Acute accent \' Left paren \( Right paren \) %% Asterisk \* Plus \+ Comma \, %% Minus \- Point \. Solidus \/ %% Colon \: Semicolon \; Less than \< %% Equals \= Greater than \> Question mark \? %% Commercial at \@ Left bracket \[ Backslash \\ %% Right bracket \] Circumflex \^ Underscore \_ %% Grave accent \` Left brace \{ Vertical bar \| %% Right brace \} Tilde \~} %% % \makeatletter % \CheckSum{1403} % % \iffalse %<*ins> \ifx\documentclass\undefined \input docstrip \askforoverwritetrue \AddGenerationDate \preamble \endpreamble \generate{% \file{outoruby.sty}{\from{outoruby.dtx}{pkg}}% } \expandafter\endbatchfile \fi % % %<*driver> \NeedsTeXFormat{LaTeX2e} \ProvidesFile{outoruby.dtx} % % \fi % % \@nameuse{@@sourcepart}\iffalse % % 残念ながら\LaTeX 限定。 % \begin{macrocode} %\NeedsTeXFormat{LaTeX2e} %\ProvidesPackage{outoruby} %<*pkg|driver> [2025/03/02 v0.0.0 ] % % \end{macrocode} % % \@nameuse{@@sourcepart}\fi % \@nameuse{@@sourcepartend} % % \iffalse %<*driver> \documentclass[dvipdfmx]{ujarticle} \makeatletter \usepackage[scale=0.924715,deluxe]{jlreq-deluxe}\normalfont\normalsize \usepackage{ajmacros} \newcommand\zw{zw} \setlength\emergencystretch{3em} \usepackage[T1]{fontenc} \usepackage{lmodern} \renewcommand*\rmdefault{lmr} \usepackage[scale=0.86,medium]{FiraSans} \renewcommand*{\ttdefault}{ntxtt} \DeclareFontShape{JY2}{hmc}{b}{n}{<->ssub*hmc/bx/n}{} \DeclareFontShape{JT2}{hmc}{b}{n}{<->ssub*hmc/bx/n}{} \DeclareFontShape{JY2}{hgt}{b}{n}{<->ssub*hgt/bx/n}{} \DeclareFontShape{JT2}{hgt}{b}{n}{<->ssub*hgt/bx/n}{} % 太字はゴシック \DeclareFontShape{JY2}{hmc}{bx}{n}{<->ssub*hgt/bx/n}{} \DeclareFontShape{JT2}{hmc}{bx}{n}{<->ssub*hgt/bx/n}{} % \setlength\topskip{1.5\zw} \setlength\baselineskip{1.75\zw} \setlength\columnsep{3\zw} \usepackage[ textwidth=47\zw, lines=46, left=12.2\zw, ]{geometry} \usepackage{pxeverysel,plext} \usepackage{multicol,color,graphicx,bm,amsfonts,array} \usepackage{booktabs,float,bxtexlogo,tasks,accsupp,fancyvrb,manfnt,needspace} \usepackage{etoolbox} \usepackage[verb]{bxghost} \usepackage{hypdoc} \AlsoImplementation \CodelineIndex \usepackage{footnotehyper,footnotebackref} \usepackage{pxjahyper} \usepackage{outoruby} %\usepackage{bxjaprnind} \catcode`\#=12 \@firstofone{\catcode`\#=6 \let\@@pxrr@compose@oneside@block@do\pxrr@compose@oneside@block@do \patchcmd\@@pxrr@compose@oneside@block@do{% \pxrr@evenspace@int{#1}\pxrr@boxr }{% \pxrr@evenspace@int{\pxrr@locate@inner}\pxrr@boxr }{% \newcommand\pxpatchon{% \let\pxrr@compose@oneside@block@do\@@pxrr@compose@oneside@block@do} }{% \let\@@pxrr@compose@block\pxrr@compose@block \patchcmd\@@pxrr@compose@block{% \pxrr@evenspace@int{#1}\pxrr@boxr }{% \pxrr@evenspace@int{\pxrr@locate@inner}\pxrr@boxr }{% \newcommand\pxpatchon{% \let\pxrr@compose@block\@@pxrr@compose@block} }{% Patch failed% }% } } \outorubyhyphenbreakable \def\em@@last#1{% \global\@namedef{em@@last@#1}{}} \begin{document} \DocInput{outoruby.dtx} \end{document} % % \fi % % \RecordChanges % \def\@@generalname:\ {}^^A 危険 % \def\generalname{\protect\@@generalname} % \changes{v0.0.0}{2025/03/02}{初版} % \DoNotIndex{ % \advance, \begingroup, \csname, \def, \edef, \else, \endgroup, \endcsname, \expandafter, % \fi, \if, \ifnum, \ifx, \let, \noexpand, % \relax, \the % } % % \frenchspacing % \setlength\emergencystretch{3em} % % \setlength\marginparwidth{12\zw} % \newcommand\marginfig[1]{\marginpar{^^A % \hskip2.5\zw % \advance\marginparwidth-3\zw % \parbox[b]{\marginparwidth}{^^A % #1}\hskip0.5\zw}} % % \def\texlevel{\leavevmode\marginpar{\hfill\dbend}} % \def\textexlevel{\leavevmode\marginpar{\hfill\dbend\dbend}} % % \DeclareRobustCommand\small{^^A % \@setfontsize\small\@ixpt{13.5}^^A % } % \DeclareRobustCommand\footnotesize{^^A % \@setfontsize\small\@viiipt{12}^^A % } % \setlength\footnotesep{8.6\p@} % \DeclareRobustCommand*\emph[1]{^^A % \relax\ifmmode \bm{#1}^^A % \else \textbf{\textgt{#1}}\fi} % % \renewcommand\contentsname{目次} % \renewcommand\abstractname{\outoruby{概要}{がい|よう}} % % \newcommand\jttdefault{\gtdefault} % \EverySelectfont{^^A % \begingroup % \edef\x{\f@family}^^A % \edef\y{\ttdefault}^^A % \edef\z{\k@family}^^A % \edef\a{\jttdefault}^^A % \expandafter\expandafter\expandafter\endgroup\ifx\x\y\ifx\z\a\else % \kanjifamily\jttdefault\selectfont % \fi\fi\relax % \setlength\kanjiskip{0pt plus 0.02\zw minus 0.02\zw}^^A % \setlength\xkanjiskip{0.25\zw plus 0.05\zw minus 0.10\zw}^^A % }\selectfont % % \renewcommand\quotation{^^A % \list{}{\listparindent1\zw\itemindent\listparindent % \rightmargin\leftmargin \parsep\z@ % \item\relax}} % \setlength\leftmargini{2\zw} % \edef\@listi{\@listi % \itemsep\z@ % \parsep\z@ % } % \let\@listI\@listi % % \renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}{^^A % 0.5\Cvs}{1sp}{\normalfont\normalsize\bfseries\gtfamily \noindent ■}} % % \newcommand\@@fnmark{\textsf{\textdagger}} % \renewcommand\@makefnmark{\null\hbox{\@textsuperscript{\normalfont\@@fnmark\@thefnmark}}\null} % \renewcommand\@makefntext[1]{\parindent1\zw % \leftskip1.75\zw % \noindent\hb@xt@\z@{\hskip-1\zw\relax % \hyperref[\BackrefFootnoteTag]{\@@fnmark\@thefnmark}\hss}\hskip1\zw\relax#1} % \renewcommand\footnoterule{^^A % \kern-3\p@ % \hrule\@width.333\columnwidth\@height0.4\p@ % \kern2.5\p@} % \setlength{\skip\footins}{1.75\zw\@plus5\p@\@minus5\p@} % % \newenvironment{fullwidth}{^^A % \list{}{^^A % \leftmargin-\marginparwidth % \advance\leftmargin-\marginparsep % \advance\leftmargin3\zw % \listparindent1\zw % }\item\relax % }{^^A % \endlist % } % % \clubpenalty\z@ % \widowpenalty\z@ % % \renewcommand\AltMacroFont{\MacroFont} % \CodelineNumbered % \setlength\MacroTopsep{2pt minus \z@}^^A macro環境前後のアキ % \def\linenumberstyle#1{{^^A % \rmfamily\scriptsize\color[gray]{0.5}^^A % \BeginAccSupp{method=hex,ActualText=00}^^A % #1\EndAccSupp{}}} % \def\theCodelineNo{\linenumberstyle{^^A % \arabic{CodelineNo}}} % \def\theFancyVerbLine{\linenumberstyle{^^A % \arabic{FancyVerbLine}}} % \fvset{fontsize=\small, frame=leftline, numbersep=2pt, numbers=left, framerule=0.4pt, framesep=4pt, rulecolor=\color[gray]{0.75}, gobble=4} % % \def\PrintDescribeMacro#1{^^A % \begingroup \MacroFont % \mparwidth{\string #1}^^A % \endgroup} % \let\PrintMacroName\PrintDescribeMacro % \newcommand*\mparwidth[1]{^^A アレ % \begingroup % \settowidth\@tempdima{#1}^^A % \@tempdimb\marginparwidth % \advance\@tempdimb-3\p@ % \ifdim\@tempdima>\@tempdimb % ^^A\fontfamily{lmtt}\fontseries{lc}\selectfont % \settowidth\@tempdima{#1}^^A % \ifdim\@tempdima>\@tempdimb % \advance\@tempdima10\p@ % \divide\@tempdima\p@ % \divide\@tempdimb\@tempdima % \expandafter\scalebox\expandafter{\romannumeral-`0\strip@pt\@tempdimb}[1.0]{#1}^^A % \else % #1^^A % \fi % \else % #1^^A % \fi\endgroup} % % \newcount\em@@count % \chardef\em@@unique=17 % \newif\ifem@@lastand \global\em@@lastandtrue % \def\endmacro{^^A % \ifdim\lastskip=-\em@@unique sp\relax^^A アレ % \else % \immediate\write\@auxout{^^A % \noexpand\em@@last{\the\em@@count}}^^A % \fi % \global\advance\em@@count\@ne % \endtrivlist % \expandafter\expandafter\expandafter\gdef\expandafter\expandafter\expandafter\em@@savedname\expandafter\expandafter\expandafter{\expandafter\string\saved@macroname}^^A % \ifx\em@@list\@undefined % \global\expandafter\def\expandafter\em@@list\expandafter{\em@@savedname}^^A % \else % \ifem@@lastand % \expandafter\ltx@GlobalPrependToMacro\expandafter\em@@list\expandafter{\em@@savedname\em@@andlast}^^A % \else % \expandafter\ltx@GlobalPrependToMacro\expandafter\em@@list\expandafter{\em@@savedname\em@@and}^^A % \fi % \global\em@@lastandfalse % \fi % \expandafter\ifx\csname em@@last@\the\em@@count\endcsname\relax % \else % \em@@print % \global\let\em@@list\@undefined % \global\em@@lastandtrue % \fi % \vskip-\em@@unique sp\relax % } % \def\em@@and{{\normalfont\@@it\itshape \,, \,}} % \def\em@@andlast{{\normalfont\@@it\itshape \,,\, and \,}} % \def\em@@print{{^^A % \par\noindent % \small\@@it\itshape (End of definition for {\MacroFont\itshape\em@@list}\,.)\par}} % \AtEndDocument{^^A % \immediate\write\@auxout{^^A % \noexpand\em@@last{\the\em@@count}}} % % \definecolor{hred}{rgb}{0.5,0,0} % \definecolor{hblue}{rgb}{0,0,0.45} % \hypersetup{^^A % linkcolor=hred, % urlcolor=hblue, % pdfauthor=kkotsi, % } % % \GetFileInfo{outoruby.dtx} % \DeclareRobustCommand\file[1]{\textsf{#1}} % \DeclareRobustCommand\pkg[1]{\file{#1}} % \DeclareRobustCommand\cls[1]{\file{#1}} % % \newcommand\globstar{^^A % \texttt{\textit{\large\lower.5ex\hbox{*}}}} % % \newcommand\jkrubypkg{^^A % 画期的\ajSnowman なルビパッケージ} % \newcommand\ltjrubypkg{^^A % \href{https://github.com/luatexja/luatexja}{\pkg{luatexja-ruby}}} % \newcommand\pxrbpkg{^^A % \href{https://github.com/zr-tex8r/PXrubrica}{\pkg{pxrubrica}}} % % \newcommand\X{\(\mathbb{X}\)} % % \xspcode`\\=\thr@@ % \xspcode`\{=\@ne % \xspcode`\}=\tw@ % % \catcode`\<=\active % \newcommand\@@it{^^A % \fontfamily{ntxlf}\def\ntx@scaled{s*[1]}\selectfont} % \protected\def<#1>{{\eghostguarded{^^A % \@@it % \(\langle\)\null\textit{\met@#1_{}\@nil}\null\(\rangle\)}}} % \DeclareRobustCommand*\meta[1]{<#1>} % \def\met@#1_#2#3\@nil{^^A % \ltx@ifempty{#3}{#1}{^^A % \c@@arg #1$_{#2}$\met@#3\@nil}} % \let\@@outorb@opt@opt\outorb@opt@opt % \def\outorb@opt@opt#1\outorb@nil{^^A % \begingroup % \edef<{\string<}^^A % \protected@edef\x{#1}^^A % \expandafter\endgroup\expandafter\@@outorb@opt@opt\x\outorb@nil} % % \DeclareRobustCommand*\cs{^^A % \ltx@ifnextchar\bgroup{\cs@@{}}{\cs@@@{}}} % \def\cs@@#1#2{^^A % \eghostguarded{\texttt{\bslash #2}}#1} % \def\cs@@@#1#2{\cs@@{#1}{\expandafter\@gobble\string#2}} % \DeclareRobustCommand*\@cs{^^A % \ltx@ifnextchar\bgroup{\cs@@\c@@arg}{\cs@@@\c@@arg}} % % \DeclareRobustCommand\A{^^A % \ltx@ifnextchar[\oarg\marg} % \newcommand*\marg[1]{\eghostguarded{^^A % \texttt\{\c@@arg #1\texttt\}}} % \def\oarg[#1]{\eghostguarded{^^A % \texttt{[\c@@arg #1]}}} % \def\CS{\cs{CS}} % \def\CSa{\cs{CSa}} % \def\CSb{\cs{CSb}} % \def\pxrr@inter{\cs{pxrr@inter}\c@@arg} % \def\pxrr@pre{\cs{pxrr@pre}\c@@arg} % \def\pxrr@post{\cs{pxrr@post}\c@@arg} % \def\c@@arg{^^A % \ltx@ifnextchar\bgroup{\c@@@rg}{^^A % \ltx@ifnextchar[{\c@@@@rg}{}}} % \def\c@@@rg#1{^^A % \marg{#1}\c@@arg} % \def\c@@@@rg[#1]{^^A % \oarg[#1]\c@@arg} % % \newcommand\ttindent{\mbox{\texttt{\space\space}}} % \newcommand*\ttend[1]{\texttt\%\\^^A % \@@ttend{#1}} % \def\@@ttend#1{^^A % \ifnum#1>\z@ % \ttindent % \begingroup \@tempcnta=#1\relax \advance\@tempcnta\m@ne % \expandafter\endgroup\expandafter\@@ttend\expandafter{\the\@tempcnta}^^A % \fi\c@@arg} % % \newcommand*\desccs[1]{\par % \needspace{6\baselineskip}^^A % \noindent % \if*\noexpand#1^^A % \expandafter\DescribeMacro % \else % \DescribeMacro{#1}^^A % \cs#1^^A % \expandafter\c@@arg % \fi} % % \newcommand*\@@argbrace[1]{^^A % \@ifnextchar\bgroup{^^A % \@@argbrace@b{#1}}{#1}} % \def\@@argbrace@b#1#2{#1{{#2}}} % % \newcommand*\headitem[1]{^^A % \if@@movemarginpar \@@movemarginparfalse \fi % \par\noindent\hb@xt@\z@{\hss\mparwidth{#1}\hskip\labelsep}\ignorespaces} % \newcommand*\inarg[1]{^^A % \headitem{\texttt{\##1}:}\c@@arg} % \newcommand*\result{^^A % \@@argbrace\@@result} % \def\@@result#1{^^A % \headitem{\texttt{\cs#1} \textrightarrow}\c@@arg} % \newcommand*\intl[1]{^^A % \@@argbrace\@@intl} % \def\@@intl#1{^^A % \headitem{\texttt{\cs#1}:}\c@@arg} % % \newif\if@@movemarginpar % \newcommand\movempar{\par\@@movemarginpartrue\vskip-\baselineskip\leavevmode} % % \newcommand*\argn[1]{^^A % \texttt{\##1}} % % \title{\pkg{outoruby}パッケージ} % \let\@@@@@makefntext\@makefntext % \let\@@@@@makefnmark\@makefnmark % \let\thanks\footnote % \author{kkotsi^^A % \let\@makefntext\@@@@@makefntext % \def\@@fnmark{}^^A % \footnote{リポジトリは\url{https://codeberg.org/kkotsi/outoruby}。}}^^A % \date{\filedate} % \begin{savenotes} % \HyOrg@maketitle % \end{savenotes} % \begin{abstract} % \pxrbpkg をラップし、 % \outoruby{自動}{じ|どう}で\outoruby[||-][-|]{行頭形}{ぎょう|とう|けい}/ % \outoruby{行中形}{ぎょう|ちゅう|けい}/\outoruby[-||][|-]{行末形}{ぎょう|まつ|けい} % を\outoruby{切}{き}り\outoruby{替}{か}えられるるルビ\outoruby[-:]{命令}{めい|れい}\cs{outoruby}を % \outoruby[<>]{提供}{てい|きょう}する。 % \outoruby{実装}{じっ|そう}は\cs{discretionary}による。 % \end{abstract} % % \renewcommand*{\l@subsection}{\@dottedtocline{2}{1\zw}{2\zw}} % \renewcommand*{\l@subsubsection}{\@dottedtocline{3}{2\zw}{3\zw}} % \section*{\contentsname\@mkboth{\contentsname}{\contentsname}} % \begin{multicols}{2} % \@starttoc{toc} % \end{multicols} % % \section{背景} % % 従来、日本語\LaTeX 環境においてルビを実現するパッケージとしては % \begin{savenotes} % \begin{tasks}[ % label=\arabic*., % item-indent={2\zw}, % column-sep={1\zw}, ^^A 3x+(3-1)y=47の自然数解のうち最小のy \textwidth=47\zw % ](3) % \task \href{https://github.com/texjporg/jsclasses}{\pkg{okumacro}} % \task \href{http://xymtex.com/fujitas2/texlatex/index.html\#tategumi}{\pkg{furikana}}^^A % \footnote{長らくメンテナンスされておらず、改変再配布等も認められてない。\TeX\ Live未収録。} % \task \href{http://xymtex.com/fujitas2/texlatex/index.html\#tategumi}{\pkg{furiknkt}}^^A % \footnote{上に同じ。} % \task \href{https://www.nongnu.org/cjk/}{\pkg{ruby}(\pkg{CJK}パッケージ)\<}^^A % \footnote{日本語のルビとしては使うべきではないとされている。} % \task \pxrbpkg % \task \ltjrubypkg % \end{tasks} % 等が知られていた。 % これらのうち行分割可能なルビ命令を提供するのは\pxrbpkg と\ltjrubypkg のみであり、それぞれ次の制約がある: % \end{savenotes} % \begin{description} % \item[\pxrbpkg] \mbox{}\\* % モノルビに帰着できる場合にしか行分割できない。 % 行頭形/行中形/行末形を自動で切り替えられない。 % \item[\ltjrubypkg] \mbox{}\\* % \LuaLaTeX でしか使えない。 % \end{description} % % したがって、(u)\pLaTeX では行分割に応じて自動で形が変わるルビは実現できず、 % 一度組版してみた上で手動で調整しなければならなかった。 % % \texlevel % (u)\pLaTeX において自動切り替えルビを実現する以前の試みとしては、 % \pxrbpkg の作者である八登崇之氏(ZR氏)による検討がマクロツイーター % 「\href{https://zrbabbler.hatenablog.com/entry/20110724/1311503096}{ルビはじめました(PXrubrica パッケージ)(2)}」、 % またそこからリンクがある % \TeX\ Q \& A「\href{https://okumuralab.org/~okumura/texfaq/qa/55536.html}{Re: マクロでの行頭・行末判定方法}」 % に見られる。 % これらのページでは\cs{discretionary}および\pdfTeX の拡張機能(\epTeX にも実装済み)である\cs{pdfsavepos}について検討した上で、 % \cs{discretionary}は日本語ルビの行分割には力不足(!)だとしている。 % 拡張機能については\pxrbpkg にもこれらを使うことを見越した\cs{rubyuseextra}などのコードの痕跡があるが、\href{https://zrbabbler.hatenablog.com/entry/20120430/1335811160}{残念ながら実装されていない}。 % % \emph{しかしながら\cs{discretionary}によって日本語ルビを行分割させることは可能であり、本パッケージはそれを証明するために実装されている。} % % \section{使い方} % % 単に読み込む。オプションはない。 % % \begin{Verbatim} % \usepackage{outoruby} % \end{Verbatim} % % \pkg{outoruby}は\pxrbpkg がサポートする任意のエンジン/フォーマットをサポートする\footnote{^^A % \pxrbpkg は現在\LaTeX しかサポートしていない。また\pkg{outoruby}は相互参照の仕組みが使えることを前提としている。}。 % % また\pxrbpkg に加え\pkg{ltxcmds}、\pkg{infwarerr}に依存する。いずれも\TeX\ Live収録済み。 % % 本文書の記述は\pxrbpkg\ v1.3e (2023/03/01) に基づく。 % % \bigskip % % 簡単には次のように使う: % % \begin{Verbatim} % あれは\outoruby[][][][]{}{} % % 、、は\pxrbpkg での\@cs\jruby[ % \end{macrocode} % % \Finale % % \catcode`\#=6 % \setlength\marginparwidth{10\zw} % \begin{fullwidth} % % \section{開発} % % このパッケージは\href{https://www.gnu.org/licenses/gpl-3.0.html}{GNU General Public License Version 3}で配布される。 % % リポジトリは % \begin{quote} % \url{https://codeberg.org/kkotsi/outoruby} % \end{quote} % である。バグ報告などはこちらに連絡されたい。 % % \raggedcolumns % \renewcommand\indexname{インデックス} % \IndexPrologue{\section{\indexname}} % \PrintIndex % \setcounter{GlossaryColumns}{3} % \renewcommand\glossaryname{更新履歴} % \GlossaryPrologue{\section{\glossaryname}} % \PrintChanges % \end{fullwidth} %