显示数学运算被排版为内联数学运算

显示数学运算被排版为内联数学运算

当排版下面带注释的方程式时,我的总结被排版为内联数学而不是显示数学。 内联总结,诅咒你!

  • 如果我用 包装总和和下标,\smashoperator{}那么它们将被正确排版为再次显示数学。
  • 我已经尝试过对数组的数组使用多个最外层包装器,
    • \begin{equation}
    • \begin{align}有星号和无星号,
    • \[ ... \]
    • \begin{gather}

我知道这个\displaystyle宏的存在,如果可能的话,我不想全局设置它,我的文档中的其他地方有内联数学。老实说,我想找出我做错的地方并修复它,而不是在那里插入一个宏来修复我糟糕的文本处理)。

我使用 编写了我的文档LuaLaTeX,MWE 如下。

\documentclass[a4paper]{book}
\usepackage{mathtools}
\usepackage{lipsum}
\begin{document}
\lipsum[1]
   \begin{equation}
   \begin{array}{ll} % array to ensure the force field and the braces are aligned, as the non-bonded terms are a little wider than the bonded.
      \begin{array}{rcl} % bonded terms.
         U  &=& \sum_{\text{bonds},\, i} K_{b,i} \left( b_i - b_{0,i} \right)^2 \\
            &+& \sum_{\text{angles},\, i} K_{\theta,i} \left( \theta_i - \theta_{0,i} \right)^2 \\
            &+& \sum_{\text{dihedrals},\, i}%
               K_{\phi,i} \left( 1 - \cos\left( n\phi_i - \phi_{0,i} \right) \right) \\
            &+& \sum_{%
               \substack{\text{improper},\, i\\ \text{dihedrals}}%
               } K_{\omega,i} \left( \omega_i - \omega_{0,i} \right)^2 \\
   \end{array}%
   & \left. \vphantom{% Phantom content to make brace correct size. \left. \right\} Havent worked when across two columns in array...
               \begin{array}{rcl}
                  U  &=& \sum_{\text{bonds},\, i} K_{b,i} \left( b_i - b_{0,i} \right)^2 \\
                     &+& \sum_{\text{angles},\, i} K_{\theta,i} \left( \theta_i - \theta_{0,i} \right)^2 \\
                     &+& \sum_{\text{dihedrals},\, i}%
                        K_{\phi,i} \left( 1 - \cos\left( n\phi_i - \phi_{0,i} \right) \right) \\
                     &+& \sum_{%
                        \substack{\text{improper},\, i\\ \text{dihedrals}}%
                        } K_{\omega,i} \left( \omega_i - \omega_{0,i} \right)^2 \\
               \end{array}
               }%
   \right\} \text{bonded} \\
   \begin{array}{rcl} % non-bonded terms.
      \hphantom{U}   &+& \sum_{\text{atoms},\, i,j} \epsilon_{ij}%
                        \left[%
                           \left(%
                              \frac{ r^{min}_{ij} } { r_{ij} }%
                           \right)^{12}%
                           -2 \left(%
                              \frac{ r^{min}_{ij} }{ r_{ij} }%
                           \right)^6%
                        \right] \\
                     &+& \sum_{\text{atoms},\, i,j}%
                        \frac{1}{4\pi\epsilon_0\epsilon_r}\frac{q_i q_j}{ r_{ij} }
   \end{array}%
   & \left. \vphantom{% Phantom content to make brace correct size. \left. \right\} Havent worked when across two columns in array...
               \begin{array}{rcl} % non-bonded terms.
                  \phantom{U} &+& \sum_{\text{atoms},\, i,j} \epsilon_{ij}%
                                 \left[%
                                    \left(%
                                       \frac{ r^{min}_{ij} } { r_{ij} }%
                                    \right)^{12}%
                                    -2 \left(%
                                       \frac{ r^{min}_{ij} }{ r_{ij} }%
                                    \right)^6%
                                 \right] \\
                              &+& \sum_{\text{atoms},\, i,j}%
                                 \frac{1}{4\pi\epsilon_0\epsilon_r}\frac{q_i q_j}{ r_{ij} }
               \end{array}
               }%
   \right\} \text{non-bonded}
   \end{array}
   \end{equation}

\lipsum[2-3]
\end{document}

答案1

您可以\displaystyle在您的中添加您喜欢的列array

% arara: pdflatex

\documentclass[a4paper]{book}
\usepackage{mathtools}
\usepackage{lipsum}
\usepackage{array}

