Skip to main content

How to Create Japanese PDFs with pLaTeX

· 10 min read

A guide to creating Japanese PDF documents with pLaTeX — from document structure and templates to compilation and common error fixes.

What is pLaTeX?

pLaTeX is a LaTeX implementation designed for Japanese typesetting. It compiles .tex files with the platex command and converts them to PDF using dvipdfmx.

It is included in TeX Live and ready to use once installed. For installation instructions, see Installing TeX Live 2026 on Linux.

Choosing a Document Class

Use the following classes for Japanese documents.

ClassUse case
jarticleShort documents such as papers and reports
jbookLong documents with chapter structure
jreportTechnical reports (abstract + chapter structure)
beamerPresentations

Template (jarticle)

A comprehensive sample using jarticle is shown below.

Show sample code
% pLaTeX sample document — covers major features
\documentclass[a4paper,12pt]{jarticle}

%% ========== Packages ==========
\usepackage{amsmath, amssymb} % Enhanced math
\usepackage{graphicx} % Include figures
\usepackage{color} % Color support
\usepackage{fancyhdr} % Headers and footers
\usepackage{geometry} % Page layout
\usepackage{enumerate} % Custom list labels
\usepackage{url} % URL formatting
\usepackage{multicol} % Multi-column layout
\usepackage{booktabs} % High-quality table rules
\usepackage{array} % Extended table column formats
\usepackage{verbatim} % Verbatim environment
\usepackage{ascmac} % Box environments (screen, itembox, etc.)
\usepackage{okumacro} % Ruby, kenten, etc. (pLaTeX standard)
\usepackage{setspace} % Line spacing control
\usepackage{listings} % Source code listings
\usepackage{xcolor} % Colors (for listings)
\usepackage{caption} % Caption formatting

%% ========== Page Layout ==========
\geometry{top=25mm, bottom=25mm, left=25mm, right=25mm}
\setlength{\headheight}{17pt}
\addtolength{\topmargin}{-5pt}

%% ========== Headers and Footers ==========
\pagestyle{fancy}
\fancyhf{}
\lhead{pLaTeX Sample Document}
\rhead{\today}
\cfoot{\thepage}
\renewcommand{\headrulewidth}{0.4pt}

%% ========== listings Settings ==========
\lstset{
basicstyle=\ttfamily\small,
keywordstyle=\color{blue}\bfseries,
commentstyle=\color{green!50!black},
stringstyle=\color{red!70!black},
numbers=left,
numberstyle=\tiny\color{gray},
frame=single,
breaklines=true,
tabsize=4,
}

%% ========== Title Information ==========
\title{\textbf{pLaTeX Feature Showcase}\\[5pt]
\large --- Typical usage of Japanese \LaTeX ---}
\author{John Doe\thanks{Department of Computer Science, Sample University}
\and Jane Doe}
\date{\today}

%% ================================================================
\begin{document}
%% ================================================================

\maketitle
\thispagestyle{fancy}

\begin{abstract}
This document demonstrates the major features of pLaTeX.
It covers document class and package loading, Japanese typesetting features,
math environments, tables, figures, cross-references, footnotes,
ruby (furigana), kenten (emphasis dots), source code listings,
multi-column layout, and custom commands.
\end{abstract}

\tableofcontents
\newpage

%% ================================================================
\section{Japanese Typesetting Basics}
%% ================================================================

\subsection{Mixing Japanese and Latin Text}

pLaTeX handles Japanese and Latin text naturally in the same document.
ASCII characters such as ``Hello, World!'' and \texttt{LaTeX2e}
are automatically spaced appropriately.

Spacing between full-width and half-width characters is adjusted automatically:
JapaneseEnglishJapanese, numbers 123 Japanese, symbol \% Japanese.

\subsection{Ruby (Furigana)}

The \verb|\ruby| command from the \texttt{okumacro} package adds ruby annotations.

\begin{center}
\ruby{漢字}{かんじ}、\ruby{情報処理}{じょうほうしょり}、
\ruby{自然言語}{しぜんげんご}\ruby{処理}{しょり}
\end{center}

\subsection{Kenten (Emphasis Dots)}

The \verb|\kenten| command from \texttt{okumacro} adds emphasis dots above characters.

