iTranslated by AI

The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
📐

Building a Japanese LaTeX Environment on Mac from Scratch

に公開

1. Introduction

When starting to use LaTeX on a Mac, many people encounter the problem of Japanese text not appearing in the PDF. English shows up fine, but Japanese characters turn into boxes (□) or disappear as blanks—many of you have probably experienced this. (I myself struggled a lot with this... 😢)

Actually, to make Japanese LaTeX work stably on a Mac, there are a few correct combinations. Especially when dealing with mixed content like "Japanese + math + figures"—typical for science reports or seminar materials—an unstable environment can lead to compilation issues every time.

This article summarizes how to build a Japanese LaTeX environment from scratch that reliably outputs Japanese PDFs, targeting those who:

  • Have no LaTeX installed on their Mac
  • Want to properly create Japanese PDFs from now on
  • Plan to write reports for classes or labs

In short, the most stable configuration is MacTeX (full) + upLaTeX + dvipdfmx. Using this route, almost all Japanese PDF troubles disappear. By following the steps in this article, you will:

  • Be able to install LaTeX correctly even as a beginner
  • Guarantee that Japanese PDFs output properly
  • Avoid stumbling blocks in report creation

Let's get you there as quickly as possible!

2. What Do You Need to Install to Use LaTeX on Mac?

LaTeX often has a reputation of being "difficult," but what you actually need on a Mac is quite simple. In short, install a package called MacTeX and you're all set.

2.1 LaTeX's True Identity: TeX Live

LaTeX is built on a massive collection of packages called TeX Live, used worldwide.

  • LaTeX engine
  • Libraries for math, tables, fonts, etc.
  • Font maps
  • Compilers (uplatex, platex, lualatex, etc.)
  • PDF generation tools (dvipdfmx, etc.)

All bundled together as TeX Live.

2.2 MacTeX: A "Full Set for Mac"

MacTeX is the macOS port of TeX Live. Installing it gives you a complete package including:

  • TeX Live (core)
  • Japanese-capable LaTeX compilers (uplatex / platex)
  • dvipdfmx (PDF generation tool)
  • TeXShop (GUI LaTeX editor)
  • Various Japanese font configuration tools (kanji-config-updmap)

In other words, just installing this completes your LaTeX environment.

2.3 Why MacTeX (Full) Is Optimal?

There are several ways to install LaTeX, but beginners often fall into these pitfalls:

  • brew install texlive (lacks features & Japanese support is fragile)
  • BasicTeX (lightweight, missing many Japanese-essential packages)

Using these often results in:

  • Japanese fonts not being embedded
  • Japanese not appearing in PDFs
  • Need to reconfigure font maps
  • Compilation failures due to missing libraries

On the other hand, MacTeX (full) is the only configuration that makes Japanese LaTeX stable.

For science reports, theses, or research purposes, remember: MacTeX from the start is the way to go.

2.4 Configuration Used in This Article

The environment we'll build in this article consists of:

  • MacTeX (full)
  • upLaTeX (the standard Japanese LaTeX compiler)
  • dvipdfmx (correctly generates Japanese PDFs)

This configuration is standard in many labs and universities. Now that you know what to install, let's move on to the actual installation steps.

3. Installing MacTeX (Full Version)

The quickest way to use Japanese LaTeX on Mac is installing MacTeX (full version). All you need to do is download the PKG from the official site and run it. There are hardly any tricky points.

3.1 Downloading MacTeX

Download the latest version from the official site:

https://www.tug.org/mactex/

On the page, choose MacTeX.pkg (approx. 4 GB).

It's large, but it includes a complete set with full Japanese support.

3.2 Run the PKG to Install

Double-click the downloaded MacTeX.pkg and follow the wizard: just click "Continue → Continue → Install"!

There are no special settings or options.

Estimated Installation Time

About 3–5 minutes

You can leave it running.

3.3 Verification After Installation (Very Important)

After installation, run the following in Terminal:

which latex

If it returns:

/Library/TeX/texbin/latex

Then it succeeded.

Also check the version:

latex --version

If installed correctly, the output should contain:

  • pdfTeX
  • TeX Live 20xx
  • kpathsea

among others.

3.4 No Need to Set PATH

