2

2 Weeks ago, I asked how to replace the current default Japanese font for LaTex with Noto Sans mono CJK (How can I change the Japanese font to be used). This font is installed on my Fedora PC using the command sudo dnf install google-noto-sans-mono-fonts and I use this font by default for my Japanese texts. (By the way, I do not know which font is now used by Latex nor how it is set in Latex). In response to that question, I was told that the best option was to switch to Luatex because LuaTex would support all Open Type fonts. However, I have not found anywhere how to set this up in Luatex.

I have since found that LuaTex-Ja probably fits my needs even better. Even with the help of this package, however, I do not succeed in using the noto fonts.

With this Preamble, LuaTex-Ja returns the expected result:

\documentclass{article}
\usepackage{amssymb}
\usepackage[haranoaji]{luatexja-preset}
\usepackage{luatexja-fontspec}
\usepackage{mathtools,array,booktabs} 
\usepackage{cancel}
\usepackage{nimbussans}
\renewcommand*\familydefault{\sfdefault}
\usepackage{fontenc}
\usepackage[sf]{noto}

\begin{document} [ \setlength\arraycolsep{0pt} \renewcommand\arraystretch{1} \left. \begin{array}{rr} \left.\begin{array}{l} \text{V} \ \text{い-adj} \end{array}\right} & \multicolumn{1}{l}{\text{Jisho}} \ \addlinespace \left.\begin{array}{l} \text{な-adj} \ \text{N}\textsubscript{1} \end{array}\right} & \begin{array}{l} \text{Jisho} \ \text{$\sim$\cancel{だ}}\to\text{$\sim$な} \end{array} \end{array} \right}
\text{のは N}\textsubscript{2}\text{です} ] \end{document}

But after changingharanoaji into noto, compilation fails.

The complete log is 1247 lines. Which parts of the log-file are most instructive and should be added?

It would be great if someone could tell me how I can use the Noto Sans mono fonts.


@cfr,

The answer that you produced is exactly what I intended! That means that I don't have to work on the code itself ;-). Alas, on my laptop it still give compile errors. But you gave a lot of clues that I can use to continue my search.

Thanx!

Comment 1

  • This is the first error in the log:

    Package luatexja-preset Warning: Japanese fonts will be scaled by
    (luatexja-preset)                0.96221923828125.
    

    Package luatexja-fontspec Warning: \addjfontfeature(s) ignored; (luatexja-fontspec) it cannot be used with a font that (luatexja-fontspec) wasn't selected by luatexja-fontspec.

    luaotfload | cache : Lookup cache loaded from /home/bengbers/.texlive2022/texmf- var/luatex-cache/generic/names/luaotfload-lookup-cache.luc. luaotfload | db : Reload initiated (formats: otf,ttf,ttc); reason: Font "NotoSer ifCJKJPRegular" not found. luaotfload | resolve : sequence of 3 lookups yielded nothing appropriate.

    ! Package fontspec Error: The font "NotoSerifCJKJPRegular" cannot be found.

    For immediate help type H <return>. ...

    l.731 \ltjapplypreset {}

    A font might not be found for many reasons. Check the spelling, where the font is installed etc. etc.

    When in doubt, ask someone for help!

    luaotfload | resolve : sequence of 3 lookups yielded nothing appropriate. luaotfload | aux : no font with id 0

    Package fontspec Warning: Font "NotoSerifCJKJPRegular" does not contain (fontspec) requested Script "CJK".

Comment 3

  • In an earlier test-file that contained the line \usepackage{nimbussans}, \text{V} produced a V in Nimbus Sans. A V resulted in a V in the default latex font.

Answer 1

  • Thanks for pointing at the differences between the font-types. fontenc was included after copying from an example I found somewhere.

  • You mention the use of NotoSansCJK-Regular.ttc. I searched my filesystem but this file does not exist. I only found /usr/share/fonts/google-noto-sans-mono-cjk-vf-fonts/NotoSansMonoCJK-VF.ttc. Is it possible that this is the cause of my problem?. I found this page Fonts in Luatex on the Internet. I thought most of the suggested tests executed without errors. Obviously, I should have a better look at the test results.

  • I read the Luatex-Ja documentation. As far as I understand it, the documentation mainly gives information on how to display a font. The question of how to select a font is not answered, in my understanding.

