无法使用 chemnum 包中的 LuaLaTeX 更改字体

无法使用 chemnum 包中的 LuaLaTeX 更改字体

我似乎无法使用 chemnum 作为包来更改 LuaLaTeX 中的字体。我想使用 Calibri(而不是 Times New Roman),就像现在的情况一样。这是我的代码:

\documentclass[12pt]{report}
\usepackage[a4paper,width=150mm,top=25mm,bottom=25mm]{geometry}
\usepackage{fancyhdr} 
\usepackage{achemso} 
\usepackage{chemnum}
\usepackage{psfrag} 
\usepackage[crop=off]{auto-pst-pdf}
\usepackage{graphicx} 
\usepackage{wrapfig} 

\linespread{1.3}%1.5 line spacing

\begin{document}
\tableofcontents

\chapter{This is your chapter title}

\section{This is your section title}

\subsection{Here is an example}

\begin{wrapfigure}{l}{0.35\textwidth}
\vspace{-20pt} % removes 'white-space'
\begin{center}
\cmpdref{benzene} % replaces TMP1
\includegraphics{images/benzene.eps}
\end{center}
\vspace{-20pt}
\end{wrapfigure}

Add any text here and use \refcmpd{benzene} to refer to the compound. This way if you add a new figure in front of this one the numbering will automatically be changed. \\
Not totally sure if .eps is require or if only benzene would be sufficient.\\

Note: you need lualatex --shell-escape  -synctex=1 -interaction=nonstopmode %.tex in the configure texmaker for the lualatex. 

\end{document}

benzen,这是一张png图片,请转换成eps

答案1

您必须加载包fontspec并定义主字体:

\documentclass[12pt]{report}
\usepackage{achemso} 
\usepackage{chemnum}
\usepackage{fontspec}
\setmainfont{Calibri}
\begin{document}

Add any text here and use to refer to the compound. This way if you add a new figure 
in front of this one the numbering will automatically be changed. 

Not totally sure if .eps is require or if only benzene would be sufficient.
\end{document}

答案2

如果您想要更改整个文档的默认字体,Herbet 的答案是正确的。但是,如果您只想chemnum更改由此生成的标签,则加载fontspec并定义要使用的字体,并将其名称置于复合标签的格式中,如下所示:

\usepackage{fontspec}

\newfontface\chemnumface[Scale=MatchUppercase]{Calibri}
\setchemnum{format=\chemnumface}

psfrag但是,您还需要它才能与和 一起使用auto-pst-pdf。这需要在切换包时小心谨慎:主文件与lualatex支持的一起运行fontspec,但auto-pst-pdf仅与latex支持的 一起运行。您应该按以下顺序加载ifluatex测试:

\usepackage{ifluatex}
\ifluatex
 \usepackage{fontspec}
  \newfontface\chemnumface[Scale=MatchUppercase]{Calibri}
  \setchemnum{format=\chemnumface}
\else
  \usepackage{psfrag} 
\fi
\usepackage[crop=off]{auto-pst-pdf}

示例输出

\documentclass[12pt]{report}

\usepackage[a4paper,width=150mm,top=25mm,bottom=25mm]{geometry}
\usepackage{fancyhdr} 
\usepackage{achemso} 
\usepackage{chemnum}
\usepackage{ifluatex}
\ifluatex
 \usepackage{fontspec}
  \newfontface\chemnumface[Scale=MatchUppercase]{Calibri}
  \setchemnum{format=\chemnumface}
\else
  \usepackage{psfrag} 
\fi
\usepackage[crop=off]{auto-pst-pdf}
\usepackage{graphicx} 
\usepackage{wrapfig} 


\linespread{1.3}%1.5 line spacing

\begin{document}

\begin{wrapfigure}{l}{0.35\textwidth}
\centering
\replacecmpd{benzene} % replaces TMP1
%\includegraphics{benzene.eps}
\end{wrapfigure}

Add any text here and use \refcmpd{benzene} to refer to the
compound. This way if you add a new figure in front of this one the
numbering will automatically be changed. Here is another compound
\cmpd{xx.one}

\end{document}

我没有你的benzene.eps文件所以注释掉了那一行。

相关内容