我是 Latex 的新手,但真的很想用它来写我的论文(当然是化学)。实验室工作快完成了,但这似乎是目前较低的障碍 :D
现在,我正尝试使用 chemnum 包来为所有化合物获取漂亮的标签。理论上,它应该用自动编号替换“TMP”标记(由 chemdraw 软件创建的外部 eps 文件中给出)。但是,我甚至无法使用 TeXstudio 运行示例文件:
在我的例子中,标记没有被替换,而是在所有六个示例化合物下都写有文本“TMP1”或“TMP2”。此外,图片内的字体相对于上面的模型 pdf 来说也是乱七八糟的。
我做错了什么?我们来谈谈这个问题:我该如何制作自己的 TMP 标签?在 chemdraw 中将“TMP”写为文本块可以吗?
提前致谢!
答案1
因此,我得到了一些额外的线索:它可能与编译设置有关。
如前所述,使用 overleaf texmaker 可以在线编译。Overleaf 使用 latex 编译,但当更改为 pdflatex 时,它无法重新印制 TMP 标记,但是,图形仍然看起来正确。我的设置已经无法描绘图片(见下面的屏幕截图,请注意随机部分缺失/移动并且字体已更改)。
使用 auto-pst-pdf 命令根本不会产生任何图像。
enter\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{graphicx}
\title{Automatically numbering compounds in chemical schemes}
%% Uncomment these lines if you get error about "too many \new..."
% \let\tmp\newinsert
% \let\newinsert\newbox
\usepackage{chemstyle}
% \let\newinsert\tmp
\usepackage{chemnum}
% For positioning the scheme captions at the top.
\floatsetup[scheme]{position=top}
\begin{document}
\begin{scheme}
%% hexa.eps has "TMP1" and "TMP2" as the markers
%% in fact EVERY .eps should start with TMP1, TMP2 etc
%% for ease of use \replacecmpd{first:compound}
%% automatically replace TMP1
\replacecmpd{DSV} %% automatically replace TMP2
\includegraphics[width=\linewidth]{Picture}
\caption{This is something!}
\label{first:chem:scheme}
\end{scheme}
Compounds \refcmpd{first:compound} and \refcmpd{DSV} in \ref{first:chem:scheme}. Here's a reference to in-text creation of \cmpd{RareCompound} that we can later refer to.
\vfill
\end{document}
答案2
您描述的问题是 pdfLatex / chemnum / Texstudio / ChemDraw 组合中的常见问题。化合物编号在化学论文中显然非常重要。
我的回答基于类似问题的答案,请参阅:编号/ChemDraw/Mac,EPS/ChemDraw/chemnum,正确的 Texstudio 配置,
我将尝试在下面列出最常见的错误来源:
编译:你需要
pdflatex -synctex=1 -interaction=nonstopmode --shell-escape %.tex
在TexStudio中使用Texstudio PATH:根据您的操作系统,将您的 PATH 设置为类似的值
/usr/local/texlive/2019/bin/x86_64-darwin:/Library/TeX/texbin
(您必须根据您的操作系统进行调整)。Auto-pst-pdf:您需要
\usepackage[crop=off,runs=2]{auto-pst-pdf}
在序言中尽早加载。EPS:需要以一种明确定义文本字符串的方式进行。Windows 上的 ChemDraw 可以很好地完成此操作(导出的标准参数),但 Mac 上的 ChemDraw 则不行。这是一个错误,也是一个前一个问题调查了一下。因为我可以编译你的 MWE,所以我认为你没问题。
我之前不知道 jobname 注释,对于 TexStudio 我不需要它,但对于 Overleaf 来说可能是必要的?
此示例对我有用,使用上面描述的设置,使用 TexStudio v3:
\documentclass{article}
%\def\jobname{main} %<-- your file name
\usepackage[
runs=2,
crop=off
]{auto-pst-pdf}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{graphicx}
\title{Automatically numbering compounds in chemical schemes}
%% Uncomment these lines if you get error about "too many \new..."
% \let\tmp\newinsert
% \let\newinsert\newbox
\usepackage{chemstyle}
% \let\newinsert\tmp
\usepackage{chemnum}
% For positioning the scheme captions at the top.
%\floatsetup[scheme]{position=top}
\begin{document}
\begin{scheme}
%% hexa.eps has "TMP1" and "TMP2" as the markers
%% in fact EVERY .eps should start with TMP1, TMP2 etc
%% for ease of use
\replacecmpd{first:compound} %% automatically replace TMP1
\replacecmpd{second:compound} %% automatically replace TMP2
\includegraphics[width=\linewidth]{hexa}
\caption{This is something!}
\label{first:chem:scheme}
\end{scheme}
Compounds \refcmpd{first:compound} and \refcmpd{second:compound} in \ref{first:chem:scheme}. Here's a reference to in-text creation of \cmpd{RareCompound} that we can later refer to.
\vfill
\begin{scheme}
\replacecmpd{next:compound} %% automatically replace TMP1 BUT the autonumbering counter updates to 3!
\replacecmpd{last:compound} %% automatically replace TMP2
\includegraphics[width=\linewidth]{hexa}
\caption{This is something else!}
\label{second:chem:scheme}
\end{scheme}
Compounds \refcmpd{next:compound} and \refcmpd{last:compound} in \ref{second:chem:scheme}. Hey remember \cmpd{RareCompound}? \texttt{chemnum} still remembers it correctly, \emph{and} see how the compound numbering continues throughout the scheme diagrams!
\vfill
%% MANUAL UPDATING THE COMPOUND COUNTER; make sure you know what you're doing!
\setcounter{cmpdmain}{8}
\begin{scheme}
\replacecmpd{jumped:compound} %% automatically replace TMP1 BUT the autonumbering counter updates to 9!
\replacecmpd{nextjumped:compound} %% automatically replace TMP2
\includegraphics[width=\linewidth]{hexa}
\caption{This is again something else!}
\label{third:chem:scheme}
\end{scheme}
Compounds \refcmpd{jumped:compound} and \refcmpd{nextjumped:compound} in \ref{third:chem:scheme}. (Yes we manually modified the compound numbering counter after \ref{second:chem:scheme}).
\end{document}
答案3
我没有资格评论你的答案。如果你仍然想使用 pdflatex 作为编译器,我建议重命名“\jobname”,就像 Ulrike Fischer 在这里的答案中所做的那样这里。
使用您引用的背面示例并添加行来重命名\jobname
并且该{auto-pst-pdf}
包对我有用。
\documentclass{article}
\def\jobname{main} %<-- your file name
\usepackage[
%runs=2,
%crop=off
]{auto-pst-pdf}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{graphicx}
\title{Automatically numbering compounds in chemical schemes}
%% Uncomment these lines if you get error about "too many \new..."
% \let\tmp\newinsert
% \let\newinsert\newbox
\usepackage{chemstyle}
% \let\newinsert\tmp
\usepackage{chemnum}
% For positioning the scheme captions at the top.
%\floatsetup[scheme]{position=top}
\begin{document}
\begin{scheme}
%% hexa.eps has "TMP1" and "TMP2" as the markers
%% in fact EVERY .eps should start with TMP1, TMP2 etc
%% for ease of use
\replacecmpd{first:compound} %% automatically replace TMP1
\replacecmpd{second:compound} %% automatically replace TMP2
\includegraphics[width=\linewidth]{hexa}
\caption{This is something!}
\label{first:chem:scheme}
\end{scheme}
Compounds \refcmpd{first:compound} and \refcmpd{second:compound} in \ref{first:chem:scheme}. Here's a reference to in-text creation of \cmpd{RareCompound} that we can later refer to.
\vfill
\begin{scheme}
\replacecmpd{next:compound} %% automatically replace TMP1 BUT the autonumbering counter updates to 3!
\replacecmpd{last:compound} %% automatically replace TMP2
\includegraphics[width=\linewidth]{hexa}
\caption{This is something else!}
\label{second:chem:scheme}
\end{scheme}
Compounds \refcmpd{next:compound} and \refcmpd{last:compound} in \ref{second:chem:scheme}. Hey remember \cmpd{RareCompound}? \texttt{chemnum} still remembers it correctly, \emph{and} see how the compound numbering continues throughout the scheme diagrams!
\vfill
%% MANUAL UPDATING THE COMPOUND COUNTER; make sure you know what you're doing!
\setcounter{cmpdmain}{8}
\begin{scheme}
\replacecmpd{jumped:compound} %% automatically replace TMP1 BUT the autonumbering counter updates to 9!
\replacecmpd{nextjumped:compound} %% automatically replace TMP2
\includegraphics[width=\linewidth]{hexa}
\caption{This is again something else!}
\label{third:chem:scheme}
\end{scheme}
Compounds \refcmpd{jumped:compound} and \refcmpd{nextjumped:compound} in \ref{third:chem:scheme}. (Yes we manually modified the compound numbering counter after \ref{second:chem:scheme}).
\end{document}
答案4
如果您在 MacOS 上使用 Chemdraw,请查找此帖子: https://tex.stackexchange.com/a/687480/298255
该解决方案对于 Windows 用户也可能有帮助。