2

I've tried to use font family to change the font of text that consist of Chinese characters and English alphabets. But it seems to only affect Chinese characters.

Is there any way I can change the font of them using the same font family?

\documentclass{standalone}
\usepackage{xeCJK}

\newCJKfontfamily\familyA{NotoSansCJKtc-Medium}
\newCJKfontfamily\familyB{NotoSansCJKtc-Light}
\newCJKfontfamily\familyC{NotoSansCJKtc-Regular}
\newCJKfontfamily\familyD{NotoSansCJKtc-Black}

\begin{document}
{   \familyA 中文 Eng     } ||
{   \familyB 中文 Eng     } ||
{   \familyC 中文 Eng     } ||
{   \familyD 中文 Eng     } 
\end{document}{}

Result of the code above

1
  • The whole idea of xeCJK is to allow users to use separate fonts for CJK and non-CJK text. Oct 12, 2019 at 17:03

1 Answer 1

1

You should take the concept of a "font family" serious, i.e. instead of using different families for different weights, you should use a single family with suitable font commands to switch between font weights. In addition, you should define a corresponding font for Latin characters. Here I am using Noto Serif:

\documentclass{standalone}
\usepackage{fontspec}
\setmainfont{NotoSerif}[
  UprightFont=*-Regular,
  BoldFont=*-Bold,
  FontFace={l}{n}{*-Light},
  FontFace={mb}{n}{*-Medium},
  FontFace={k}{n}{*-Black},
]


\usepackage{xeCJK}
\setCJKmainfont{NotoSansCJKtc}[
  UprightFont=*-Regular,
  BoldFont=*-Bold,
  FontFace={l}{n}{*-Light},
  FontFace={mb}{n}{*-Medium},
  FontFace={k}{n}{*-Black},
]

\DeclareRobustCommand\lseries{\fontseries{l}\selectfont}
\DeclareTextFontCommand{\textl}{\lseries}
\DeclareRobustCommand\mbseries{\fontseries{mb}\selectfont}
\DeclareTextFontCommand{\textmb}{\mbseries}
\DeclareRobustCommand\kseries{\fontseries{k}\selectfont}
\DeclareTextFontCommand{\textk}{\kseries}

\begin{document}
{   \mbseries 中文 Eng     } ||
{   \lseries 中文 Eng     } ||
{   中文 Eng     } ||
{   \kseries 中文 Eng     }

\end{document}

Result:

enter image description here

Note that this answer is partially based on https://tex.stackexchange.com/a/264275/140850.

5
  • +1: In the case of 中文 Eng, is LaTeX using automatically two different fonts or is all in 中文 Eng taken from one font? Mar 2, 2020 at 10:24
  • 1
    @Dr.ManuelKuehner LaTeX is using a CJK font family for 中文 and a (latin) font family for Eng. If you do not configure anything, Latin Modern will be used for Eng, which does not provid all the weights you want to use. You could also configure NotoSansCJKtc as (latin) font family. This should work as long as you only use characters provided by this font, i.e. any accented characters might be problematic. I am not sure if this has any advantages over using NotoSans or NotoSerif. Mar 2, 2020 at 10:36
  • Thanks for the explanation. I have some trouble setting up my bi-lingual document. Maybe I can later draft a question and you can have a look at it. Mar 2, 2020 at 10:43
  • @Dr.ManuelKuehner Sure, I will see the question if it has the fonts tag. Mar 2, 2020 at 10:49
  • I just sent you an email using stubner.me. Mar 2, 2020 at 10:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .