無法使用 LuaLaTeX 和 chemnum 套件更改字體

無法使用 LuaLaTeX 和 chemnum 套件更改字體

我似乎無法使用 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}

苯,這是一張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文件,所以註解掉了該行。

相關內容