MacTeX automatically sets the PATH during installation, so you don't need to edit .zshrc or .bashrc.

This is a subtle but significant advantage. Other methods (like the brew version) require you to manually set PATH, and mistakes there can break Japanese support.

Once you've completed these steps, the LaTeX core installation is done.

In the next chapter, we'll actually create a "Hello, world" test in Japanese and verify that the environment is working.

Got it, Asahi. That's much friendlier for Zenn readers.
I'll completely rewrite it as: Create a .tex file in an editor → Compile in the terminal.

4. Creating Your First Japanese PDF (uplatex + dvipdfmx)

Once MacTeX installation is complete, let's actually create a LaTeX file containing Japanese and generate a PDF!

This time, I'll explain using the easiest method for beginners: Create a file in an editor → Compile in the terminal.

4.1 Create test.tex in Your Favorite Editor

VS Code, Cursor, etc., any editor is fine.
(I'll use VS Code here, but the process is the same for other editors.)

Steps

  1. Open VS Code
  2. Open any folder (e.g., Desktop)
  3. Create a new file named test.tex
  4. Paste the following content exactly:
\documentclass[uplatex]{jsarticle}
\usepackage{bxpapersize}

\begin{document}
こんにちは、世界。

\section{日本語テスト}
これは upLaTeX + dvipdfmx のテストです。
\end{document}

This is a minimal sample to verify that Japanese text displays correctly.

4.2 Compile in the Terminal

Next, generate the PDF.
If you have MacTeX installed, you can use the following commands without any special settings.

① Convert .tex to .dvi (uplatex)

Open Terminal and run the following command:

uplatex test.tex

② Convert .dvi to .pdf (dvipdfmx)

dvipdfmx test.dvi

If successful, test.pdf will be generated in the same folder.

4.3 Open and Verify the PDF

Open the generated test.pdf and check that:

  • "こんにちは、世界。"
  • The section title "日本語テスト"
  • The paragraph

are displayed correctly in Japanese, then it's a success.

4.4 If Japanese Does Not Appear (Blanks or Boxes)

Even during initial setup, Japanese may rarely not appear due to an unconfigured font map.
In that case, please refer to Chapter 5: Troubleshooting.

(*The next chapter explains this in detail.)

If you've made it this far, your Mac's LaTeX should be ready to output Japanese PDFs without any issues!
Next, let's move on to "What to do when Japanese doesn't display."

5. Checklist When Japanese Doesn't Display (Common Even on First Build)

Even if you've correctly installed MacTeX:

  • Only Japanese characters become blank
  • Only Japanese characters become boxes (□)
  • English appears, but Japanese characters disappear

These issues can sometimes occur.

Actually, this isn't a "LaTeX bug" but rather an initial setup issue caused by the font map not being configured.
With MacTeX, you need to run a one-time configuration to use Hiragino (Japanese) fonts.

5.1 Common Symptoms

  • Japanese characters do not display at all
  • Replaced by boxes (tofu)
  • Output as PDF but the content is blank

These are all caused by fonts not being embedded.

5.2 Cause: Font Map Not Activated

To embed Japanese in a PDF, LaTeX needs to correctly recognize:

  • The location of Hiragino fonts
  • Glyph mappings
  • Japanese map files (such as kanjiEmbed.map)

MacTeX includes a tool to handle this called kanji-config-updmap-sys.

5.3 Solution: Enable the Font Map with a Single Command

Run the following command in the terminal:

sudo kanji-config-updmap-sys --jis2004 hiragino-pron

Enter your password and wait for the process to complete.

Example Output After Execution

Updating updmap.cfg
Generating Kanji map files for hiragino-pron...
Finished.

The output may vary, but if it finishes without any errors, it's probably OK!

5.4 Recompile and Verify

Run these commands again:

uplatex test.tex
dvipdfmx test.dvi

Open the PDF. If Japanese appears correctly, the issue is resolved!

5.5 This Setting is Permanent

The font map configuration persists until you change your Mac.
You don't need to do this every time.

Clearing this hurdle reduces issues with Japanese PDF output to nearly zero! ✨ It took me this long to finally get it stable too.

6. Bonus: Why Choose upLaTeX

When setting up a Japanese LaTeX environment on a Mac, there are several compiler options:

  • pLaTeX
  • upLaTeX
  • LuaLaTeX
  • XeLaTeX

However, this article uses upLaTeX (+ dvipdfmx).
The reason is very simple: It is the most stable option for beginners and handles Japanese correctly.

6.1 Overwhelmingly High Stability for Japanese Typesetting

upLaTeX is a "Japanese-specific" LaTeX engine designed to accurately handle documents mixing Japanese and English.

  • Japanese line-breaking rules (e.g., positions of punctuation)
  • Line spacing and character width handling
  • Handling of punctuation, symbols, full-width and half-width characters

These are all optimized for Japanese.

For documents like science reports that mix:

  • Japanese paragraph explanations
  • English technical terms
  • Mathematical formulas
  • Figures and tables

the stability of upLaTeX is high, and layouts are less likely to break, which is a major advantage.

6.2 Reliable Embedding of Japanese Fonts (dvipdfmx)

The combination of upLaTeX and dvipdfmx is also very powerful in correctly embedding Japanese fonts into PDFs.

  • Automatic support for Hiragino fonts
  • Font maps can be configured with a single command
  • Blank or tofu (□) issues almost never occur

It also has excellent compatibility with MacTeX, making it the combination most likely to avoid the "Japanese not displaying" problem.

6.3 Good Compatibility with LaTeX Document Classes (Especially for University Reports)

upLaTeX is highly compatible with the following "document classes commonly used by science students":

  • jsarticle
  • jsreport
  • jbook
  • Custom style files (*.sty) distributed by labs

These are widely used in universities and labs, and are the de facto standard for Japanese document classes.

6.4 Better Unicode Support than pLaTeX

In the past, pLaTeX was mainstream, but now upLaTeX is nearly the standard.

  • Can write Japanese directly in Unicode
  • Handles emoji and supplementary characters better
  • Some packages have already migrated to upLaTeX

MacTeX 202x series fully supports upLaTeX.

6.5 Is LuaLaTeX / XeLaTeX Not Okay?

They are not bad.
However, if a beginner chooses them directly, they are prone to the following troubles:

  • Complex configuration of Japanese fonts
  • Compatibility issues with bibliography styles (biblatex)
  • Lab-provided templates may not support them
  • Subtle behavior of line spacing and punctuation in Japanese

LuaLaTeX and XeLaTeX are for those who need advanced customization. Choosing them from the start can lead to confusion.
upLaTeX is the safest choice.

6.6 Conclusion: upLaTeX is the Optimal Solution for Beginners and University Reports

  • Stability for Japanese
  • Reliability of font embedding
  • Compatibility with university and lab templates
  • Simplicity that is easy for beginners

From any perspective, upLaTeX + dvipdfmx is the "standard path for Japanese LaTeX."

Especially since its compatibility with MacTeX is outstanding, if you are setting up an environment from scratch like in this article, choosing this combination is the safe bet.

7. Summary

This article has summarized the steps to build an environment that can reliably generate Japanese PDFs from a Mac with no LaTeX installed at all.

Once you set up LaTeX, it becomes an extremely powerful document creation tool.
Especially for documents that mix formulas and Japanese — such as reports, theses, and lab reports — its expressive power far surpasses Word.

Environment Built in This Article (The Ultimate Configuration)

  • MacTeX (Full version)
  • upLaTeX
  • dvipdfmx
  • Configuration to reliably embed Japanese fonts (Hiragino)
  • A state where PDFs can be stably output from the terminal

This combination can handle almost everything, from university reports and lab templates to thesis writing.

95% of Troubles Are Solved by the Font Map

If Japanese does not appear, the following command will almost certainly resolve it:

sudo kanji-config-updmap-sys --jis2004 hiragino-pron

This command "correctly configures Japanese font settings," and once executed, it is no longer needed afterward.

Final Thoughts

LaTeX may look difficult, but the key is simply not to make a mistake in the initial environment setup.
If you use MacTeX with the upLaTeX + dvipdfmx configuration, you will almost never encounter broken PDFs or Japanese characters becoming tofu.

Use this article as a reference to create a "stable Japanese LaTeX environment" on your own Mac.
Once it's up and running, report writing becomes amazingly comfortable — like a whole new world.

It would be an honor if this article could rescue even one person struggling with LaTeX.

Discussion