XyMTeX \lonepair 导致错误

XyMTeX \lonepair 导致错误

\lonepairA我使用 XyMTeX 越来越成功 - 但使用或指定孤对电子位置时总是遇到同样的问题\lonepairB。每当我添加少于四个孤对电子的可选位置时,编译器就会挂起,我不得不停止它并出现错误。如果没有可选规范,我会得到四个与键重叠的孤对电子。

\documentclass[varwidth]{standalone}
\usepackage{xymtexpdf}
\usepackage{xcolor}
\usepackage{graphicx}

\usepackage{unicode-math}
\setmainfont{Source Sans Pro}
%\setmathfont{Latin Modern Math}% default setting
\setmathfont{latinmodern-math.otf}
\setmathfont[range={up,it}]{Source Sans Pro}

% fix the issue with \smash
\def\dotnodimension{\hbox{\smash{\hbox to0pt{\hss.\hss}}}}
%%
\begin{document}

% I only want / need lonepairs at two positions.

%This crashes the compiler 
%           \begin{XyMcompd}(800,500)(-150,50){}{}
%           \Ltrigonal{0==C;1D==\lonepairB[12]{O};2==A;3==B}
%       \end{XyMcompd}
        
        
%This works, but produces lonepairs that are unwanted
        \begin{XyMcompd}(800,500)(-150,50){}{}
            \Ltrigonal{0==C;1D==\lonepairB{O};2==A;3==B}
        \end{XyMcompd}
        
\end{document}

答案1

您能尝试一下此代码作为可能的解决方案吗?在您的序言中插入:

\makeatletter

\let\dotnodimensionorig=\dotnodimension 
\def\dotnodimension{\hbox{\dotnodimensionorig}}

\let\phantomoriginal=\phantom
\def\phantom#1{\hbox{\phantomoriginal{#1}}}

\makeatother

不久前,我直接从 XyMTeX 的作者那里得到了它。此代码对我来说与 XeLaTeX 配合得很好:

\documentclass[varwidth]{standalone}
\usepackage{xymtexpdf}
\usepackage{xcolor}
\usepackage{graphicx}

\usepackage{unicode-math}
\setmainfont{Source Sans Pro}
%\setmathfont{Latin Modern Math}% default setting
\setmathfont{latinmodern-math.otf}
\setmathfont[range={up,it}]{Source Sans Pro}

% fix the issue with \smash
%\def\dotnodimension{\hbox{\smash{\hbox to0pt{\hss.\hss}}}}
%%

\makeatletter

\let\dotnodimensionorig=\dotnodimension 
\def\dotnodimension{\hbox{\dotnodimensionorig}}

\let\phantomoriginal=\phantom
\def\phantom#1{\hbox{\phantomoriginal{#1}}}

\makeatother

\begin{document}

% I only want / need lonepairs at two positions.

%This crashes the compiler 
           \begin{XyMcompd}(800,500)(-150,50){}{}
           \Ltrigonal{0==C;1D==\lonepairB[12]{O};2==A;3==B}
       \end{XyMcompd}
        
        
%This works, but produces lonepairs that are unwanted
        \begin{XyMcompd}(800,500)(-150,50){}{}
            \Ltrigonal{0==C;1D==\lonepairB{O};2==A;3==B}
        \end{XyMcompd}
        
\end{document}

我希望这对你有帮助。

相关内容