\begin{document}
    \lipsum[1]
    \begin{equation}
    \begin{aligned}
    &\left.\begin{array}{r@{\;}>{{}\displaystyle}l}
    U  =& \sum_{\mathclap{\text{bonds},\,i}} K_{b,i} ( b_i - b_{0,i})^2 \\
    &+ \sum_{\mathclap{\text{angles},\, i}} K_{\theta,i} ( \theta_i - \theta_{0,i} )^2 \\
    &+ \sum_{\mathclap{\text{dihedrals},\, i}}  K_{\phi,i} \bigl( 1 - \cos( n\phi_i - \phi_{0,i} ) \bigr) \\
    &+ \mathrlap{\sum_{\mathclap{\substack{\text{improper},\, i\\ \text{dihedrals}}}} K_{\omega,i} ( \omega_i - \omega_{0,i} )^2 }
    \hphantom{\sum_{\mathclap{\text{atoms},\,i,j}}\epsilon_{ij}\Biggl[\biggl(\frac{r^{\min}_{ij}}{r_{ij}}\biggr)^{12}-2\biggl(\frac{r^{\min}_{ij}}{r_{ij}}\biggr)^6\Biggr]}
    \end{array}\right\}\text{bonded}\\
    &\left.\begin{array}{r@{\;}>{{}\displaystyle}l}
    \hphantom{U =}
    &+\sum_{\mathclap{\text{atoms},\,i,j}}\epsilon_{ij}\Biggl[\biggl(\frac{r^{\min}_{ij}}{r_{ij}}\biggr)^{12}-2\biggl(\frac{r^{\min}_{ij}}{r_{ij}}\biggr)^6\Biggr] \\
    &+\sum_{\mathclap{\text{atoms},\, i,j}}(4\pi\epsilon_0\epsilon_r)^{-1}\frac{q_i q_j}{ r_{ij}}
    \end{array}\right\}\text{non-bonded}
    \end{aligned}
    \end{equation}
    \lipsum[2-3]
\end{document}

在此处输入图片描述


如果您只是关心和符号的限制,您可以\limits向每个和符号添加命令。为您节省一些空间。

\begin{equation}
\begin{aligned}
&\left.\begin{array}{r@{\;}>{{}}l}
U =&\sum\limits_{\mathclap{\text{bonds},\,i}} K_{b,i} ( b_i - b_{0,i})^2 \\
&+ \sum\limits_{\mathclap{\text{angles},\, i}} K_{\theta,i} ( \theta_i - \theta_{0,i} )^2 \\
&+ \sum\limits_{\mathclap{\text{dihedrals},\, i}}   K_{\phi,i}\bigl( 1 - \cos( n\phi_i - \phi_{0,i} ) \bigr) \\
&+ \mathrlap{\sum\limits_{\mathclap{\substack{\text{improper},\, i\\ \text{dihedrals}}}} K_{\omega,i} ( \omega_i - \omega_{0,i} )^2 }
\hphantom{\sum\limits_{\mathclap{\text{atoms},\,i,j}}\epsilon_{ij}\biggl[\Bigl(\frac{r^{\min}_{ij}}{r_{ij}}\Bigr)^{12}-2\Bigl(\frac{r^{\min}_{ij}}{r_{ij}}\Bigr)^6\biggr]}
\end{array}\right\}\text{bonded}\\
&\left.\begin{array}{r@{\;}>{{}}l}
\hphantom{U =}
&+\sum\limits_{\mathclap{\text{atoms},\,i,j}}\epsilon_{ij}\biggl[\Bigl(\frac{r^{\min}_{ij}}{r_{ij}}\Bigr)^{12}-2\Bigl(\frac{r^{\min}_{ij}}{r_{ij}}\Bigr)^6\biggr] \\
&+\sum\limits_{\mathclap{\text{atoms},\, i,j}}(4\pi\epsilon_0\epsilon_r)^{-1}\frac{q_i q_j}{ r_{ij}}
\end{array}\right\}\text{non-bonded}
\end{aligned}
\end{equation}

这看起来像

在此处输入图片描述


但是,我个人不会将这些东西设置为array,因为它们是用于矩阵等的。您可以嵌套两个,aligned这也会产生显示样式。

