Japanese
Different packages exist to support Japanese typesetting for various LaTeX engines, though not all packages fully support all Japanese typesetting conventions e.g. vertical typesetting. This help article briefly outlines how to typeset Japanese with pdfLaTeX, XƎLaTeX, pTeX and LuaLaTeX.
CJKutf8 package with pdfLaTeX
The CJKutf8
package is sufficient if you would like to compile with pdfLaTeX.
\documentclass{article}
\usepackage{CJKutf8}
\begin{document}
\begin{CJK}{UTF8}{min}
\section{これは最初のセクションである}
日本語で \LaTeX の組版を実証するための導入部分。
フォントはまた、数学的な形態および他の環境で使用することができる
\end{CJK}
\bigskip
Outside the environment Latin characters may be used.
\begin{CJK*}{UTF8}{goth}
\section{これは最初のセクションである}
日本語で \LaTeX の組版を実証するための導入部分。
フォントはまた、数学的な形態および他の環境で使用することができる
\end{CJK*}
\end{document}
Open this CJKutf8 example in Overleaf.
This example produces the following output, demonstrating Japanese text typeset using two font families:
The line \usepackage{CJKutf8}
imports the CJKutf8
which enables UTF8 encoding for Chinese, Japanese and Korean characters.
In this case, every block of Japanese text must be typed inside a \begin{CJK*}{UTF8}{min}
environment. In that environment UTF8
is the encoding and min
(Mincho family) is the font to be used in section 1 of the example.
As demonstrated by section 2 of the example, you can replace min
with goth
to use the Gothic family; however, CJKutf8
and pdfLaTeX are not capable of easily using other fonts.
xeCJK package with XeLaTeX
XeLaTeX offers the possibility of using OpenType and TrueType fonts, and the xeCJK
package provides support for Chinese, Japanese and Korean typesetting.
\documentclass{article}
\usepackage{xeCJK}
\setCJKmainfont{IPAMincho}
\setCJKsansfont{IPAGothic}
\setCJKmonofont{IPAGothic}
\begin{document}
\section{これは最初のセクションである}
日本語で \LaTeX の組版を実証するための導入部分。
フォントはまた、数学的な形態および他の環境で使用することができる
\bigskip
And you can also use Latin characters within your Japanese document.
\bigskip
\begin{verbatim}
このテキストは、別のフォントを持つことになります
This is a verbatim environment using a monospaced font.
\end{verbatim}
\end{document}
Open this xeCJK example in Overleaf.
This example produces the following output:
Below is a description of each command:
\usepackage{xeCJK}
: this includes the packagexeCJK
which allows use of Chinese, Japanese and Korean fonts in a document to be compiled with XeLaTeX. See this article for help setting your Overleaf project's compiler.\setCJKmainfont{IPAMincho}
: sets the main font used for this document.\setCJKsansfont{IPAGothic}
: sets the font to be used in elements that require the sans family font.\setCJKmonofont{IPAGothic}
: sets the font to be used in elements that require the monospace family font. In the example the Japanese text inside theverbatim
environment uses this font.
Using Google Noto fonts
Because Google Noto Fonts suitable for use with CJK typesetting are stored on Overleaf's servers, we can use them to repeat the previous example.
\documentclass{article}
\usepackage{xeCJK}
\setCJKmainfont{Noto Serif CJK JP}
\setCJKsansfont{Noto Sans CJK JP}
\setCJKmonofont{Noto Sans Mono CJK JP}
\begin{document}
\section{これは最初のセクションである}
日本語で \LaTeX の組版を実証するための導入部分。
フォントはまた、数学的な形態および他の環境で使用することができる
\bigskip
And you can also use Latin characters within your Japanese document.
\bigskip
\begin{verbatim}
このテキストは、別のフォントを持つことになります
This is a verbatim environment using a monospaced font.
\end{verbatim}
\end{document}
Open this xeCJK example in Overleaf.
This example produces the following output:
The pTeX engine
Many journals and conference proceedings published in Japan use a specific Japanese LaTeX distribution called pLaTeX, which is based on the jsarticle
or jsbook
document classes. pLaTeX supports many Japanese typesetting conventions, including vertical typesetting.
Using pLaTeX on Overleaf
Although pLaTeX is not listed as a user-selectable compiler in Overleaf's Compiler menu drop-down:
Overleaf can be configured to use pLaTeX by adding a small configuration file to your project: that file is called latexmkrc
. Here are the steps to do that:
- set your project's compiler setting to LaTeX
- add a new, empty, file called
latexmkrc
(no file extension) to your project - add the following lines to
latexmkrc
:
$latex = 'platex';
$bibtex = 'pbibtex';
$dvipdf = 'dvipdfmx %O -o %D %S';
$makeindex = 'mendex %O -o %D %S';
If you are using a template that was designed for uplatex
instead, then change platex
to uplatex
, and pbibtex
to upbibtex
.
The following listings show a basic pLaTeX document together with a latexmkrc
file used to compile it on Overleaf. Use the link below the listings to open these files on Overleaf.
pLaTeX-example.tex
\documentclass{jsarticle}
\bibliographystyle{jplain}
\title{A pLaTeX example}
\begin{document}
本稿では、文書組版システムp\LaTeX{}の使い方を解説します。p\LaTeX{}を利用するときには、
あらかじめ文章中に\TeX{}コマンドと呼ばれる組版用の指示を混在させ\ldots
\section{導入}
こんにちは世界!
\end{document}
latexmkrc
$latex = 'platex';
$bibtex = 'pbibtex';
$dvipdf = 'dvipdfmx %O -o %D %S';
$makeindex = 'mendex %O -o %D %S';
Open this pLaTeX project on Overleaf.
This example produces the following output:
luatex-ja package bundle with LuaLaTeX
The luatex-ja package bundle is a relatively new effort to port pTeX's typesetting capabilities to LuaLaTeX, to leverage LuaLaTeX's scripting engine and OTF/TTF support. (Remember to set your project's compiler to LuaLaTeX.) The easiest way to use it is by loading the ltjbook
, ltjarticle
or ltjreport
document class:
\documentclass{ltjarticle}
\begin{document}
\section{これは最初のセクションである}
日本語で \LaTeX の組版を実証するための導入部分。
フォントはまた、数学的な形態および他の環境で使用することができる
\end{document}
Open this ltjarticle
and LuaLaTeX example on Overleaf.
This example produces the following output:
Or, if you would like to use a different document class, then you can load the luatex-ja
package instead, like this:
\documentclass{scrartcl}
\usepackage{luatexja}
\begin{document}
\section{これは最初のセクションである}
日本語で \LaTeX の組版を実証するための導入部分。
フォントはまた、数学的な形態および他の環境で使用することができる
\end{document}
Open this luatex-ja
and LuaLaTeX example on Overleaf.
This example produces the following output:
To load your own preferred fonts for the Japanese text, you'll also need the luatexja-fontspec
package:
\usepackage[match]{luatexja-fontspec}
\setmainjfont{TakaoMincho}
\setsansjfont{TakaoGothic}
\setmonojfont{Komatuna}
See the luatex-ja package documentation for its other (very extensive) Japanese typesetting features and customisations.
The jlreq class
The jlreq
class is a more recent choice for typesetting Japanese documents. You can simply set jlreq
as the document class, but it requires LuaLaTeX, pLaTeX or upLaTeX as the compiler.
\documentclass{jlreq}
\begin{document}
\section{これは最初のセクションである}
日本語で \LaTeX の組版を実証するための導入部分。
フォントはまた、数学的な形態および他の環境で使用することができる
\end{document}
Open this jlreq
and LuaLaTeX example on Overleaf.
This example produces the following output:
The Overleaf Gallery contains a template demonstrating jlreq
and LuaLaTeX, which you can open here. The jlreq
package documentation contains details for the Japanese typesetting features and customisations offered.
Further reading
For more information see
- Supporting modern fonts with XƎLaTeX
- Latex-questions/Does Overleaf support pTeX?
- Typesetting quotations and quotation marks
- International language support
- Chinese
- French
- German
- Greek
- Italian
- Arabic
- Korean
- Portuguese
- Russian
- Spanish
- The not so short introduction to LaTeX2ε
- LaTeX/Internationalization on WikiBooks
- LaTeX/Special_Characters on WikiBooks
Overleaf guides
- Creating a document in Overleaf
- Uploading a project
- Copying a project
- Creating a project from a template
- Using the Overleaf project menu
- Including images in Overleaf
- Exporting your work from Overleaf
- Working offline in Overleaf
- Using Track Changes in Overleaf
- Using bibliographies in Overleaf
- Sharing your work with others
- Using the History feature
- Debugging Compilation timeout errors
- How-to guides
- Guide to Overleaf’s premium features
LaTeX Basics
- Creating your first LaTeX document
- Choosing a LaTeX Compiler
- Paragraphs and new lines
- Bold, italics and underlining
- Lists
- Errors
Mathematics
- Mathematical expressions
- Subscripts and superscripts
- Brackets and Parentheses
- Matrices
- Fractions and Binomials
- Aligning equations
- Operators
- Spacing in math mode
- Integrals, sums and limits
- Display style in math mode
- List of Greek letters and math symbols
- Mathematical fonts
- Using the Symbol Palette in Overleaf
Figures and tables
- Inserting Images
- Tables
- Positioning Images and Tables
- Lists of Tables and Figures
- Drawing Diagrams Directly in LaTeX
- TikZ package
References and Citations
- Bibliography management with bibtex
- Bibliography management with natbib
- Bibliography management with biblatex
- Bibtex bibliography styles
- Natbib bibliography styles
- Natbib citation styles
- Biblatex bibliography styles
- Biblatex citation styles
Languages
- Multilingual typesetting on Overleaf using polyglossia and fontspec
- Multilingual typesetting on Overleaf using babel and fontspec
- International language support
- Quotations and quotation marks
- Arabic
- Chinese
- French
- German
- Greek
- Italian
- Japanese
- Korean
- Portuguese
- Russian
- Spanish
Document structure
- Sections and chapters
- Table of contents
- Cross referencing sections, equations and floats
- Indices
- Glossaries
- Nomenclatures
- Management in a large project
- Multi-file LaTeX projects
- Hyperlinks
Formatting
- Lengths in LaTeX
- Headers and footers
- Page numbering
- Paragraph formatting
- Line breaks and blank spaces
- Text alignment
- Page size and margins
- Single sided and double sided documents
- Multiple columns
- Counters
- Code listing
- Code Highlighting with minted
- Using colours in LaTeX
- Footnotes
- Margin notes
Fonts
Presentations
Commands
Field specific
- Theorems and proofs
- Chemistry formulae
- Feynman diagrams
- Molecular orbital diagrams
- Chess notation
- Knitting patterns
- CircuiTikz package
- Pgfplots package
- Typesetting exams in LaTeX
- Knitr
- Attribute Value Matrices
Class files
- Understanding packages and class files
- List of packages and class files
- Writing your own package
- Writing your own class