Werner
  • 603,163
  • The first error is usually the most useful thing to post if compilation fails. Anything after that is not usually helpful. You should not load fontenc if you are using fontspec. Nor should you load nimbussans since that package loads fontenc and textcomp. I think haranoaji will not use Noto. It seems to load a specific set of fonts of its own, but I don't know enough (anything) about Japanese typesetting to be sure. I would load luatexja-fontspec before the preset and check whether this is the correct way to do it. To start, though, load only luatexja-fontspec and see docs. – cfr Oct 21 '23 at 03:14
  • luatexja-fontspec package (see Table 1 in the documentation) provides \setsansjfont, \setjfontfamily and \addjfontfeatures commands. – Cicada Oct 22 '23 at 00:46
  • Re. update: It is looking for the serif. Do you have NotoSerifCJK or NotoSerifCJKJP installed? I know you want all sans, but the preset sets up the serif, too. (Fedora should provide this, but it might be in a different package from the sans.) – cfr Oct 23 '23 at 04:25
  • If you look at the section on presets in the documentation, you can compare the fonts each preset requires with those installed. That way, you can specify a preset which matches what you've got. You can also use fontconfig to check. E.g. fc-match "Noto Serif CJK JP" returns NotoSerifCJK-Regular.ttc: "Noto Serif CJK JP" "Regular"; fc-match "Noto Sans CJK JP" returns NotoSansCJK-Regular.ttc: "Noto Sans CJK JP" "Regular". – cfr Oct 23 '23 at 04:25
  • @Cicada Indeed, but there are also presets for Noto .... – cfr Oct 23 '23 at 04:27

1 Answers1

1

This is certainly incorrect. My only claim is that I think it is closer to being correct than your original MWE. That said, I could not reproduce the compilation failure you reported. Your code compiled without error for me, though surely the output was not what you wanted.

  • You need to decide whether you are using traditional NFSS fonts (the 'New Font Selection Scheme'), which are typically type 1 and greatly complicate typesetting languages such as Japanese, or opentype fonts.
  • fontenc, textcomp and nimbussans supports NFSS.
  • fontspec supports opentype.

It is a bit more complicated than this. In particular, I've deliberately avoided mentioning truetype. But, for our purposes, the choice is - theoretically - a simple one.

luatexja supports either, but, as you've been told, opentype fonts are more straightforward. In any case, if you wish to use NotoSansCJK, I think you do not have any choice. You must use fontspec in this case.

So ensure you are not loading any conflicting packages. Don't add font packages without checking what they do.

In the code below, I drop nimbussans, fontenc and textcomp. I also make explicit some default options and enable some non-default ones.

\usepackage[noto-otf,fontspec,match]{luatexja-preset}

This specifies fontspec, though this is the default. match means commands such as \sffamily will switch Japanese fonts, too. noto-otf specifies the noto-otf presets. Initially, I tried noto-otc because this is supposed to support use of NotoSansCJK-Regular.ttc. However, I couldn't get this to work. When I use noto-otf, however, the .ttc font is found. You should check what Fedora has installed, since I'm using Arch. You may find you need to use one of the other noto... presets.

Although match means \sffamily switches to NotoSansCJK, setting the default family to \sfdefault doesn't make NotoSansCJK default. Instead, you still get NotoSerifCJK. Issuing \sffamily at the beginning of the document is an effective workaround.

I do not know what the result should look like. This doesn't look great to me, but I don't know anything about Japanese. I just observe that the weight of NotoSansCJK-Regular and of NotoSans for English doesn't work well with the weight of the mathematical symbols.

However, it does use NotoSansCJK-Regular, so while I don't recommend this, it may be a useful starting point.

NotoSansCJK and NotoSans with standardish maths

I recommend reading luatexja's documentation. Doubtless it will mean rather more to you than it does to me. Moreover, some parts of the package are undocumented in English, so the Japanese version is surely the best source of information.

\documentclass{article}
\usepackage{amssymb}
\usepackage{mathtools,array,booktabs} 
\usepackage[noto-otf,fontspec,match]{luatexja-preset}
\usepackage{cancel}
\usepackage[sfdefault]{noto}
\renewcommand*\familydefault{\sfdefault}
\begin{document}
\sffamily
のは
\[ 
  \setlength\arraycolsep{0pt}
  \renewcommand\arraystretch{1}
  \left.
  \begin{array}{rr}
    \left.\begin{array}{l} 
      \text{V} \\ 
      \text{い-adj}
    \end{array}\right\} & 
    \multicolumn{1}{l}{\text{Jisho}} \\
    \addlinespace
    \left.\begin{array}{l} 
      \text{な-adj} \\ 
      \text{N}\textsubscript{1}
    \end{array}\right\} &
    \begin{array}{l} 
      \text{Jisho} \\
      \sim\cancel{\text{だ}}\to\sim\text{な} 
    \end{array}
  \end{array}
  \right\}  
  \text{のは N}\textsubscript{2}\text{です}
\]
\end{document}  
cfr
  • 198,882