\begin{equation}
\begin{aligned}
&\left.\begin{aligned}
U  ={}& \sum_{\mathclap{\text{bonds},\,i}} K_{b,i} ( b_i - b_{0,i})^2 \\
&+ \sum_{\mathclap{\text{angles},\, i}} K_{\theta,i} ( \theta_i - \theta_{0,i} )^2 \\
&+ \sum_{\mathclap{\text{dihedrals},\, i}}  K_{\phi,i} \bigl( 1 - \cos( n\phi_i - \phi_{0,i} ) \bigr) \\
&+ \mathrlap{\sum_{\mathclap{\substack{\text{improper},\, i\\ \text{dihedrals}}}} K_{\omega,i} ( \omega_i - \omega_{0,i} )^2 }
\hphantom{\sum_{\mathclap{\text{atoms},\,i,j}}\epsilon_{ij}\Biggl[\biggl(\frac{r^{\min}_{ij}}{r_{ij}}\biggr)^{12}-2\biggl(\frac{r^{\min}_{ij}}{r_{ij}}\biggr)^6\Biggr]}
\end{aligned}\right\}\text{bonded}\\
&\left.\begin{aligned}
\hphantom{U ={}}
&+\sum_{\mathclap{\text{atoms},\,i,j}}\epsilon_{ij}\Biggl[\biggl(\frac{r^{\min}_{ij}}{r_{ij}}\biggr)^{12}-2\biggl(\frac{r^{\min}_{ij}}{r_{ij}}\biggr)^6\Biggr] \\
&+\sum_{\mathclap{\text{atoms},\, i,j}}(4\pi\epsilon_0\epsilon_r)^{-1}\frac{q_i q_j}{ r_{ij}}
\end{aligned}\right\}\text{non-bonded}
\end{aligned}
\end{equation}

您可以看到垂直间距更加令人愉悦(但当然,您可以在所有情况下手动处理):

在此处输入图片描述

答案2

这是一个解决您问题的通用选项。即从内联到显示样式数学排版的局部更改。对于您使用的情况,更简单的选项array是调整其参数(如评论中所述)。

解决方案打开一个组,并重新定义你希望的宏\displaystyle。组关闭后,重新定义也会被重置。

对于您来说,可能需要重新调整 arraystretch 以确保行之间没有符号重叠。(\renewcommand\arraystretch{<factor>}\begingroup和之间\endgroup)。

这是输出的屏幕截图。请注意数组下方的内联数学具有“标准内联”数学样式。

在此处输入图片描述

\documentclass[a4paper]{book}
\usepackage{mathtools}
\usepackage{lipsum}
\begin{document}
\lipsum[1]
\begingroup
\let\oldsum\sum
\let\oldfrac\frac
\def\sum{\displaystyle\oldsum}
\def\frac{\displaystyle\oldfrac}
   \begin{equation}
   \begin{array}{ll} % array to ensure the force field and the braces are aligned, as the non-bonded terms are a little wider than the bonded.
      \begin{array}{rcl} % bonded terms.
         U  &=& \sum_{\text{bonds},\, i} K_{b,i} \left( b_i - b_{0,i} \right)^2 \\
            &+& \sum_{\text{angles},\, i} K_{\theta,i} \left( \theta_i - \theta_{0,i} \right)^2 \\
            &+& \sum_{\text{dihedrals},\, i}%
               K_{\phi,i} \left( 1 - \cos\left( n\phi_i - \phi_{0,i} \right) \right) \\
            &+& \sum_{%
               \substack{\text{improper},\, i\\ \text{dihedrals}}%
               } K_{\omega,i} \left( \omega_i - \omega_{0,i} \right)^2 \\
   \end{array}%
   & \left. \vphantom{% Phantom content to make brace correct size. \left. \right\} Havent worked when across two columns in array...
               \begin{array}{rcl}
                  U  &=& \sum_{\text{bonds},\, i} K_{b,i} \left( b_i - b_{0,i} \right)^2 \\
                     &+& \sum_{\text{angles},\, i} K_{\theta,i} \left( \theta_i - \theta_{0,i} \right)^2 \\
                     &+& \sum_{\text{dihedrals},\, i}%
                        K_{\phi,i} \left( 1 - \cos\left( n\phi_i - \phi_{0,i} \right) \right) \\
                     &+& \sum_{%
                        \substack{\text{improper},\, i\\ \text{dihedrals}}%
                        } K_{\omega,i} \left( \omega_i - \omega_{0,i} \right)^2 \\
               \end{array}
               }%
   \right\} \text{bonded} \\
   \begin{array}{rcl} % non-bonded terms.
      \hphantom{U}   &+& \sum_{\text{atoms},\, i,j} \epsilon_{ij}%
                        \left[%
                           \left(%
                              \frac{ r^{min}_{ij} } { r_{ij} }%
                           \right)^{12}%
                           -2 \left(%
                              \frac{ r^{min}_{ij} }{ r_{ij} }%
                           \right)^6%
                        \right] \\
                     &+& \sum_{\text{atoms},\, i,j}%
                        \frac{1}{4\pi\epsilon_0\epsilon_r}\frac{q_i q_j}{ r_{ij} }
   \end{array}%
   & \left. \vphantom{% Phantom content to make brace correct size. \left. \right\} Havent worked when across two columns in array...
               \begin{array}{rcl} % non-bonded terms.
                  \phantom{U} &+& \sum_{\text{atoms},\, i,j} \epsilon_{ij}%
                                 \left[%
                                    \left(%
                                       \frac{ r^{min}_{ij} } { r_{ij} }%
                                    \right)^{12}%
                                    -2 \left(%
                                       \frac{ r^{min}_{ij} }{ r_{ij} }%
                                    \right)^6%
                                 \right] \\
                              &+& \sum_{\text{atoms},\, i,j}%
                                 \frac{1}{4\pi\epsilon_0\epsilon_r}\frac{q_i q_j}{ r_{ij} }
               \end{array}
               }%
   \right\} \text{non-bonded}
   \end{array}
   \end{equation}
