Chemfig/Chemnum 路线

Chemfig/Chemnum 路线

我正在写化学论文,其中涉及很多反应方案反应方案我如何添加显示的标签?我想将第一个化合物标记为 1,并且我希望这是一个 Latex 标签,这样我就可以在文本中引用它,然后在需要时更改标签。

以下是 MWE:

\documentclass{report}
\usepackage[utf8]{inputenc}
\usepackage{geometry}
\geometry{letterpaper, margin = 1in}
\DeclareFloatingEnvironment[fileext = los, listname = {List of     Schemes}, name = Scheme]{scheme}
\begin{document}
        \begin{scheme}[h!]
            \centering
            \includegraphics[scale = 0.7]{Carbdiazosyn}
            \caption{Generation ...}
            \label{carbdiazosyn}
        \end{scheme}
\end{document}

答案1

Chemfig/Chemnum 路线

方案

可能不是最明智的选择chemfig,但只是表明这是可能的。您可能希望使用该包chemnum来标记分子。它提供(除其他外)以下命令:

\cmpd{<main label>.<sublabel>} % <main label> produces the 1, <sublabel> produces the a, b etc.
\refcmpd{<main label>.<sublabel>} % Acts like \ref in normal circumstances

代码如下:

\documentclass[]{report}
\usepackage{chemfig,chemnum}
\usepackage[version=4]{mhchem}
\usepackage{geometry}
\geometry{letterpaper, margin = 1in}
\usepackage{newfloat}
\DeclareFloatingEnvironment[fileext = los, listname = {List of     Schemes}, name = Scheme]{scheme}

\begin{document}
\begin{scheme}[ht]
    \centering
    %\schemedebug{true}
    \schemestart[0,1.3]
        \chemname{%
            \chemfig{[:120]*3(-[@{a1}]N=[@{db}]N-[@{a2}])%
                (-[:50,,,,red]\textcolor{red}{\ce{R1}})%
                (-[@{r2}:-50,,,,red]\textcolor{red}{\ce{R2}})%
            }
        }{\cmpd{scheme.1}}
        \arrow(.mid east--.mid west){->[$h\nu/\Delta$][$-$\ce{N2}]}
        \chemname{%
            \setlewis{0.8ex}{}{red}%
            \chemfig[shift={(0,0.4)}]{[:-30]\textcolor{red}{\ce{R1}}%
                -[,,,,red](\lewis{6:,})%
                -[::60,,,,red]\textcolor{red}{\ce{R2}}}%
        }{\cmpd[pre-label-code{scheme.2}}
    \schemestop
    \chemmove{%
        \draw[shorten <=2pt, shorten >=3pt]%
            (a1)..controls +(250:3mm) and +(340:3mm)..(db);
        \draw[shorten <=2pt, shorten >=2pt]%
            (a2)..controls +(320:3mm) and +(210:2mm)..(r2);
        }
    \caption[]{My scheme}\label{scheme1}
\end{scheme}
The arrows in \refcmpd{scheme.1} refer to electron movement! The compound in \refcmpd{scheme.2} is in red! Both \refcmpd{scheme.1, scheme.2} are in scheme \ref{scheme1}.
\end{document}

注意事项:我使用命令chemnum中的命令\chemname插入“标签”。我还使用mhchem包在内排版化合物名称chemfig。其余的只是chemfig代码:-)


Auto-pst-pdf/Chemnum 路线(可能推荐)

该包还记录了替换第 9 节第 18 页图形chemnum标签的方法.eps文档根据手册,此工作流程如下(逐字引用):

  1. 创建方案并将临时标签(如)放置TMP1TMP2您想要复合标签所在的位置。
  2. 将方案导出为epsps图形,确保标签嵌入为文本字符串。
  3. 包括eps。在每个临时标签\includegraphics之前使用一次。\replacecmpd

我个人还没有尝试过(因为我不使用chemdraw),所以我只会让你参考文档。(也许需要另一个正确记录此方法的答案)。无论如何,正如文档所建议的那样,如果您想继续使用,我认为这是可行的方法chemdraw

以下是文档中的示例代码:

 % code for figure 2
 \documentclass{standalone}
 \usepackage{graphicx,auto-pst-pdf,chemnum}
 \begin{document}
 \replacecmpd{Alc}% replaces TMP1
 \replacecmpd{EtherBr}% replaces TMP2
 \includegraphics{scheme-tmp.ps} % Contains TMP1 and TMP2 as embedded text strings
 \end{document}

答案2

我必须调整宽度以使子标题适合。

\documentclass{report}
\usepackage[utf8]{inputenc}
\usepackage{geometry}
\geometry{letterpaper, margin = 1in}
\usepackage{newfloat}
\DeclareFloatingEnvironment[fileext = los, listname = {List of     Schemes}, name = Scheme]{scheme}
\usepackage{graphicx}
\usepackage{subcaption}
\DeclareCaptionSubType{scheme}
\captionsetup[subscheme]{font+=footnotesize}
\begin{document}
        \begin{scheme}[htp]% h! is interpreted as "I am an idiot so replace this with something reasonable"
            \centering
            \sbox0{\includegraphics[scale = 0.7]{images/Carbdiazosyn}}% measure width
            \usebox0\par
            \makebox[1.1\wd0]{\parbox{0.45\wd0}{\subcaption{Compound 1}\label{compound1}}\hfill
              \parbox{0.45\wd0}{\subcaption{Compound 2}\label{compound2}}}
            \caption{Generation ...}
            \label{carbdiazosyn}
        \end{scheme}

\centering Of course, the reference will only return \ref{compound1}.
\end{document}

演示


由于字幕是设计为适合给定的空间,并且在这种情况下我们希望它们适合一行,因此更容易不是使用 subcaption 包。

有多种格式选项可供选择。在本例中,我将标题放在左侧,但将图片放在中间。

\documentclass{report}
\usepackage[utf8]{inputenc}
\usepackage{geometry}
\geometry{letterpaper, margin = 1in}
\usepackage{newfloat}
\DeclareFloatingEnvironment[fileext = los, listname = {List of     Schemes}, name = Scheme]{scheme}
\usepackage{graphicx}

\newcounter{compound}
\newcommand{\compound}[1]% #1 = label
{\refstepcounter{compound}\label{#1}Compound \thecompound}

\begin{document}
        \begin{scheme}[htp]
            \centering
            \leavevmode\llap{\compound{test}:\qquad}%
            \raisebox{-0.5\height}{\includegraphics[scale = 0.7]{images/Carbdiazosyn}}% center
            \caption{Generation ...}
            \label{carbdiazosyn}
        \end{scheme}

\centering This references the compound index, \ref{test}.
\end{document}

演示2

相关内容