我又来复习LaTeX字体设置了~

1,722 阅读1分钟
\documentclass{ctexart}
\usepackage{xeCJK}

\newfontfamily{\con}{Consolas}
\newfontfamily{\mo}{Monaco}
\newfontfamily{\st}{宋体}
\newfontfamily{\yh}{微软雅黑}
\newfontfamily{\kt}{楷体}
\newfontfamily{\ht}{黑体}
%\newcommand{\erhao}{\fontsize{21pt}{\baselineskip}\selectfont}
%\newcommand{\kai}{\CJKfamily{kai}}

\setmainfont{Times New Roman}		% LaTeX默认Computer Modern/Latin Modern
											% Arial/Helvetica/Futura也不错
\setsansfont{Adobe Garamond Pro}	% 无衬线字体,一般用于标题。Adobe Garamond Pro/Caslon
\setmonofont{Monaco}					% 等宽字体,一般用于排版代码
\setCJKmainfont{宋体}		%设置字体族,\textrm{这样就显示宋体}						=\rmfamily
\setCJKsansfont{微软雅黑}	%设置字体族,\textsf{这样就显示微软雅黑}				=\sffamily
\setCJKmonofont{楷体}		%设置字体族,\texttt{这样就显示打字机字体monofont}	=\ttfamily



\begin{document}
\noindent
hello this is a small~ \&\&\&\fontname\font \\

\noindent
\con{hello this is a consolas~ \&\&\&\fontname\font }\\

\noindent
\mo{hello this is a monaco~ \&\&\&\fontname\font }\\

正文 \textrm{Times New Roman宋体} \& \textsf{Adobe Garamond Pro微软雅黑} 	\&	\texttt{monaco楷体}

正文 \textup{直立} \& \textit{a b c Italy 意大利(数学公式)} \& \textsl{a b c Italy 倾斜(手写体)} \& A\scshape{A小型大写} % 然而字体形状对中文没用,只用字体族进行区分

正文 \textmd{中等} \& \textbf{加宽加粗}
\end{document}

可以用fc-list :lang=zh >> D:\zh.txt来把电脑所有中文字体全输出到文件中
同理,fc-list :lang=en >> D:\en.txt来把电脑所有英文字体全输出到文件中
若新安装字体则应该在命令行下刷新字体缓存:fc-cache -fsv