如何使用 chemformula 包在化学公式中插入可选的换行符?

如何使用 chemformula 包在化学公式中插入可选的换行符?

使用\iupac命令时chemmacros,我可以执行类似操作\ch{1,2\-dimethyl|really|long|name},以便 LaTeX 知道它可以拆分名称以及拆分位置。但是,当我有一个很长的公式时,命令\ch{UO2}(来自chemformula子包)在手册中没有列出这样的选项(我已经尝试过 |)。有没有办法拆分我的长(45 个字符)化学式?

梅威瑟:

\documentclass[letterpaper]{article}
%\usepackage[left = 1.5 in, right = 1.5 in]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[language=british]{chemmacros}
    \chemsetup[iupac]{coord-use-hyphen=true} %Puts hypens after bridging and hapto

%misc

%Load last stuff.
\begin{document}
This works See, it breaks at where I tell it to: \iupac{methyl|phenyl|piperidin|yl|acetate}


Here is a chemical formula: \ch{Cu(NCMe)2(pyz)[AuCl2(CN)2]2UO2(NO3)2}

Here is that same chemical formula with a bunch of filler text: \ch{Cu(NCMe)2(pyz)[AuCl2(CN)2]2UO2(NO3)2}

Here is that same chemical formula with a bunch of filler text: \ch{Cu(NCMe)2(pyz)|[AuCl2(CN)2]|2UO2(NO3)2}

Here is that same chemical formula with a bunch of filler text: \ch{Cu(NCMe)2(pyz) [AuCl2(CN)2] 2UO2(NO3)2}

Note a complete lack of this working despite spaces and such. 

The one way I've seen it work is (filler text filler text) \ch{Cu(NCMe)2(pyz)[AuCl2(CN)2] * 2 MeCN}
\end{document}

答案1

不确定这是否是正确的方法,但是,嘿,它有效!

添加允许换行的新属性。我建议添加两个:一个只允许换行,另一个还允许添加连字符。任您选择。

\documentclass[letterpaper]{article}
%\usepackage[left = 1.5 in, right = 1.5 in]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[language=british]{chemmacros}

\chemsetup[iupac]{coord-use-hyphen=true} %Puts hypens after bridging and hapto

\NewChemCompoundProperty{|}{\linebreak[0]}
\NewChemCompoundProperty{?}{\-}

%misc

%Load last stuff.
\begin{document}
This works See, it breaks at where I tell it to: \iupac{methyl|phenyl|piperidin|yl|acetate}


Here is a chemical formula: \ch{Cu(NCMe)2(pyz)[AuCl2(CN)2]2UO2(NO3)2}

Here is that same chemical formula with a bunch of filler text:
\ch{Cu(NCMe)2 | (pyz) | [AuCl2(CN)2]2 | UO2(NO3)2}

Here is that same chemical formula with a bunch of filler text:
\ch{Cu(NCMe)2 ? (pyz) ? [AuCl2(CN)2]2 ? UO2(NO3)2}

\end{document}

在此处输入图片描述

相关内容