% hangulmath-doc.tex -- documentation for the hangulmath package
% Copyright (C) 2026 Inkyu Park <icpark00@gmail.com>
% LaTeX Project Public License 1.3c or later.
%
% Compile with:  xelatex hangulmath-doc  (twice)
% Requires the Noto Serif CJK KR font for the Korean prose.
\documentclass[11pt,a4paper]{article}
\usepackage[margin=28mm]{geometry}
\usepackage{amsmath,amssymb}
\usepackage{hangulmath}
\usepackage{array,booktabs,longtable}
\usepackage{xcolor}
\usepackage[hidelinks]{hyperref}

\newfontfamily\koreanfont{Noto Serif CJK KR}[Scale=MatchLowercase]
\newcommand\cs[1]{\texttt{\textbackslash#1}}
\newcommand\meta[1]{\ensuremath{\langle}\textrm{\itshape#1}\ensuremath{\rangle}}
\newcommand\marg[1]{\texttt{\{}\meta{#1}\texttt{\}}}
\newcommand\ko[1]{{\koreanfont #1}}
\newenvironment{koreanpar}
  {\par\koreanfont\sloppy\linespread{1.35}\selectfont}{\par}
\newenvironment{preface}[1]
  {\begin{quote}\setlength\parindent{0pt}\setlength\parskip{0.6ex}%
   #1\linespread{1.3}\selectfont}
  {\end{quote}}
\newenvironment{example}
  {\par\medskip\noindent\begin{minipage}{\linewidth}\small}
  {\end{minipage}\par\medskip}

\setlength\parindent{0pt}
\setlength\parskip{0.6ex}

\title{\textsf{hangulmath}\\[0.5ex]
  \large Hangul jamo as mathematical symbols}
\author{Inkyu Park \\ \texttt{icpark00@gmail.com}}
\date{Version 0.5 \quad 2026/10/10}

\begin{document}
\maketitle

\begin{center}
  {\LARGE\koreanfont 訓民正號}\\[0.5ex]
  {\large\koreanfont 훈민정호 \textrm{---} 백성을 가르치는 바른 기호}\\[0.3ex]
  {\itshape The Correct Symbols for the Instruction of the People}
\end{center}

\begin{preface}{\koreanfont\sloppy}
수식의 기호가 로마와 희랍의 글자에만 머물러 그 수가 넉넉지 아니하니,
이런 까닭으로 어리석은 수학자가 적고자 하는 바가 있어도
마침내 제 뜻을 수식에 실어 펴지 못하는 이가 많으니라.

내 이를 위하여 어여삐 여겨 새로 마흔 자를 수식에 들이노니,
자음 열아홉과 모음 스물하나라.
\[
  \#\{\giug,\ \niun,\ \diud,\ \dots,\ \uih,\ \euih\} = 19 + 21 = 40
\]
사람마다 쉬이 익혀 날마다 수식을 씀에 편안케 하고자 할 따름이니라.

\hfill 병오년(2026) 한글날
\end{preface}

\begin{preface}{}
Because the symbols of mathematics dwell only among the letters of Rome
and of Greece, they are not sufficient in number; and for this cause
there be many a humble mathematician who, having something he would set
down, can never at the last express his meaning in a formula.

Taking pity upon them, I have newly brought forty letters into
mathematics: nineteen consonants and twenty-one vowels.
\[
  \#\{\giug,\ \niun,\ \diud,\ \dots,\ \uih,\ \euih\} = 19 + 21 = 40
\]
I desire only that every person may learn them with ease, and use them
in comfort day by day.

\hfill \textit{Given on Hangul Day, in the year 2026}
\end{preface}

\clearpage
\tableofcontents
\clearpage

% ===================================================================
\section{Introduction}

Mathematical notation draws almost entirely on the Latin and Greek
alphabets, and in a long paper one easily runs out of distinct letters.
The Korean alphabet, Hangul, offers a clean supply of new symbols: its
letters (\emph{jamo}) are built from simple geometric strokes, are
visually distinct from Latin and Greek, and each has a well-established
name.

The \textsf{hangulmath} package makes the 40 jamo of modern Hangul
available in mathematics: 14 basic consonants, 5 double consonants,
10 basic vowels and 11 compound vowels. Each symbol has a command
named after the letter, so $\giyeok$ is \cs{giyeok}, much as $\alpha$
is \cs{alpha}. Consonants also have a four-letter alias that is easy to
remember (\cs{giug}).

\begin{example}
\[
  \hangulsum\tiut_{k=1}^{n} \giug_k^{\,2}
  \;\le\; \Bigl(\hangulsum\tiut_{k=1}^{n} \giug_k\Bigr)^{2},
  \qquad
  \mium^2 \vec{A} = -\mu_0 \vec{J},
  \qquad
  \hangullim\liul_{x\to\infty} f(x) = b.
\]
\end{example}

The symbols are taken from a bundled subset of the Noto Sans CJK KR
typeface, so no Korean font needs to be installed.

% ===================================================================
\section{Requirements and installation}

\textsf{hangulmath} requires \textbf{XeLaTeX or LuaLaTeX} (it uses
\textsf{fontspec}) and a LaTeX kernel from 2022 or later. It does not
work with pdfLaTeX; the package stops with an error if loaded there.

\paragraph{TeX Live and MiKTeX.} Once the package is distributed via
CTAN it is installed with the usual package manager
(\texttt{tlmgr install hangulmath}, or automatically by MiKTeX).

\paragraph{Manual installation.} Copy the following files into the
directory of your document, or into your local \texttt{texmf} tree
(\texttt{tex/latex/hangulmath/} and \texttt{fonts/opentype/public/hangulmath/}),
then run \texttt{mktexlsr} if appropriate:
\begin{quote}\ttfamily
hangulmath.sty\\ hangulmath-metrics.def\\
hangulmath-sans.otf\\ hangulmath-sans-light.otf
\end{quote}

\paragraph{Overleaf.} Upload the four files above into your project
and set the compiler to XeLaTeX (\emph{Menu} $\to$ \emph{Compiler}),
or add a file \texttt{latexmkrc} containing \verb|$pdf_mode = 5;|.

% ===================================================================
\section{Usage}

\begin{verbatim}
\usepackage{hangulmath}
...
$\giyeok + \nieun = \digeut$   or, with aliases,   $\giug + \niun = \diud$
\end{verbatim}

Every symbol command works in math mode and also in running text (it
uses \cs{ensuremath}). The symbols are ordinary math symbols
(\cs{mathord}): they take sub- and superscripts and scale correctly in
script styles. They are always set upright, whatever the surrounding
text font.

\begin{example}
\verb|$\giug_{\ah}(x)$, $\niun^{\ih j}$, $X\giug x\niun$|
\hfill
$\giug_{\ah}(x)$, $\niun^{\ih j}$, $X\giug x\niun$
\end{example}

\subsection{Package options}

\begin{longtable}{@{}>{\ttfamily}l p{0.62\linewidth}@{}}
\toprule
option & meaning\\ \midrule
font=\meta{font} & Font for the symbols, given by name or file name.
  Default: the bundled \texttt{hangulmath-sans.otf}
  (HangulMath Sans DemiLight).\\
opfont=\meta{font} & Font for the large operator forms
  (Section~\ref{sec:operators}). Default: the bundled, lighter
  \texttt{hangulmath-sans-light.otf}.\\
metrics=\meta{file} & Name (without \texttt{.def}) of the metrics file that
  describes the glyphs of \texttt{font}. Default:
  \texttt{hangulmath-metrics}, which matches the bundled font.
  See Section~\ref{sec:fonts}.\\
scale=\meta{number} & Scale factor for the symbol font. Default: taken from the
  metrics file (about 1.24 for the bundled font).\\
sidebearing=\meta{em} & Space, in em, added to the left and right of each
  glyph. Default: \texttt{0.06}.\\
\bottomrule
\end{longtable}

If a requested font is not installed, \textsf{hangulmath} issues a
warning and uses the bundled font instead, so that documents always
compile.

% ===================================================================
\section{The symbols}

\subsection{Naming rules}

\begin{itemize}
\item \textbf{Official names} follow the Revised Romanization of Korean:
  \cs{giyeok}, \cs{nieun}, \dots, \cs{ssanggiyeok}.
\item \textbf{Consonant aliases} have four letters: the consonant,
  \texttt{iu}, and the consonant again, imitating the shape of the
  Korean letter names (\ko{기역} $\to$ \cs{giug}, \ko{니은} $\to$
  \cs{niun}). Their first letters are all different, so the first letter
  alone identifies the consonant. Two adjustments are needed:
  \ko{ㅇ} has no initial sound and is \cs{iung}; \ko{ㅊ} is written
  with \texttt{c} to keep four letters, \cs{ciuc}. \ko{ㄹ} uses
  \texttt{l}, its sound at the end of a syllable.
\item \textbf{Double consonants} double the first letter of the alias:
  \cs{ggiug}, \cs{ddiud}, \cs{bbiub}, \cs{ssius}, \cs{jjiuj}.
\item \textbf{Vowels} are written as pronounced, followed by \texttt{h}:
  \cs{ah}, \cs{eoh}, \cs{ih}. The trailing \texttt{h} avoids clashes
  with existing commands such as \cs{a}, \cs{o}, \cs{u} and \cs{i}.
  In compound vowels the glide \emph{w} is written \texttt{u}
  (\cs{uah} for \ko{ㅘ}). \ko{ㅢ} is \cs{euih} (\ko{ㅡ}+\ko{ㅣ}) to
  distinguish it from \ko{ㅟ}, \cs{uih}.
\end{itemize}

\subsection{Consonants}

\noindent\begin{minipage}[t]{0.49\linewidth}
\begin{tabular}{@{}c>{\ttfamily}l>{\ttfamily}l>{\ttfamily\small}l@{}}
\toprule
 & official & alias & Unicode\\ \midrule
$\giyeok$ & \textbackslash giyeok & \textbackslash giug & U+3131\\
$\nieun$  & \textbackslash nieun  & \textbackslash niun & U+3134\\
$\digeut$ & \textbackslash digeut & \textbackslash diud & U+3137\\
$\rieul$  & \textbackslash rieul  & \textbackslash liul & U+3139\\
$\mieum$  & \textbackslash mieum  & \textbackslash mium & U+3141\\
$\bieup$  & \textbackslash bieup  & \textbackslash biub & U+3142\\
$\siot$   & \textbackslash siot   & \textbackslash sius & U+3145\\
\bottomrule
\end{tabular}
\end{minipage}\hfill
\begin{minipage}[t]{0.49\linewidth}
\begin{tabular}{@{}c>{\ttfamily}l>{\ttfamily}l>{\ttfamily\small}l@{}}
\toprule
 & official & alias & Unicode\\ \midrule
$\ieung$  & \textbackslash ieung  & \textbackslash iung & U+3147\\
$\jieut$  & \textbackslash jieut  & \textbackslash jiuj & U+3148\\
$\chieut$ & \textbackslash chieut & \textbackslash ciuc & U+314A\\
$\kieuk$  & \textbackslash kieuk  & \textbackslash kiuk & U+314B\\
$\tieut$  & \textbackslash tieut  & \textbackslash tiut & U+314C\\
$\pieup$  & \textbackslash pieup  & \textbackslash piup & U+314D\\
$\hieut$  & \textbackslash hieut  & \textbackslash hiuh & U+314E\\
\bottomrule
\end{tabular}
\end{minipage}

\subsection{Double consonants}

\begin{tabular}{@{}c>{\ttfamily}l>{\ttfamily}l>{\ttfamily\small}l@{}}
\toprule
 & official & alias & Unicode\\ \midrule
$\ssanggiyeok$ & \textbackslash ssanggiyeok & \textbackslash ggiug & U+3132\\
$\ssangdigeut$ & \textbackslash ssangdigeut & \textbackslash ddiud & U+3138\\
$\ssangbieup$  & \textbackslash ssangbieup  & \textbackslash bbiub & U+3143\\
$\ssangsiot$   & \textbackslash ssangsiot   & \textbackslash ssius & U+3146\\
$\ssangjieut$  & \textbackslash ssangjieut  & \textbackslash jjiuj & U+3149\\
\bottomrule
\end{tabular}

\subsection{Vowels and compound vowels}

\noindent\begin{minipage}[t]{0.49\linewidth}
\begin{tabular}{@{}c>{\ttfamily}l>{\ttfamily\small}l@{}}
\toprule
 & command & Unicode\\ \midrule
$\ah$   & \textbackslash ah   & U+314F\\
$\yah$  & \textbackslash yah  & U+3151\\
$\eoh$  & \textbackslash eoh  & U+3153\\
$\yeoh$ & \textbackslash yeoh & U+3155\\
$\oh$   & \textbackslash oh   & U+3157\\
$\yoh$  & \textbackslash yoh  & U+315B\\
$\uh$   & \textbackslash uh   & U+315C\\
$\yuh$  & \textbackslash yuh  & U+3160\\
$\euh$  & \textbackslash euh  & U+3161\\
$\ih$   & \textbackslash ih   & U+3163\\
\bottomrule
\end{tabular}
\end{minipage}\hfill
\begin{minipage}[t]{0.49\linewidth}
\begin{tabular}{@{}c>{\ttfamily}l>{\ttfamily\small}l@{}}
\toprule
 & command & Unicode\\ \midrule
$\aeh$  & \textbackslash aeh  & U+3150\\
$\yaeh$ & \textbackslash yaeh & U+3152\\
$\eh$   & \textbackslash eh   & U+3154\\
$\yeh$  & \textbackslash yeh  & U+3156\\
$\uah$  & \textbackslash uah  & U+3158\\
$\uaeh$ & \textbackslash uaeh & U+3159\\
$\oeh$  & \textbackslash oeh  & U+315A\\
$\ueoh$ & \textbackslash ueoh & U+315D\\
$\ueh$  & \textbackslash ueh  & U+315E\\
$\uih$  & \textbackslash uih  & U+315F\\
$\euih$ & \textbackslash euih & U+3162\\
\bottomrule
\end{tabular}
\end{minipage}

% ===================================================================
\section{Operator forms}\label{sec:operators}

The symbol commands produce ordinary symbols. To use a symbol as an
operator, wrap it in one of the following commands. They accept any
math symbol, not only Hangul.

\begin{longtable}{@{}>{\ttfamily}l p{0.62\linewidth}@{}}
\toprule
command & behaviour\\ \midrule
\textbackslash hangulsum\{\meta{sym}\} & Large; in display style, limits
  below and above (like \cs{sum}).\\
\textbackslash hangulint\{\meta{sym}\} & Large; limits at the side
  (like \cs{int}).\\
\textbackslash hangullim\{\meta{sym}\} & Normal size; in display style,
  limits below (like \cs{lim}).\\
\textbackslash hangulopscale\{\meta{d}\}\{\meta{t}\} & Sets the
  magnification of the large forms in display and text style
  (defaults 2.0 and 1.3).\\
\bottomrule
\end{longtable}

The large forms are drawn with the lighter operator font
(\texttt{opfont}), so that magnification does not make their strokes
heavier than those of \cs{sum} and \cs{int}.

\begin{example}
\begin{verbatim}
\[ \hangulsum\tiut_{k=1}^{n} k^2 = \frac{n(n+1)(2n+1)}{6} \]
\end{verbatim}
\[
  \hangulsum\tiut_{k=1}^{n} k^2 = \frac{n(n+1)(2n+1)}{6},
  \qquad
  \hangulsum\tiut_{i=1}^{m}\hangulsum\tiut_{j=1}^{n} a_{ij}
  \quad\text{vs.}\quad
  \sum_{i=1}^{m}\sum_{j=1}^{n} a_{ij}
\]
Inline: $\hangulsum\tiut_{k=1}^{n} \giug_k = \sum_{k=1}^{n} \giug_k$.
\end{example}

\begin{example}
\begin{verbatim}
\[ \hangulint\diud_{x=0}^{x=1} f(x) = a \qquad
   \hangullim\liul_{x\to\infty} f(x) = b \]
\end{verbatim}
\[
  \hangulint\diud_{x=0}^{x=1} f(x) = a
  \qquad
  \hangullim\liul_{x\to\infty} f(x) = b
  \qquad
  \hangullim\liul_{n\to\infty}\Bigl(1+\frac{1}{n}\Bigr)^{n} = e
\]
\end{example}

% ===================================================================
\section{More examples}

\paragraph{\cs{mium} as the d'Alembertian.} The shape of
$\mieum$ suggests the box operator.
\begin{example}
\begin{verbatim}
\mium^2 \equiv \nabla^2 - \mu_0\epsilon_0 \frac{\partial^2}{\partial t^2},
\qquad \mium^2 \vec{A} = -\mu_0 \vec{J}
\end{verbatim}
\[
  \mium^2 \equiv \nabla^2 - \mu_0 \epsilon_0 \frac{\partial^2}{\partial t^2},
  \qquad
  \mium^2 \vec{A} = -\mu_0 \vec{J}
\]
\end{example}

\paragraph{Pre- and post-scripts.} Like any ordinary symbol, a jamo can
carry scripts on both sides, for instance in a hypergeometric-style
notation.
\begin{example}
\begin{verbatim}
{}_{123}\biub_{45}, \qquad {}_{2}\biub_{1}(a,b;c;z), \qquad
{}^{\ih}_{\ah}\biub^{\uh}_{\oh}
\end{verbatim}
\[
  {}_{123}\biub_{45},
  \qquad
  {}_{2}\biub_{1}(a,b;c;z),
  \qquad
  {}^{\ih}_{\ah}\biub^{\uh}_{\oh}
\]
\end{example}

\paragraph{Mixed with Latin and Greek.} Jamo combine freely with other symbols.
\begin{example}
\[
  \giug_{\ah}(x) = \sum_{\niun=0}^{\infty} \frac{\diud^{\niun}}{\niun!}\, x^{\liul_{\ih}},
  \qquad
  \alpha\giug\beta\niun\gamma,
  \qquad
  \ssius_{\uah} + \ggiug^{\euih}
\]
\end{example}

% ===================================================================
\section{Using other fonts}\label{sec:fonts}

Hangul compatibility jamo are drawn small and high in the em square of
most Korean fonts, with large side bearings. \textsf{hangulmath}
therefore scales all glyphs by a common factor, lowers them by a common
amount so that consonants sit on the baseline, and trims each glyph to
its ink. These values depend on the font and are stored in a metrics
file.

To use another font, generate a metrics file with the Python script
\texttt{hangulmath-metrics.py} (Python 3.10+, \texttt{pip install
fonttools}):
\begin{verbatim}
python3 hangulmath-metrics.py "Nanum Gothic" -o nanum.def
\end{verbatim}
and load it together with the font:
\begin{verbatim}
\usepackage[font={Nanum Gothic}, metrics=nanum]{hangulmath}
\end{verbatim}
\cs{hangulmathfont}\marg{font} and \cs{hangulmathopfont}\marg{font} change the
fonts later in the preamble.

% ===================================================================
\section{Caveats}

\begin{itemize}
\item \textbf{Look-alikes.} $\euh$ resembles a minus sign and $\ih$ a
  vertical bar. Use them with care, and say in the text which letter
  you mean.
\item \textbf{Engines.} pdfLaTeX is not supported. Check whether your
  publisher or preprint server compiles with XeLaTeX or LuaLaTeX before
  relying on the package for a submission.
\item \textbf{Searchability.} The symbols are real Unicode characters in
  the PDF, so they can be copied and searched.
\end{itemize}

% ===================================================================
\section{Korean summary \ko{(한국어 요약)}}

\begin{koreanpar}
hangulmath는 현대 한글 자모 40자(기본 자음 14, 쌍자음 5, 기본 모음 10,
복모음 11)를 수식 기호로 쓸 수 있게 하는 패키지입니다.
XeLaTeX 또는 LuaLaTeX에서 동작하며, 기호용 고딕체 글꼴이 함께 들어 있어
따로 한글 글꼴을 설치할 필요가 없습니다.

명령어는 로마자 표기법에 따른 공식 이름(\cs{giyeok})과 외우기 쉬운 네
글자 약어(\cs{giug})가 있습니다. 약어는 자음, iu, 자음의 순서이며,
쌍자음은 첫 글자를 두 번 씁니다(\cs{ggiug}). 모음은 소리 나는 대로 쓰고
끝에 h를 붙입니다(\cs{ah}, \cs{uah}).

합, 적분, 극한처럼 쓰려면 \cs{hangulsum}, \cs{hangulint},
\cs{hangullim}으로 감쌉니다.
\begin{center}\verb|\hangulsum\tiut_{k=1}^{n} a_k|\quad $\Rightarrow$\quad $\displaystyle\hangulsum\tiut_{k=1}^{n} a_k$\end{center}
\end{koreanpar}

% ===================================================================
\section{License}

Copyright \copyright\ 2026 Inkyu Park.

The package files may be distributed and/or modified under the
conditions of the \LaTeX\ Project Public License, version 1.3c or (at
your option) any later version.

The bundled fonts \texttt{hangulmath-sans.otf} and
\texttt{hangulmath-sans-light.otf} are modified (subset and renamed)
versions of Noto Sans CJK KR, copyright 2014--2021 Adobe, and are
distributed under the SIL Open Font License 1.1; see \texttt{OFL.txt}.
They are rebuilt with \texttt{hangulmath-fonts.py}.

\section{Change history}

\begin{description}
\item[v0.5 (2026/10/10)] First public release.
\end{description}

\end{document}
