Learning LaTeX has been on my bucket list since god knows when! I had the LearnLaTeX.org open on my browser for anywhere between 6 months to an year. Now, I finally got the time to dig into it. FYI, the tutorial is great! Very succinct.

Installing

Let’s start with the basics–setting up the LaTeX workflow in your editor, so rest of the journey is smooth sailing. It all starts with downloading a TeX distribution. I have tried both MiKTeX and MacTex distributions. MiKTeX even comes with a strange looking (non-native) GUI, but I found it a little buggy to use. I used to get a popup every time I installed a new package.

MacTex came in two flavours, a ~100MB one and a ~4GB one. I just grabbed the smaller one because I was new to LaTeX and probably would not require all its features. But it’s your choice, have it your way 😉

Another difference is that MiKTeX can be installed either system-wide or for a particular user. However, MacTex does not offer this flexibility.

Setting up

After installing MacTex, you will need to add /Library/TeX/texbin to your PATH so that you and your editor can easily access and run all the installed packages.

Your installation will come with a package manager called tlmgr. We will use this to install packages in subsequent steps.

But first, open your favourite editor. If it is Emacs and your OS is MacOS, then you can kiss goodbye to your dreams of rendering LaTeX output inside Emacs itself. That will not work because it does not have the ability to display graphics, which is not so different from the terminal. There is Aquamacs, but I didn’t bother checking it out because the Emacs version it forks out of or uses is quite old (at the time of writing, Emacs version 25.3). However, if you are a Linux user, Emacs apparently offers that functionality, and you’ll be just fine!

So let’s open VSCode (and pretend other editors do not exist), and install LaTeX Workshop extension.

Open your settings.json and add the following to set up build instructions:

{
    "latex-workshop.latex.recipes": [
        {
            "name": "latexmk 🔃",
            "tools": [
                "latexmk"
            ]
        }
    ],
    "latex-workshop.latex.tools": [
        {
            "name": "latexmk",
            "command": "latexmk",
            "args": [
                "-synctex=1",
                "-interaction=nonstopmode",
                "-file-line-error",
                "-pdf",
                "-outdir=%OUTDIR%",
                "--xelatex",
                "%DOC%"
            ],
            "env": {}
        }
    ]
}

Now, open your terminal and install the xelatex package using

sudo tlmgr install xelatex

Conclusion

Rendering Japanese should work now!

\documentclass{article}

\usepackage{zxjatype}

\begin{document}

    おはようございます!

\end{document}

Sources

  1. How to use xelatex with latexmk: link
  2. LaTeX Workshop – Recipes: link
  3. LaTeX Workshop – Tools: link
  4. Old reference on how to render Japanese in LaTeX: link