2

This question now has my own answers that I redacted in accordance to work instructions. I would have tried to redact my own answers again, but my workplace has decided that my answers do indeed fall under public domain since my answers are composed of open-source or public material. (I just can't give anymore answers from now on.)

I'll leave this question here, but I must let the site administrators know that this question isn't useful. It was just a test (like a few other questions) to assess the barriers-to-entry to LaTeX et al. It would be best to just delete this question.

A fuller answer (I posted) on doing CJK is at a very tangentially related question.

To Davislor who diligently answered nigh every possible facet of my question: Thank you! I am going to keep this question here to showcase your diligence and resourcefulness. Do note in my answer (in another question) how I avoided potentially problematic automatic font lookup via font name; in certain scenarios, that lookup can actually loop badly as to break TeX processing. The demographics of LaTeX newbies turned away tend overwhelmingly towards software engineers, and they are very wary of "automagic" features that "provide no consistently reliable function, and yet no way to fully control".


MWE:

\documentclass{scrbook}

\usepackage[utf8]{inputenc} % For non-English languages

% Install cjk for Chinese, zhmetrics for font size.
\usepackage{CJKutf8}

% OT1 for Chinese. T1 for English.
\usepackage[OT1, T1]{fontenc} % T1 will be active encoding.

\begin{document}

This is mainly an English document.

\begin{CJK}{UTF8}{song}
With a smattering of Chinese: {\fontencoding{OT1}\selectfont 中文}
\end{CJK}

\end{document}

The error:

!pdfTeX error: pdflatex (file cyberb65): Font cyberb65 at 657 not found

I would at least like to know which fonts come default with which packages. In the MWE, the packages I installed are:

  • koma-script
  • inputenc
  • cjk
  • fontenc

For some unknown reason, I already have access to the gbsn font. Am on MacOS.

Side question: Is it difficult to transition to an engine that better supports UTF-8 and non-English languages?


Working answer: Don't use song font family. Use gbsn. If you wanna know how/where that font got installed by default, private message Jon who wrote this question.

And thanks to @cfr, I'm not using OT1 font encoding anymore. Not needed with gbsn font family.

Updated MWE:

\documentclass{scrbook}

\usepackage[utf8]{inputenc} % For non-English languages.

% Install babel-vietnamese, vntex for Vietnamese.
\usepackage[vietnamese, english]{babel} % English will be active language.

% Install cjk for Chinese, zhmetrics for font size.
\usepackage{CJKutf8}

% T5 for Vietnamese.
\usepackage[T5, T1]{fontenc} % T1 will be active encoding.

\begin{document}

This is mainly an English document.

\begin{CJK}{UTF8}{gbsn}
With a smattering of Chinese: 中文
\end{CJK}

And some Vietnamese: {\fontencoding{T5}\selectfont Tiếng Việt}

\end{document}

closed as too broad by user36296, Phelype Oleinik, Mensch, TeXnician, Henri Menke Jan 23 at 4:08

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    OT1 for Chinese? I don't think so. OT1 is an older Latin encoding, which does not support accented characters in the way T1 does. Not too bad for English, but pretty crap for other European languages and certainly hopeless for Chinese. – cfr Jun 11 '18 at 0:22
  • 1
    I didn't say you couldn't use \fontencoding. I said that OT1 was not the right encoding for what you wanted. OT1 is a 7-bit Latin encoding, good for English and used for text in mathematics. Also, you're not using microtypography, as far as I can tell. But perhaps you didn't mean that literally. – cfr Jun 11 '18 at 23:52
  • 1
    If you want a minimal LaTeX installation, you should use MikTeX instead of TeX Live. It comes with a very basic install of only a few hundred megabytes and installs packages on-the-fly during a LaTeX run if missing dependencies are detected. – Henri Menke Jan 22 at 1:13
  • 1
    If you’re missing a file you need, such as a font, I’d try A: searching for it on CTAN, and installing the package that contains it. B: On Debian/Ubuntu, which has its own texlive package, run apt-file search to find out which OS packages contain the font. For example, the uming font needed by ctex is in the Ubuntu package fonts-arphic-uming:. – Davislor Jan 31 at 2:28
  • 1
    @JonWong That works. Although, if you do that, you already have everything that’s in CTAN, so what package would install it no longer matters to you. – Davislor Jan 31 at 4:04
4

You ask about transitioning to an engine with better support for more languages. I highly recommend it. At the moment, there are a few workarounds you need to apply, but this works in XeLaTeX or LuaLaTeX:

\documentclass[varwidth=10cm, preview]{standalone}
\usepackage{fontspec}
\usepackage[english]{babel}

% Babel 3.22 erroneously passes the wrong OpenType script and language options
% to fontspec.  This workaround overrides the bug:
\babelprovide[script=CJK, language={Chinese Simplified}]{chinese-simplified}

\defaultfontfeatures{ Scale = MatchUppercase, Ligatures = TeX }

\babelfont{rm}[Scale = 1.0, Ligatures = Common]{Noto Serif}
\babelfont{sf}{Noto Sans}
\babelfont[chinese-simplified]{rm}[Ligatures = Common]{Noto Serif CJK SC}
\babelfont[chinese-simplified]{sf}[Ligatures = Common]{Noto Sans CJK SC}
% Also set the monospace font and load unicode-math if you need math.

\begin{document}

This is mainly an English document.

With a smattering of Chinese: \foreignlanguage{chinese-simplified}{中文}

\end{document}

Noto font sample

I used the Noto fonts and Noto CJK, but any Unicode font with support for Simplified Chinese should work.

You would use \foreignlanguage{chinese-simplified}{...} for short snippets of Chinese within a paragraph, and \begin{otherlanguage}{chinese-simplified} ... \end{otherlanguage} for long passages in Chinese. See the Babel manual for more details.

I used the Noto fonts in this example, but you can change them. With fontspec, any font from your system or word processor will work, and in this template, they will automatically scale to the height of the main font.

As of January 2019, this is trickier than it should be because polyglossia does not support Chinese, but babel is broken out of the box on several languages I’ve tried, including Chinese, Japanese and Hebrew. However, there was a simple one-line workaround for the bug with Chinese.

Installing Missing Components

You requested a follow-up about, I think, locating missing fonts.

On most TeX Live or MikTeX installations, if you’re missing a file, such as a package or font, I would search CTAN.org for it, find out which package contains it, and install that package. Make sure you select the option to search file names!

This search found that cyberb65.tfm is in the zhmetrics package, which is installable in either TeX Live or MikTeX.

If you are using the Debian/Ubuntu installation of TeX Live, it is possible to create a texmf directory and do a local installation from CTAN, but you should first search to see if there is a deb package for the file you want, either online or with apt-file search. For example, searching for uming.ttc tells you that the uming font that ctex requires is in the package fonts-arphic-uming.

If you’re missing a class, search for foo.cls; a package, foo.sty; or a type 1 font, foo.tfm. For example, if you were trying to compile a document that used \documentclass[UTF8]{ctexart}, and it were not installed, you would get an error about a missing class ctexart, search for the file ctexart.cls, and find it in texlive-lang-chinese. If you were missing the cjk package, you would search for cjk.sty.

  • 1
    @JonWong, this is an excellent MWE in this answer. It does only use an absolute minimum of packages that would come with even the smallest LaTeX installation. You could slightly simplify it by using \documentclass{article} instead of \documentclass[varwidth=10cm, preview]{standalone}. It might be failing for you because you do not have the Noto family of fonts installed. But you could use any font that you have that supports Chinese. The other possible problem is that you have the Noto fonts installed but in ttc format and you are compiling with lualatex, which has trouble with ttc. – David Purton Jan 22 at 1:22
  • 1
    @JonWong Okay. If you’re writing documents in Chinese, you probably have at least one Chinese font installed that you can use in your word processor? That should work for you. – Davislor Jan 22 at 5:33
  • 1
    @JonWong Well, I added links to the fonts I used in that document. You should be able to click on the .otf files to install them. Noto does cover almost all the world’s scripts. – Davislor Jan 22 at 5:37
  • 2
    There’s a CTAN package for it, and also for Arphic, the Fandol family and perhaps some others. You should be able to install them with tlmgr. – Davislor Jan 22 at 5:49
  • 1
    @JonWong, xetex and luatex are designed to use system fonts (though they can make use of fonts installed in the texmf tree too). So usually you need to install fonts in the normal way for your operating system. This is often especially true for non-Latin Scripts. The full Noto font download comes in at a hefty 1.1GB! This would substantially increase the size of your TeXLive distribution :). – David Purton Jan 22 at 7:05