\documentclass[a4j]{ujarticle}
\usepackage{ascmac}
\def\yen{\noautoxspacing\symbol{92}}%
\usepackage{url}
\usepackage[dvipdfmx]{hyperref}
\usepackage{pxjahyper}
\usepackage{fancyvrb}
\begin{document}

\section*{kanruby.sty/kanruby.mf v.1.0 User Manual}
\begin{flushright}
Date: 2026-11-11
\end{flushright}

This package is a UTF-8 compatible version, updated in 2026,
of a package previously released by the author.
It is newly released here under the LPPL 1.3c license.  
\medskip

Originally, I created convenient kunten(reading marks) macros
for use in high school Japanese classes,
similar to what is found in ``Introduction to Kambun Kunten''
(\url{https://rakunet.org/p/2022/0729}),
and used them in my teaching.
However, in response to requests from Japanese literature researchers at universities
and with the assistance of professionals using \TeX{} in the printing industry,
we exchanged opinions primarily on the Nifty forum.
This package was created as a result,
designed to support typesetting for academic books to a certain extent.  
\medskip

Initially, it was designed to work in conjunction with Kinokuniya's Konjaku Mojikyo font,
but that support has now been removed, and it is released as a package usable with Unicode.
\medskip

I have confirmed that with a little ingenuity,
it can handle typesetting at the level of high school Kambun textbooks incorporating notes and images.
Furthermore, typesetting at the level of Taishukan's Kambun Taikei is also possible.  
\medskip

However, if you are typesetting Kambun for high school or university entrance exams,
it would be much easier to use the kambunsnx package mentioned in Introduction to Kambun Kunten.
This is because the book I previously published,
``Ask the Entrance Exam! Kambun''
(\url{https://www.amazon.co.jp/s?k=475393165X}),
was typeset and printed exactly as is using that package.  
\medskip

As shown in the samples below,
this package includes METAFONTs for fonts used exclusively in Kambun to some extent.
Additionally, it allows for somewhat fine-grained specification of the size
and position of the kunten placed around the Kanji.
For further details, please see the output samples below.   
\medskip

You can also find a similar instruction manual at ``Kunten Macro kanruby''
(\url{https://rakunet.org/p/2026/0812}).


\subsection*{Package Contents}

\begin{itemize}
\item README*.md
\item kanruby-doc*.tex/pdf User Manual
\item kanruby.sty Style file
\item ukanruby.fd Font definition file for using kanruby.mf
\item kanruby.mf METAFONT source for Kambun
\item kanruby.tfm TFM file for kanruby.mf
\item examples/* Sample files
\end{itemize}

\subsection*{Installation}

I will explain using Linux, the environment I can verify.
You should be able to install it similarly in other environments.
In that case, please pay attention to character encoding and line break codes.

\begin{enumerate}
\item Unzip kanruby.zip.
\item Move kanruby.sty and ukanruby.fd to a directory like the following:\\
\verb|~/texmf/tex/platex|
\item Move kanruby.tfm to a directory like the following:\\
\verb|~/texmf/fonts/tfm/public/kanruby|
\item Move kanruby.mf to a directory like the following:\\
\verb|~/texmf/fonts/source/public/kanruby|
\item Execute the following command:\\
\verb|sudo mktexlsr|
\end{enumerate}

\subsection*{Installation verification}

\noindent
{\tt kanruby-sample.tex}
\begin{verbatim}
\documentclass[a4j]{utarticle}
\usepackage{kanruby}
\begin{document}
\kanrubyon
\noindent
{\LARGE
麗\kanruby<1>[.2]<.6>{かな}
麗\kanruby<1>[.8]<.4>{カナ}
麗\kanruby<1>[1][-0.4]{\footnotesize 。}
麗\kanruby<3>[0]{\footnotesize 左注}
麗\kanruby<3>[1][-0.3]{上}
\let\kanrubysize=\footnotesize
麗\kanruby<1>[0]{□□}
\kankunoji\kanruby<1>[0]{}
\kangunoji\kanruby<1>[0]{}
麗
}%
\kanrubyoff
\bigskip

おめでとうございます！
kanruby.styのインストールは成功です。
\end{document}
\end{verbatim}

Let's try executing the following commands:
\begin{verbatim}
uplatex kanruby-sample
dvipdfmx kanruby-sample
\end{verbatim}

If kanruby-sample.pdf is created
and the image, showing various kunten marks around the Kanji,
is displayed in your PDF viewer, it is successful.


\subsection*{Usage Examples}

\subsubsection*{kanruby-sample01.tex Example of writing standard Kambun}

\begin{verbatim}
\documentclass[a4j]{utarticle}
\usepackage{kanruby}
\def\yen{\noautoxspacing\symbol{92}}%
\begin{document}
\noindent
通常の漢文を書いた例です（{\tt \yen{}Large}がふつうでしょう）。
字間は{\tt \yen{}kanjiskip}を変えることによって調整します。
\bigskip

% 漢字間の空白を広くする({\tt \yen{}normalsize}の0.5倍)。
\kanrubyon%
\noindent
{\Large
\Kan{見}{}{}{二}
\Kan{胤}{いん}{ヲ}{}
於童幼之
\Kan{中}{うち}{ニ}{一}
\Kuto{、}
\Kan{謂}{}{ヒテ}{二}
\Kan{胤}{}{ノ}{}
\Kan{父}{}{ニ}{一}
\Kan{曰}{}{ク}{}
...
\end{document}
\end{verbatim}

\subsubsection*{kanruby-sample02.tex Example of writing Kambun in various sizes}

\begin{verbatim}
\documentclass[a4j]{utarticle}
\usepackage{kanruby}
\def\yen{\noautoxspacing\symbol{92}}%
\begin{document}
\noindent
いろいろなサイズの漢文を書いた例です。
\bigskip

\kanrubyon
\let\kanrubysize=\tiny
\noindent
% \smallより\kansmallの方が訓点等の位置がうまく調整される。
{\kansmall
\Kan{見}{}{}{二}
\Kan{胤}{いん}{ヲ}{}
於童幼之
\Kan{中}{うち}{ニ}{一}
\Kuto{、}
\Kan{謂}{}{ヒテ}{二}
\Kan{胤}{}{ノ}{}
\Kan{父}{}{ニ}{一}
\Kan{曰}{}{ク}{}
...
\end{document}
\end{verbatim}

\subsubsection*{kanruby-sample03.tex Example of using kanruby.mf fonts}


\subsubsection*{kanruby-sample04.tex Example of using warichu (inline split notes)}

\begin{verbatim}
\documentclass[a4j]{utarticle}
\usepackage{kanruby}
\def\KanW#1#2{#1\kanruby<3>[1][-0.4]{#2}\hskip.8zw}
\def\KutoW#1{\hskip-.5zw\kanruby<1>[1][-0.65]<.5>{\scriptsize #1}}
\begin{document}
\noindent
{\kanlarge
\kanrubyon
「%
\Kan{未}{}{ダ}{二}
\kanwari<1>{ふつうの}{割注。　}
嘗
\setlength{\kanwariskip}{-1pt}%
\kanwari<2>{行間を詰}{めたり、}
\setlength{\kanwariskip}{3pt}
\kanwari<0>{広げまく}{ったり、~}
\setlength{\kanwariskip}{0pt}
\kanwari<3>{元に戻した~}{りする割注。}
\Kan{終}{}{ラ}{一}
\Kuto{。}」
}%
\bigskip
...
\end{document}
\end{verbatim}

\subsubsection*{kanruby-sample05.tex Example of outputting number frames}


\subsubsection*{kanruby-sample06.tex Example of adding special ruby}

\begin{Verbatim}
\documentclass[a4j]{utarticle}
\usepackage{ascmac}
\usepackage{kanruby}
\begin{document}
\section*{特別なルビを付す例}

kanrubyコマンドは、出力した一文字の直後に置き、
その漢字の上下左右の場所に特定の文字列を出力する命令を付加します。
その後、何事もなかったかのように、後続の文字に処理を移します。
\medskip

\small
\setbox0=\hbox{%
\begin{minipage}<y>[t]{65mm}
\begin{verbatim}
\kanrubyon%
\noindent
{\LARGE
麗\kanruby<1>[.2]<.6>{かな}
麗\kanruby<1>[.8]<.4>{カナ}
麗\kanruby<1>[1][-0.4]{\footnotesize 。}
麗\kanruby<3>[0]{\footnotesize 左注}
麗\kanruby<3>[1][-0.3]{上}
\let\kanrubysize=\footnotesize
麗\kanruby<1>[0]{□□}
\kankunoji\kanruby<1>[0]{}
\kangunoji\kanruby<1>[0]{}
麗}%
\end{verbatim}
\end{minipage}}
\normalsize%
...
\end{document}
\end{Verbatim}

\subsubsection*{kanruby-sample07.tex Example of enclosing in a frame and adding pronunciation marks}


For more details, please read kanruby.sty itself. 
Enjoy your happy \TeX{} life!

\end{document}