\begin{center}
\kenten{Important text} can be emphasized with kenten dots.
\end{center}

\subsection{Font Sizes}

{\tiny tiny} {\scriptsize scriptsize} {\footnotesize footnotesize} {\small small}
{\normalsize normalsize} {\large large} {\Large Large} {\LARGE LARGE}
{\huge huge} {\Huge Huge}

\subsection{Text Decoration}

\begin{itemize}
\item \textbf{Bold}
\item \textit{Italic}
\item \textsl{Slanted}
\item \textsc{Small Caps}
\item \texttt{Typewriter (monospace)}
\item \underline{Underlined text}
\item \textcolor{red}{Red text}
\item \textcolor{blue!70!black}{Blue text}
\item \colorbox{yellow}{Highlighted background}
\end{itemize}

%% ================================================================
\section{Document Structure}
%% ================================================================

\subsection{Heading Levels}

\texttt{jarticle} supports the following heading levels:
\verb|\section|, \verb|\subsection|, \verb|\subsubsection|,
\verb|\paragraph|, and \verb|\subparagraph|.

\subsubsection{Subsubsection Example}
This is a subsubsection.

\paragraph{Paragraph Heading}
This is an example of a paragraph heading. Body text follows without indentation.

\subsection{Footnotes}

Footnotes\footnote{This is the footnote text. It is placed automatically at the bottom of the page.}
can be added inline. Multiple footnotes\footnote{A second footnote. Numbers are assigned automatically.}
are supported.

\subsection{Cross-references}

Adding \verb|\label| allows referencing with \verb|\ref| and \verb|\pageref|.
Example: the next section is Section~\ref{sec:math} (page~\pageref{sec:math}).

%% ================================================================
\section{Math Environments}
\label{sec:math}
%% ================================================================

\subsection{Inline and Display Math}

Inline math: $E = mc^2$, $\alpha + \beta = \gamma$,
$\sum_{i=1}^{n} i = \frac{n(n+1)}{2}$.

Display math:
\[
\int_{-\infty}^{\infty} e^{-x^2}\,dx = \sqrt{\pi}
\]

\subsection{equation and align Environments}

Numbered equation (\texttt{equation}):
\begin{equation}
\label{eq:euler}
e^{i\pi} + 1 = 0
\end{equation}
Equation~\eqref{eq:euler} is Euler's identity.

Multi-line alignment (\texttt{align}):
\begin{align}
(a+b)^2 &= a^2 + 2ab + b^2 \\
(a-b)^2 &= a^2 - 2ab + b^2 \\
(a+b)(a-b) &= a^2 - b^2
\end{align}

\subsection{Matrices and Vectors}

\begin{equation}
A = \begin{pmatrix} a_{11} & a_{12} \\ a_{21} & a_{22} \end{pmatrix},\quad
\det(A) = a_{11}a_{22} - a_{12}a_{21}
\end{equation}

\subsection{Cases, Fractions, and Limits}

\begin{equation}
f(x) = \begin{cases}
x^2 & (x \geq 0) \\
-x^2 & (x < 0)
\end{cases}, \qquad
\lim_{n\to\infty} \left(1 + \frac{1}{n}\right)^n = e
\end{equation}

%% ================================================================
\section{Tables (tabular Environment)}
%% ================================================================

\subsection{Basic Table}

\begin{table}[h]
\centering
\caption{Temperature Data by City (sample)}
\label{tab:temp}
\begin{tabular}{lrrr}
\toprule
City & High (°C) & Low (°C) & Avg (°C) \\
\midrule
Tokyo & 35.2 & 25.1 & 29.8 \\
Osaka & 36.4 & 26.3 & 31.0 \\
Sapporo & 28.7 & 19.5 & 23.9 \\
Naha & 32.1 & 27.4 & 29.8 \\
\bottomrule
\end{tabular}
\end{table}

\subsection{Complex Table (\texttt{array} Extension)}

\begin{table}[h]
\centering
\caption{Programming Language Comparison}
\label{tab:lang}
\begin{tabular}{|l|c|c|c|}
\hline
Language & Typing & Paradigm & Main Use \\
\hline\hline
Python & Dynamic & Multi & AI/Data Science \\
Rust & Static & Systems & Systems Programming \\
Haskell & Static & Functional & Research/Finance \\
JavaScript & Dynamic & Multi & Web Frontend \\
\hline
\end{tabular}
\end{table}

