# How do I select a Chinese font for caption label?

I am writing a document in Chinese and would like to choose a font for the caption label, different from that is used in the main text. I know it is tricky to work with Chinese font in LaTeX, but I really want to get this straight.

To set caption label to use a font defined readily in ctex, one could do the following

\documentclass[UTF8]{article}
\usepackage{ctex}
\usepackage{float}
\usepackage{graphicx}
\usepackage{caption}

\DeclareCaptionFont{kai}{\kaishu}
\captionsetup{labelfont = kai}

\begin{document}

\begin{figure}[h]
\centering
\includegraphics[scale = 0.3]{example.png}
\caption{图注}
\end{figure}

\end{document}


However, I have no idea of how to declare a font that is not already defined in ctex for the caption label. Like the font Weibei SC, which can be used with package fontspec for the main text

\documentclass[11pt, a4paper]{article}
\usepackage{fontspec}
\setmainfont{Weibei SC}

\begin{document}

\end{document}


Could someone help me on this issue? Thanks in advance!

Since you mentioned the use of fontspec, I will assume that your compile engine is XeLaTeX/LuaLaTeX. Basically you need to declare a new CJK font. I do not have Weibei SC, so I will illustrate using 华文新魏.

% !TeX program = XeLaTeX
\documentclass[UTF8]{article}

\usepackage{ctex}
\newCJKfontfamily\weibei{华文新魏}

\usepackage{graphicx}
\usepackage{caption}
\DeclareCaptionFont{weibei}{\weibei}
\captionsetup{labelfont=weibei}

\begin{document}

\begin{figure}[h]
\centering
\includegraphics[scale = 0.3]{example-image}
\caption{图注}
\end{figure}

\end{document}