Mhchem 满箱

Mhchem 满箱

我正在使用mhchem内联包,方程式不会换行,因此会导致框溢出。有什么方法可以强制它们遵循换行规则吗?

即以下句子:

Clays exist in groups with generalised formulae, these include: 
the smectite group \ce{(A1/3D2-3[T4O10]Z2.nH2O)} and the serpentine group 
\ce{(D2[Si2O5](OH4)\pm nH2O)} among others.

这些公式看起来很可爱,它只是悬在边缘上。。。

答案1

表达式被装箱了,但是如果你稍微摇晃一下箱子,它就会在数学二元运算符周围断裂。(我不知道这对于所有 mhchem 构造是否完全安全,但至少在这里可以断裂\pm。)

在此处输入图片描述

\documentclass{article}

\usepackage{mhchem}

\makeatletter


\makeatletter
\DeclareRobustCommand*{\xce@main}[1]{%
  \bgroup%
  \ifnum 1<\mhchem@option@version%
    \ifmmode\else\def\mhchem@option@alwaystextmode{1}\fi%
  \fi%
  \def\bond{}\def\sbond{}\def\dbond{}\def\tbond{}%
  \ifx\@empty#1\@empty\else%
    \ifmmode\else\mhchem@option@textFont\fi%
    \ensuremath{\break%
      \mhchem@ce@xx#1 \mhchem@END\mhchem@ENDEND%
    \break}%
  \fi%
  \egroup%
}%

\def\xce#1{{%
\let\ce@main\xce@main
\setbox0\vbox{%
\hsize\maxdimen
\ce{#1}%
\par
\setbox0\lastbox
\unskip
\unpenalty
\setbox0\lastbox
\global\setbox1\hbox{\unhbox0\unskip\unskip\unpenalty}%
\global\setbox1\hbox{\unhbox1 \global\setbox3\lastbox}%
}%
\unhbox3 }}
\makeatother


\begin{document}

Clays exist in groups with generalised formulae, these include: the smectite group \ce{(A1/3D2-3[T4O10]Z2.nH2O)} and the serpentine group \ce{(D2[Si2O5](OH4)\pm nH2O)} among others.

Clays exist in groups with generalised formulae, these include: the smectite group \xce{(A1/3D2-3[T4O10]Z2.nH2O)} and the serpentine group \xce{(D2[Si2O5](OH4)\pm nH2O)} among others.





\end{document}

相关内容