Tables~\ref{tab:temp} and~\ref{tab:lang} can be referenced using \verb|\label/\ref|.

%% ================================================================
\section{List Environments}
%% ================================================================

\subsection{Bullet List (itemize)}

\begin{itemize}
\item First item
\item Second item
\begin{itemize}
\item Nested item A
\item Nested item B
\end{itemize}
\item Third item
\end{itemize}

\subsection{Numbered List (enumerate)}

\begin{enumerate}[(1)] % Custom label format via enumerate package
\item First step
\item Next step
\item Final step
\end{enumerate}

\subsection{Description List (description)}

\begin{description}
\item[pLaTeX] Japanese-capable \LaTeX engine
\item[upLaTeX] Unicode-aware successor to pLaTeX
\item[LuaLaTeX] \LaTeX engine with Lua scripting support
\end{description}

%% ================================================================
\section{Verbatim and Source Code}
%% ================================================================

\subsection{verbatim Environment}

\begin{verbatim}
#include <stdio.h>
int main(void) {
printf("Hello, pLaTeX!\n");
return 0;
}
\end{verbatim}

\subsection{Syntax Highlighting with listings}

\begin{lstlisting}[language=Python, caption={Fibonacci sequence (Python)}]
def fibonacci(n: int) -> int:
"""Compute Fibonacci number recursively."""
if n <= 1:
return n
return fibonacci(n - 1) + fibonacci(n - 2)

# Print the first 10 terms
for i in range(10):
print(f"F({i}) = {fibonacci(i)}")
\end{lstlisting}

%% ================================================================
\section{Box Environments}
%% ================================================================

The \texttt{ascmac} package provides \texttt{itembox}, \texttt{screen}, and similar environments.

\begin{itembox}[l]{Key Points}
\begin{itemize}
\item Use \texttt{jarticle} / \texttt{jbook} document classes for Japanese
\item \texttt{okumacro} provides ruby and kenten
\item Generate PDFs with \texttt{platex + dvipdfmx}
\end{itemize}
\end{itembox}

\vspace{5pt}

\begin{screen}
\texttt{screen} environment: a terminal-style box, useful for showing command output or code examples.
\end{screen}

%% ================================================================
\section{Multi-Column Layout}
%% ================================================================

The \texttt{multicol} package enables mid-document column switching.

\begin{multicols}{2}
\noindent
This is the left column of a two-column layout.
pLaTeX handles Japanese text in multi-column layouts naturally.
Long text is distributed evenly across columns automatically,
making it suitable for newspaper or magazine-style typesetting.

\columnbreak

\noindent
This is the right column.
Use \verb|\columnbreak| to force a column break.
Inline math such as $x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}$
works as expected.
\end{multicols}

%% ================================================================
\section{Spacing Adjustments}
%% ================================================================

\subsection{Horizontal Space}

Word spacing: a\,b (\verb|\,| thin space),
a\enspace b (\verb|\enspace|),
a\quad b (\verb|\quad|),
a\qquad b (\verb|\qquad|).

\subsection{Vertical Space}

Use \verb|\vspace| to insert vertical space.

\vspace{5mm}
Text after a 5mm vertical space.
\vspace{5mm}

\subsection{Line Spacing}

{\setstretch{1.8}
This paragraph uses \texttt{setstretch} from the \texttt{setspace} package
to set line spacing to 1.8x.
A spacing of 1.5 to 2.0 is generally considered readable for Japanese text.
}

%% ================================================================
\section{Custom Commands and Environments}
%% ================================================================

\subsection{Defining Custom Commands}

