I'm trying the example from How to use Chinese with lualatex? (TexLive 2014, updated to frozen):


在 Lua\TeX{} 中正常地使用中文。获得自动的\textbf{字体选择},标点“压缩”,以及正确的断行处理等特性。


I try to compile this with lualatex test.tex - but cannot, as it fails with:

! LuaTeX error ...xlive/2014/texmf-dist/tex/luatex/luatexja/ltj-rmlgbm.lua:90: b
ad argument #1 to 'open' (string expected, got nil).
l.172 }

! LuaTeX error [\directlua]:1: attempt to index field 'stack' (a nil value).
l.249   }
.sty (/media/texlive/2014/texmf-dist/tex/latex/ms/everysel.sty)
ABD: EverySelectfont initializing macros)

What am I missing?

  • I get no error from the test document. Can you add \listfiles and show the result? – egreg May 7 '15 at 23:03

I think it is a bug of luaotfload. You can update to TeX Live 2015 (in a few days) and the problem should have been fixed.


Well, I think I got it. First, I added a print line to texmf-dist/tex/luatex/luatexja/ltj-rmlgbm.lua:90:

   local function open_cmap_file(name, inc, cid_dec, mke)
      print("open_cmap_file: name " .. name) -- added
      fh = io.open(kpse.find_file(name, 'cmap files'), "r")

... and realized it prints out: open_cmap_file: name UniJIS2004-UTF32-H. So I looked up:

$ tlmgr search --global --file UniJIS2004

... so I installed adobemapping with: tlmgr install adobemapping.

Now with this, compilation fails with:

luaotfload | db : Reload initiated (formats: otf,ttf,ttc,dfont); reason: "Font IPAExMincho not found.".
! Font \JY3/mc/m/n/10=IPAExMincho:jfm=ujis at 9.62219pt not loadable: metric dat
a not found or bad.
<to be read again>
l.34 \kanjiencoding{JY3}\selectfont

... so I have a font problem now. I'm on Ubuntu 11.04, and have no idea which specifically Chinese fonts I'd have. Via texdoc luatexja, I realized the default for this package is indeed \def\ltj@stdmcfont{IPAExMincho} - but also, that one could include a luatexja.cfg file in the same directory as the .tex file; these contents are recommended in the manual:


... and with this - and without a \setmainjfont statement - the example compiles, although it seems some characters may be missing.

I had worked with simsun.ttc font before, so I wanted to try it. Note, if the font name is simsun.ttc, and it is not installed system-wide, but merely present (even as a symlink) in the same directory as the .tex file, then it can not be read in with a \setmainjfont{SimSun}, only with \setmainjfont{simsun}. However, for my particular version of simsun.ttc, I get this compile error:

luaotfload | db : Reload initiated (formats: otf,ttf,ttc,dfont); reason: 
"Font simsun not found.".(compiling luc: /media/texlive/2014/texmf-var/luatex
-cache/generic/fonts/otf/simsun.luc)(compiling luc: /home/user/.texlive
2014/texmf-var/luatex-cache/generic/fonts/otf/simsun.luc)(save: /media/
texlive/2014/texmf-var/luatex-cache/generic/fonts/otf/simsun.lua)(save: /media
LaTeX Font Warning: Font shape `JY3/simsun(0)/bx/n' undefined
(Font)              using `JY3/simsun(0)/m/n' instead on input line 8.

gular.otf><./simsun.ttc(bad-fontname-simsun:-1)Invalid TTC index number

So, even if I had no problem with this font with pdflatex/{CJKutf8}, here simsun.ttc fails with Invalid TTC index number. Wish I knew a fix for this (maybe it's this bug: [NTG-context] Latest beta stops loading some ttc fonts)...

Then I found SimSun.ttf somewhere for download; removed simsun.ttc from the directory, and downloaded SimSun.ttf in the same directory (as the .tex file). Then I used \setmainjfont{SimSun} in the code instead -- and the example finally compiled, and all characters were apparently present in the PDF.

Not sure if this was all of it, but it looks like it so far...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.