Krypf’s Diary

暇なときに書く

Solution to luatexja.sty errors when compiling with latexmk

0. Introduction

  • I would have liked to compile .tex files using the latexmk command.
  • I use LuaLaTeX.
  • I use Visual Studio Code to write and preview .tex files
  • But a fatal error prevented me from compiling .tex files and generating PDFs.
  • Then the problem is solved by adding the pdflatex command to my .latexmkrc file.

Keywords

LaTeX, latexmk, VSCode, LuaLaTeX

1. LaTeX Problems

I'll show you the error messages, which have been very annoying for a long time.

TeX luatexja.sty /usr/local/texlive/2018/texmf-dist/tex/luatex/luatexja/luatexja.sty
    ❌ Undefined control sequence. LaTeX [Ln 42, Col 1] ^
    ❌ ==> Fatal error occurred, no output PDF file produced! LaTeX [Ln 42, Col 1] ^
    Transcript written on "(absolute path)".
    === TeX engine is 'pdfTeX'
    Latexmk: Errors, so I did not complete making targets

all messages

[{
    "resource": "/usr/local/texlive/2018/texmf-dist/tex/luatex/luatexja/luatexja.sty",
    "owner": "LaTeX",
    "severity": 8,
    "message": "Undefined control sequence.",
    "source": "LaTeX",
    "startLineNumber": 42,
    "startColumn": 1,
    "endLineNumber": 42,
    "endColumn": 65536
},{
    "resource": "/usr/local/texlive/2018/texmf-dist/tex/luatex/luatexja/luatexja.sty",
    "owner": "LaTeX",
    "severity": 8,
    "message": " ==> Fatal error occurred, no output PDF file produced!\nTranscript written on \"(absolute path)\".\n=== TeX engine is 'pdfTeX'\nLatexmk: Errors, so I did not complete making targets\n",
    "source": "LaTeX",
    "startLineNumber": 42,
    "startColumn": 1,
    "endLineNumber": 42,
    "endColumn": 65536
}]

Undefined control sequence.

[{
    "resource": "/usr/local/texlive/2018/texmf-dist/tex/luatex/luatexja/luatexja.sty",
    "owner": "LaTeX",
    "severity": 8,
    "message": "Undefined control sequence.",
    "source": "LaTeX",
    "startLineNumber": 42,
    "startColumn": 1,
    "endLineNumber": 42,
    "endColumn": 65536
}]

Fatal error occurred,

[{
    "resource": "/usr/local/texlive/2018/texmf-dist/tex/luatex/luatexja/luatexja.sty",
    "owner": "LaTeX",
    "severity": 8,
    "message": " ==> Fatal error occurred, no output PDF file produced!\nTranscript written on \"(absolute path)\".\n=== TeX engine is 'pdfTeX'\nLatexmk: Errors, so I did not complete making targets\n",
    "source": "LaTeX",
    "startLineNumber": 42,
    "startColumn": 1,
    "endLineNumber": 42,
    "endColumn": 65536
}]

2. First message

The first message conveys this line of the source code to me, which commonly arises an error.

\directlua{require('ltj-unicode-ccfix.lua')}% catcode of ideographs

Investigation of the message did not lead to a solution but told me that the error attributes to some difficulty in selecting the default language.

3. Second message

The second message shows that the error which fatally disturbs the execution must be pdfTeX.

    === TeX engine is 'pdfTeX'

So I added the below sentence and changed a command for pdflatex so that I can confirm the cause of the error.

$pdflatex = 'lualatex --synctex=1 --halt-on-error --interaction=nonstopmode %O %S';

The result was clear. No error occurred.

I add that my latex command is lualatex.

latex command

$latex = 'lualatex -synctex=1 -interaction=nonstopmode -file-line-error -halt-on-error %O %S';

n. Conclusion

A change of the pdflatex command resolved the error of "\directlua{require('ltj-unicode-ccfix.lua')}% catcode of ideographs" in luatexja.sty.