制作自定义加号箭头

制作自定义加号箭头

我需要在两行第二行和第三行之间添加一个加号箭头。但是根据我的代码编写方式,我需要自定义箭头{+}样式,而我无法实现。我阅读了文档,但复制的代码却无法运行。

Latex 图

在此处输入图片描述

\documentclass[11pt,twoside]{article}
\usepackage{bm,sectsty,fancyhdr,multicol,lastpage}
\usepackage{amsmath,enumitem,tabularx,textcomp,nccmath,amssymb,siunitx}
\usepackage{tikz,pgfplots}
\usepackage{chemfig}
\usepackage{ctable}
\usepackage[a4paper,left=1cm,right=1cm,top=2cm,bottom=2cm,headsep=0.5cm]{geometry}
\usetikzlibrary{shapes,calc,arrows,positioning}
\pgfplotsset{compat=1.17}

\makeatletter
\definearrow4{+}{%
    \CF_arrowshiftnodes{#3}% 
    \expandafter\draw\expandafter[\CF_arrowcurrentstyle,-CF](CF_arrowstartnode)--(\CF_arrowendnode)
        coordinate[midway](mid@point);
    \filldraw(mid@point)circle(\pt_radius);% 
    \CF_arrowdisplaylabel{#1}{0.5}{+}{\CF_arrowstartnode}{#2}{0.5}{-}{\CF_arrowendnode} 
}
\makeatother

\begin{document}
\begin{center}
    \schemestart
        \chemfig{Na_{(s)}}\arrow{0}[,0]\+0.5\chemfig{Cl_{2(g)}}
        \arrow{->[$\Delta$H$_f$]}[0]\chemfig{NaCl_{(s)}}
        \arrow(@c1--){->[][*{90}\parbox{2cm}{\centering \scriptsize Sublimation \\ Energy (+)}]}[-90,1.5]\chemfig{Na_{(g)}}
        \arrow(@c2--){->[][*{90}\parbox{2.5cm}{\centering \scriptsize Dissociation \\ Energy (+)}]}[-90,1.5]\chemfig{Cl_{(g)}}
        \arrow(@c4--){->[][*{90}\parbox{2cm}{\centering \scriptsize Ionisation \\ Energy (+)}]}[-90,1.5]\chemfig{Na^{+}_{(g)}}
        \arrow(@c5--){->[][*{90}\parbox{2.5cm}{\centering \scriptsize Electron \\ Affinity (-)}]}[-90,1.5]\chemfig{Cl^{-}_{(g)}}
        \arrow(@c4--@c5){+}
        \arrow(@c6--@c7){+}
        \arrow(@c7--@c3){->[L.E.]}
    \schemestop
\end{center}
\end{document}

好吧,非常感谢@polyn,我能够让这个东西正常工作。但直接粘贴他的代码会导致我的两列布局溢出。但稍加调整就可以让它完美地工作。

\documentclass[11pt,twoside]{article}
\usepackage{bm,sectsty,fancyhdr,multicol,lastpage}
\usepackage{amsmath,enumitem,tabularx,textcomp,nccmath,amssymb,siunitx}
\usepackage{tikz,pgfplots}
\usepackage{chemfig}
\usepackage{ctable}
\usepackage[a4paper,left=1cm,right=1cm,top=2cm,bottom=2cm,headsep=0.5cm]{geometry}
\usetikzlibrary{shapes,calc,arrows,positioning}
\pgfplotsset{compat=1.17}

\begin{document}
\begin{center}
    \schemestart
        \chemfig{Na_{(s)}}
        \arrow{0}[,0.25]\+\arrow{0}[,0.25]
        $\frac{1}{2}$\chemfig{Cl_{2(g)}}
        \arrow{->[$\Delta$H$_f$]}[0]
        \chemfig{NaCl_{(s)}}
        \arrow(@c1--){->[][*{90}\scriptsize\begin{tabular}{c}
            Sublimation\\Energy \((+)\)
        \end{tabular}]}[-90,1.5]
        \chemfig{Na_{(g)}}
        \arrow(@c3--){->[][*{90}\scriptsize\begin{tabular}{c}
            Dissociation\\Energy \((+)\)
        \end{tabular}]}[-90,1.5]
        \chemfig{Cl_{(g)}}
        \arrow(@c5--){->[][*{90}\scriptsize\begin{tabular}{c}
            Ionisation\\Energy \((+)\)
        \end{tabular}]}[-90,1.5]
        \chemfig{Na^{+}_{(g)}}
        \arrow{0}[,0.25]\+
        \arrow(@c6--){->[][*{90}\scriptsize\begin{tabular}{c}
            Electron\\Affinity \((-)\)
        \end{tabular}]}[-90,1.5]
        \chemfig{Cl^{-}_{(g)}}
    \schemestop
    \chemmove{
        \draw[shorten <=1em,shorten >=1em] (c9) -| (c4)
            node[pos=0.75,left,rotate=90,anchor=south] {L.E. \((-)\)};
    }
\end{center}
\end{document}

在此处输入图片描述

答案1

仅限 chemfig

\documentclass[border=15mm]{standalone}
\usepackage{chemfig}
\begin{document}
%\setchemfig{scheme debug=true}
\setchemfig{+ sep left=0em,+ sep right=0em}
\schemestart
\chemfig{Na}\,(s)\vphantom{\(\frac{1}{2}\)}
\arrow{0}[,0.5]
\+
\arrow{0}[,0.5]
\(\frac{1}{2}\)\,\chemfig{Cl_2}\,(g)
\arrow{->[\footnotesize\(\Delta H_f\)]}[,1.5]
\chemfig{NaCl}\,(s)
\arrow(@c1--){->[][*{0}\scriptsize\begin{tabular}{c}
        Sublimation \\ Energy \((+)\)
    \end{tabular}]}[-90,1.5]
\chemfig{Na}\,(g)
\arrow(@c3--){->[*{0}\scriptsize\begin{tabular}{c}
        Dissociation \\ Energy \((+)\)
    \end{tabular}]}[-90,1.5]
\chemfig{Cl}\,(g)
\arrow(@c5--){->[][*{0}\scriptsize\begin{tabular}{c}
        Ionisation \\ Energy \((+)\)
    \end{tabular}]}[-90,1.5]
\chemfig{Na^+}\,(g)
\arrow{0}[,0.5]
\+
\arrow(@c6--){->[*{0}\scriptsize\begin{tabular}{c}
        Electron \\ Affinity \((-)\)
    \end{tabular}]}[-90,1.5]
\chemfig{Cl^{-}}\,(g)
\schemestop
\chemmove{
    \draw[shorten <=1em,shorten >=1em] (c9) -| (c4)
        node[pos=0.75,right] {\scriptsize [L.E.] \((-)\)};
}
\end{document}

在此处输入图片描述

答案2

我不知道你到底需要什么。但看你的草图,它看起来非常接近我的 Born-Haber 循环。它由 和 组成tikz,而mhchem不是chemfig,但也许它能有所帮助。

\documentclass[border=2mm]{standalone}
\usepackage   [version=4] {mhchem}
\usepackage               {tikz}

\definecolor{dgreen}{rgb}{0,0.5,0}

\begin{document}
\begin{tikzpicture}[scale=2.5,->,-latex,shorten >=1pt,auto,semithick]
\node (K1) at (0  ,2) {\ce{K(s)}};
\node (M1) at (0.5,2) {$+$};
\node (F1) at (1  ,2) {\ce{\frac{1}{2}F2(g)}};
\node (KF) at (2  ,2) {\ce{KF(s)}};
\node (K2) at (0  ,1) {\ce{K(g)}};
%\node (M2) at (0.5,1) {$+$};
\node (F2) at (1  ,1) {\ce{F(g)}};
\node (K3) at (0  ,0) {\ce{K^+(g)}};
\node (M3) at (0.5,0) {$+$};
\node (F3) at (1  ,0) {\ce{F^-(g)}};
\path (K1) edge [dgreen,swap] node {$\Delta H_s(+)$}(K2)
      (K2) edge [dgreen,swap] node {$\Delta H_i(+)$}(K3)
      (F1) edge [dgreen]      node {$\frac{1}{2}\Delta H_d(+)$}(F2)
      (F2) edge [red]         node {$\Delta H_a(-)$}(F3)
      (F1) edge [red]         node {$\Delta H_f(-)$}(KF);
\draw[red,rounded corners] (F3) -- (F3-|KF) -- (KF) node [midway,right] {$\Delta H_r(-)$};  
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容