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 路線(可能推薦)

chemnum軟體包還記錄了一種替換標籤的方法.eps第 9 節第 18 頁中的圖形標籤的方法。文件。根據手冊,其工作流程為(逐字引用):

  1. 建立方案並將臨時標籤(如TMP1TMP2等)放置在您想要複合標籤的位置。
  2. 將方案匯出為epsps圖,確保標籤作為文字字串嵌入。
  3. 包括eps\includegraphics.在此之前,\replacecmpd每個臨時標籤都使用一次。

我個人還沒有嘗試過這個(因為我不使用chemdraw),所以我只會向您推薦文件。 (也許需要另一個正確記錄此方法的答案)。 Anyhoo,正如文檔所示,我認為如果您想繼續使用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

相關內容