\endgroup
$\sum_{\text{bonds},\, i} K_{b,i} \left( b_i - b_{0,i} \right)^2$
\lipsum[2-3]
\end{document}

答案3

这是一个解决方案,它保留了您的基本array设置,同时对其进行了一定程度的简化。在 中equation,它首先定义两个临时宏,\blocka\blockb,然后使用它们每个两次:首先排版材料本身,然后作为指令的参数\vphantom。每个“块”宏由一个array包含两列的环境组成。特别注意对齐符号+和求和符号,并在两个大块之间提供一些垂直空白。

在此处输入图片描述

\documentclass[a4paper]{book}
\usepackage{mathtools,array}
\usepackage{booktabs} % for "\addlinespace" macro
\begin{document}
\hrule % just to illustrate width of text block
\begin{equation}
\setlength\extrarowheight{1ex}
    %% Set up two scratch macros, \blocka and \blockb, for the bonded 
    %% and non-bonded terms, respectively
    \newcommand\blocka{% bonded terms
    \begin{array}{r @{} >{\displaystyle}l} % 2nd column in displaystyle
         U  ={}& \phantom{+\quad}\smashoperator[l]{\sum_{\text{bonds},\, i}} K_{b,i} ( b_i - b_{0,i} )^2 \\
               &+\quad \smashoperator[l]{\sum_{\text{angles},\, i}}
                  K_{\theta,i} (\theta_i -\theta_{0,i})^2 \\
               &+\quad \smashoperator[l]{\sum_{\text{dihedrals},\, i}}
                  K_{\phi,i} ( 1 - \cos( n\phi_i - \phi_{0,i} ) ) \\
               &+\quad \smashoperator[l]{\sum_{%
                  \substack{\text{improper},\, i\\ \text{dihedrals}}}} 
                  K_{\omega,i} ( \omega_i - \omega_{0,i} )^2 \\
    \end{array}}
    \newcommand\blockb{% non-bonded terms
    \begin{array}{r @{} >{\displaystyle}l} % 2nd column in displaystyle
        \phantom{U  ={}}
            &+\quad \smashoperator[l]{\sum_{\text{atoms},\, i,j}} \epsilon_{ij}
                        \biggl[%
                              \biggl(%
                                \frac{ r^{\min}_{ij} } { r_{ij} }
                              \biggr)^{\!12}
                           -2 \biggl(
                                \frac{ r^{\min}_{ij} }{ r_{ij} }
                              \biggr)^{\!6} \,
                        \biggr] \\ \addlinespace
            &+\quad \smashoperator[l]{\sum_{\text{atoms},\, i,j}}
                        \frac{1}{4\pi\epsilon_0\epsilon_r}
                        \frac{q_i q_j}{ r_{ij} }
   \end{array}}
   %% Now typeset the material in the two big blocks
   \begin{array}{ll} 
       \blocka & \left. \vphantom{\blocka} \right\} \text{bonded} \\ 
       \addlinespace
       \blockb & \left. \vphantom{\blockb} \right\} \text{non-bonded}
   \end{array}
   \end{equation}

\hrule  % just to illustrate width of text block
\end{document} 

相关内容