0

I follow How do I use a particular font for a small section of text in my document? to change CJK font for a certain part:

global: FZQingKeBenYueSongS-R-GB

selective: TpldKhangXiDictTrial

\documentclass{article}
\usepackage[T1]{fontenc}
\RequirePackage{xeCJK}
\setCJKmainfont{FZQingKeBenYueSongS-R-GB}

\begin{document}
字体:方正清刻本悦宋简体

{\fontfamily{TpldKhangXiDictTrial}\selectfont
字体:康熙字典体繁
}

\end{document}

It outputs FZQingKeBenYueSongS-R-GB for both line

enter image description here

While this what I suppose to see: enter image description here enter image description here

What's the problem?

  • @koleygr I did try \begin{myfont} text \end{myfont} suggested at tex.stackexchange.com/a/25251/95054. It just .. didn't work either – Rahn Aug 20 '17 at 4:23
  • try the XeLaTeX solution... (from here tex.stackexchange.com/questions/25249/… using the commands you see in the answer) Your code is LaTeX and not XeLaTeX... See the "A basic document will therefore look like the following:" code and use it – koleygr Aug 20 '17 at 4:37
  • looking for chineeze XeLaTeX to create an answer – koleygr Aug 20 '17 at 4:41
  • I didn't show your edit before posting the answer... alignment was probably a lost token and could be corrected. – koleygr Aug 20 '17 at 5:00
2

Please use \setCJKfamilyfont and \CJKfamily:

\documentclass{article}
\usepackage{xeCJK}
\setCJKmainfont{FZQingKeBenYueSongS-R-GB}
\setCJKfamilyfont{KhangXiDict}{TpldKhangXiDictTrial}
\begin{document}
字体:方正清刻本悦宋简体

{\CJKfamily{KhangXiDict}字体:康熙字典体繁}
\end{document}

You can also use \newCJKfontfamily:

\documentclass{article}
\usepackage{xeCJK}
\setCJKmainfont{FZQingKeBenYueSongS-R-GB}
\newCJKfontfamily\KhangXiDict{TpldKhangXiDictTrial}
\begin{document}
字体:方正清刻本悦宋简体

{\KhangXiDict 字体:康熙字典体繁}
\end{document}

or:

\documentclass{article}
\usepackage{xeCJK}
\setCJKmainfont{FZQingKeBenYueSongS-R-GB}
\newCJKfontfamily[KhangXi]\KhangXiDict{TpldKhangXiDictTrial}
\begin{document}
字体:方正清刻本悦宋简体

{\CJKfamily{KhangXi}字体:康熙字典体繁}
\end{document}

BTW, the ctex classes (ctexart, ctexrep, ctexbook, and ctexbeamer) are better choices if the main language of your document is Simplified Chinese. Documentations can be found here (if you can read Chinese):

https://ctan.org/pkg/ctex

https://ctan.org/pkg/xecjk

  • @koleygr Yes, and using \usepackage[T1]{fontenc} in XeLaTeX can cause other problems. I deleted that line. Thank you! – ManTingFang Aug 20 '17 at 6:31
  • welcome... delete this too – koleygr Aug 20 '17 at 6:34
1

Try this:

\documentclass{article}
\usepackage{fontspec}
\usepackage{xeCJK}
\setCJKmainfont{FZQingKeBenYueSongS-R-GB}
\setCJKsansfont{TpldKhangXiDictTrial}
\begin{document}
字体:方正清刻本悦宋简体

\textsf{%
字体:康熙字典体繁
}

\end{document}
  • try the second way – koleygr Aug 20 '17 at 4:56
  • I changed it... But I also show your edit in the question... If alignment was the problem we can fix it. – koleygr Aug 20 '17 at 5:04
  • Can you go back to the code that you said it works on your question? If yes add it in an answer or in your question and we will fix the alignment. – koleygr Aug 20 '17 at 5:13
  • code added to question. – Rahn Aug 20 '17 at 5:17
  • add a % exactly after '\textsf{' like my updated answer – koleygr Aug 20 '17 at 5:19

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.