TeX - LaTeX Asked on February 24, 2021
I am typesetting a german-english text with some chinese characters in it. I know similar questions have been asked often here, but none of the answers provided any help. I tried the following:
% Version 1:
documentclass{article}
usepackage{fontspec}
usepackage{xeCJK}
usepackage{xltxtra,xunicode}
begin{document}
waijiaquan, 外家拳
neijiaquan, 內家拳
end{document}
%Version 2
documentclass{article}
usepackage{fontspec}
defaultfontfeatures[FandolSong]{Script=Default}
usepackage{xeCJK}
usepackage{xltxtra,xunicode}
begin{document}
waijiaquan, 外家拳
neijiaquan, 內家拳
end{document}
% Version 3
documentclass[fontset=windows]{ctexbook}
usepackage{fontspec}
defaultfontfeatures[FandolSong]{Script=Default}
begin{document}
waijiaquan, 外家拳
neijiaquan, 內家拳
end{document}
% Version 4
documentclass{article}
usepackage[UTF8]{ctex}
usepackage{CJKutf8}
AtBeginDvi{input{zhwinfonts}}
usepackage[ngerman]{babel}
begin{document}
begin{CJK*}{UTF8}{zhsong}
waijiaquan, 外家拳
neijiaquan, 內家拳
end{CJK*}
end{document}
I always get warnings that a font is missing, Fandol or SimHei. BUT: I read on CTAN they are included in TexLive and Miktex, which I use both. So what´s the fundamental mistake here, and which options are left?
If you can download Google's Noto Serif CJK and Noto Sans CJK font families, you may want to try the following version, labelled "version 5", which runs under both XeLaTeX and LuaLaTeX. The Noto Serif CJK TC font family provides 6 font weights (from "Extra Light" to "Black"), and the Noto Sans CJK TC font family provides 7 font weights (from "Thin" to "Black").
% Version 5
documentclass{article}
usepackage[english,ngerman]{babel}
usepackage{fontspec}
setmainfont{Noto Serif CJK TC}
setsansfont{Noto Sans CJK TC}[Scale=MatchLowercase]
begin{document}
Hello World.
waijiaquan, 外家拳.
neijiaquan, 內家拳.
sffamily
Hello World.
waijiaquan, 外家拳.
neijiaquan, 內家拳.
end{document}
Answered by Mico on February 24, 2021
With SimSun (which I got with Windows 10) your chars are all there too
documentclass{article}
usepackage{fontspec}
setmainfont{SimSun}
begin{document}
waijiaquan, 外家拳
neijiaquan, 內家拳
end{document}
Answered by Ulrike Fischer on February 24, 2021
Your font is missing that character. You can add the command tracinglostchars=2
to print a warning message on the console, instead of silently printing it to the .log
file.
For this kind of multilingual document, with only short phrases in Chinese, I would recommend Babel. This MWE works on LuaLaTeX.
documentclass{article}
tracinglostchars=2 % Warn if a character is missing from the font!
usepackage[english, ngerman]{babel}
usepackage{fontspec}
babelprovide[import=zh-Hans, onchar=ids fonts]{chinese} % Or zh-Hant for Traditional.
defaultfontfeatures{ Scale=MatchUppercase, Ligatures=TeX }
babelfont{rm}
[Scale=1.0, Ligatures={Common,Discretionary}]{New Computer Modern Book}
% From: https://www.google.com/get/noto/#serif-hans or https://www.ctan.org/pkg/notocjksc
babelfont[chinese]{rm}
{Noto Serif CJK SC}
% Set up babelfont{sf} and babelfont{tt} here, if needed.
babeltags{chinese=chinese}
babeltags{english=english}
babeltags{ngerman=german}
begin{document}
waijiaquan, 外家拳
neijiaquan, 內家拳
end{document}
This will get you German captions and hyphenation, but automatically switch when you start typing Chinese. It also lets you switch languages with textenglish{...}
, begin{english}
, and so on.
To get the document to compile on XeLaTeX, remove the onchar=ids fonts
option and wrap all Chinese text in textchinese{外家拳}
. This is also compatible with polyglossia
.
The ctex
package, which is more recent than XeCJK and also works on other engines, provides two ways to select a different font: fontset=
and setCJKmainfont
(also setCJKsansfont
and setCJKmonofont
).
documentclass{article}
tracinglostchars=2 % Warn if a character is missing from the font!
usepackage[UTF8, fontset=none]{ctex}
% From: https://www.google.com/get/noto/#serif-hans or https://www.ctan.org/pkg/notocjksc
setCJKmainfont[Scale=MatchUppercase]{Noto Serif CJK SC}
begin{document}
waijiaquan, 外家拳
neijiaquan, 內家拳
end{document}
Answered by Davislor on February 24, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP