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?

Rahn
  • 498
  • @koleygr I did try \begin{myfont} text \end{myfont} suggested at https://tex.stackexchange.com/a/25251/95054. It just .. didn't work either – Rahn Aug 20 '17 at 04:23
  • try the XeLaTeX solution... (from here https://tex.stackexchange.com/questions/25249/how-do-i-use-a-particular-font-for-a-small-section-of-text-in-my-document/37251#37251 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 04:37
  • looking for chineeze XeLaTeX to create an answer – koleygr Aug 20 '17 at 04: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 05:00

2 Answers2

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

ManTingFang
  • 260
  • 1
  • 8
1

Try this:

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

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

\end{document}
koleygr
  • 20,105
  • try the second way – koleygr Aug 20 '17 at 04: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 05: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 05:13
  • code added to question. – Rahn Aug 20 '17 at 05:17
  • add a % exactly after '\textsf{' like my updated answer – koleygr Aug 20 '17 at 05:19
  • It works. But I don't thinks it's a clean solution – Rahn Aug 20 '17 at 05:23
  • I just found this: https://tex.stackexchange.com/questions/15516/how-to-write-japanese-with-latex and so it is probably a duplicate and my way is the recomended – koleygr Aug 20 '17 at 05:53
  • Ok... show the new answer... It is not the recomended +1 to the answer – koleygr Aug 20 '17 at 05:55
  • Both the link and @ManTingFang suggest to use \CJKfamily – Rahn Aug 20 '17 at 05:56
  • I saw and upvoted his answer.. the 1.1 XeLaTeX solution in the answers of the link above is like mine... But sure CJK comands are a better option... and I don't consider it a duplicate (because of the new XeLaTeX answer). This is what I said – koleygr Aug 20 '17 at 06:07