如何在 chemfig 中更改字体系列

如何在 chemfig 中更改字体系列

我正在学习使用该chemfig包并获取与某些模板匹配的结构。其中一个重要的参数是原子的字体大小和字体系列。到目前为止,为了在图中创建一个典型的结构,我得到了:

\documentclass{article}
\usepackage{chemfig}
\usepackage[version=4]{mhchem}
\usepackage{fp}
\usepackage{chemnum}
\usepackage{graphicx}
\usepackage{chemscheme}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\newcommand{\bondlength}{14.4}
\FPeval{\bondspacing}{clip(\bondlength*0.18)}
\setchemfig{
double bond sep=\bondspacing pt, %space between multiple bonds lines
atom sep=\bondlength pt, %distance between atoms (bond length)
cram width=2 pt, %width of wedged and hashed bonds (bold width)
cram dash width=0.5 pt, %thickness of lines in hashed bonds
cram dash sep =2.5pt, % distance between lines in hashed bonds (hash spacing)
bond offset=1.6 pt, %space between bond and atom (margin width)
compound sep=10 em,%separation between compounds
arrow coeff=1, %default length of the arrow
arrow offset=0.75em, %distance between arrow ends and compounds
arrow label sep=3pt, %distance between arrow and label
scheme debug=false, %show the anchors 
%atom style=red, %color atoms
%bond style=red, %color bonds
bond style={line width=0.6pt}, %bond line width - can be combined with color as bond style={line width=1pt,red}
%compound style={draw,line width=0.5pt,semitransparent,text opacity=1,inner sep=8pt,rounded corners=1mm}, %draws a box around each compound - needs the argument A\arrow([fill=red]--[fill=blue]) to work
}
\renewcommand*\printatom[1]{\normalsize\sffamily\ensuremath{\mathsf{#1}}}
\begin{document}
\begin{scheme}
\centering
\scalebox{.8}{
\chemname{\chemfig{-[:108]-[:168]=_[:222]-[:150]=_[:78]-[:6]S(-[:294])}}{\cmpd{ethylcompound}}}
\caption{This is the compound (\cmpd{ethylcompound}).}
\label{scheme:compound}
\end{scheme}
\end{document}

(请原谅我的评论)。

但改变\sffamily似乎并没有改变输出字体。

当前输出为:

在此处输入图片描述

答案1

由于chemfig使用数学字体来打印字母,您可以使用带有选项mathastext的包subdued,如下所示

\usepackage[subdued]{mathastext}
\Mathastext[chem] % create a math version for chemfig
\usepackage{chemfig}
\let\chmf\chemfig % copy the chemfig command
\renewcommand*{\chemfig}[1]{{\MTVersion{chem}\chmf{#1}}} % set the math version before printing

这样,文档中的数学内容保持不变,但原子将使用文本字体打印。

相关内容