\newcommand{\R}{\mathbb{R}}
\newcommand{\N}{\mathbb{N}}
\newcommand{\highlight}[1]{\colorbox{yellow!60}{#1}}
\newcommand{\term}[1]{\textbf{\textit{#1}}} % Term emphasis

Examples: $\R$ (real numbers), $\N$ (natural numbers).
\highlight{Highlighted text}.
\term{Machine learning} is a subfield of artificial intelligence.

\subsection{Defining Custom Environments}

\newenvironment{mybox}[1]{%
\begin{center}\begin{tabular}{|p{0.85\linewidth}|}
\hline\vspace{1pt}
\textbf{#1}\\[2pt]
}{%
\\\hline\end{tabular}\end{center}
}

\begin{mybox}{Custom Box}
Use \verb|\newenvironment| to define reusable environments.
They can accept arguments for flexible customization.
\end{mybox}

%% ================================================================
\section{References}
%% ================================================================

Cite references with the \verb|\cite| command~\cite{knuth1984,lamport1994,okumura2020}.
The reference list is output at the end of the document.

%% ================================================================
%% Reference list (thebibliography environment)
%% ================================================================
\begin{thebibliography}{99}

\bibitem{knuth1984}
D.~E. Knuth,
\textit{The \TeX book},
Addison-Wesley, 1984.

\bibitem{lamport1994}
L.~Lamport,
\textit{\LaTeX: A Document Preparation System}, 2nd ed.,
Addison-Wesley, 1994.

\bibitem{okumura2020}
H.~Okumura and Y.~Kuroki,
\textit{\LaTeXe Beautiful Document Creation Guide}, 8th ed.,
Gijutsu-Hyoronsha, 2020.

\end{thebibliography}

\end{document}

Compilation

Basic (platex + dvipdfmx)

Run platex twice to resolve cross-references and table of contents, then convert to PDF with dvipdfmx.

platex -interaction=nonstopmode -kanji=utf8 document.tex
platex -interaction=nonstopmode -kanji=utf8 document.tex
dvipdfmx document.dvi

ptex2pdf

ptex2pdf combines the platex + dvipdfmx two-step process into a single command.

Basic Command

ptex2pdf -l -ot "-kanji=utf8 -interaction=nonstopmode" document.tex
OptionMeaning
-lUse latex-based engine (platex)
-ot "..."Options passed to platex
-kanji=utf8Set input encoding to UTF-8
-interaction=nonstopmodeContinue processing without stopping on errors

Steps

  1. Run ptex2pdf twice (to resolve cross-references and table of contents)

    ptex2pdf -l -ot "-kanji=utf8 -interaction=nonstopmode" document.tex
    ptex2pdf -l -ot "-kanji=utf8 -interaction=nonstopmode" document.tex
  2. Check the result

    • Success: document.pdf is generated
    • Error: Check lines starting with ! in the .log file and the 3 surrounding lines
    • Warnings only: Check for Overfull/Underfull hbox, undefined references, etc.
  3. When BibTeX is needed (when a .bib file exists or \bibliography is used)

    ptex2pdf -l -ot "-kanji=utf8 -interaction=nonstopmode" document.tex
    bibtex document
    ptex2pdf -l -ot "-kanji=utf8 -interaction=nonstopmode" document.tex
    ptex2pdf -l -ot "-kanji=utf8 -interaction=nonstopmode" document.tex

    Running ptex2pdf twice after bibtex resolves the cross-references between the reference list and in-text citations.

Common Errors and Fixes

Undefined control sequence

! Undefined control sequence.
l.42 \somecommand

An undefined command is used. The cause is usually a missing package or a typo.

Missing $ inserted

! Missing $ inserted.

A math symbol such as _ (subscript) or ^ (superscript) is used outside math mode. Wrap the expression with $...$.

File not found

! LaTeX Error: File `image.png' not found.

The path specified in \includegraphics is incorrect. Verify the path relative to the .tex file.

Overfull \hbox

Overfull \hbox (12.3pt too wide) in paragraph at lines 55--60

This is a warning, not an error. A line does not fit within the specified width. Long URLs or words are often the cause; use \allowbreak or the \url{} package to fix it.

Checking the Log

The .log file generated after compilation contains detailed error and warning information. Lines starting with ! are errors; lines containing Warning are warnings.

grep -n "^!" document.log        # Extract error lines
grep -n "Warning" document.log # Extract warning lines

Cleaning Up Intermediate Files

Compilation generates many intermediate files. To clean up while keeping the PDF:

rm -f document.aux document.log document.dvi \
document.toc document.lof document.lot \
document.out document.bbl document.blg \
document.synctex.gz

To remove everything including the PDF, add .pdf to the list.

コメント

読み込み中...

コメントを投稿する