eqnarray* 中的段落中水平框过满(pt 太宽)

eqnarray* 中的段落中水平框过满(pt 太宽)

如何避免坏盒子

\documentclass[12pt]{article} 

\usepackage{amsmath}
\usepackage{bm} 
\usepackage{bigdelim}
\usepackage{multirow}

\begin{document}
\begin{eqnarray*}
  \bm{y} =
  \begin{matrix}
  \ldelim[{2}{0.1cm}& \bm{y}_{1}\    \rdelim]{2}{0.1cm}& n_1\\
                    & \bm{y}_{2}\  & n_2\\
  \end{matrix}
  ,\bm{\mu} =
  \begin{matrix}
  \ldelim[{2}{0.1cm}& \bm{\mu}_{1}\ \rdelim]{2}{0.1cm}&n_1\\
                    & \bm{\mu}_{2}\  & n_2\\
  \end{matrix}
\end{eqnarray*}
\begin{eqnarray*}
\Sigma =
  \begin{matrix}
\ldelim[{2}{0.1cm}& \Sigma_{11} & \Sigma_{12}\ \rdelim]{2}{0.1cm}&n_1\\
              & \Sigma_{21} & \Sigma_{22}\ & n_2\\
              &n_1 & n_2 &\\
\end{matrix}
\end{eqnarray*}
\end{document}

%--------------------------------------------------------------

Overfull \hbox (4.68791pt too wide) in paragraph at lines 12--12
[]|$[]$|  

Overfull \hbox (4.68791pt too wide) in paragraph at lines 17--17
[]|$[]$|  

Overfull \hbox (4.68791pt too wide) in paragraph at lines 17--17
[]|$[]$|  

或者我也可以使用 align*

\begin{align*}
  \bm{y} =
  \begin{matrix}
  \ldelim[{2}{0.1cm}& \bm{y}_{1}\ \rdelim]{2}{0.1cm}&n_1\\
                    & \bm{y}_{2}\  & n_2\\
  \end{matrix}
  \quad, \bm{\mu} =
  \begin{matrix}
  \ldelim[{2}{0.1cm}& \bm{\mu}_{1}\ \rdelim]{2}{0.1cm}&n_1\\
                    & \bm{\mu}_{2}\  & n_2\\
  \end{matrix}
\end{align*}
\begin{align*}
\Sigma =
  \begin{matrix}
\ldelim[{2}{0.1cm}& \Sigma_{11} & \Sigma_{12}\ \rdelim]{2}{0.1cm}&n_1\\
              & \Sigma_{21} & \Sigma_{22}\ & n_2\\
              &n_1 & n_2 &\\
\end{matrix}
\end{align*}

但问题也会加倍。

Overfull \hbox (6.11073pt too wide) in paragraph at lines 21--21
[]|$[]$|  

Overfull \hbox (6.11073pt too wide) in paragraph at lines 21--21
[]|$[]$|  

Overfull \hbox (4.68791pt too wide) in paragraph at lines 21--21
[]|$[]$|  

Overfull \hbox (4.68791pt too wide) in paragraph at lines 21--21
[]|$[]$|  

Overfull \hbox (6.11073pt too wide) in paragraph at lines 21--21
[]|$[]$|  

Overfull \hbox (6.11073pt too wide) in paragraph at lines 21--21
[]|$[]$|  

Overfull \hbox (4.68791pt too wide) in paragraph at lines 21--21
[]|$[]$|  

Overfull \hbox (4.68791pt too wide) in paragraph at lines 21--21
[]|$[]$|  

Overfull \hbox (4.68791pt too wide) in paragraph at lines 29--29
[]|$[]$|  

Overfull \hbox (4.68791pt too wide) in paragraph at lines 29--29
[]|$[]$|  

Overfull \hbox (4.68791pt too wide) in paragraph at lines 29--29
[]|$[]$|  

Overfull \hbox (4.68791pt too wide) in paragraph at lines 29--29
[]|$[]$|  

答案1

您正在尝试生成某种形式的边界矩阵,因此可以使用blkarray包,参见https://tex.stackexchange.com/a/346979/15925. 因此,对于最后一个例子,你可以写类似

\begin{blockarray}{ccc}
  \begin{block}{[cc]c}
    \Sigma_{11} & \Sigma_{12} &n_1\\
    \Sigma_{21} & \Sigma_{22} & n_2\\
  \end{block}
  n_1 & n_2 &
\end{blockarray} 

它产生一个三列均居中的对齐,由初始{ccc}选项指定,但有一个带有对齐的子矩阵{[cc]c},这意味着前两列括在方括号中,足够大以包含该块的行。

不幸的是,你接下来会遇到一些与其余材料垂直对齐的问题。解决这些问题的一种方法是通过adjustbox

示例输出

\documentclass[12pt]{article}

\usepackage{amsmath}
\usepackage{blkarray,adjustbox}
\usepackage{bm}

\begin{document}
\begin{equation*}
  \bm{y} =
  \begin{adjustbox}{raise=-1ex} $\displaystyle
    \begin{blockarray}{[c]c}
      \bm{y}_{1} & n_1\\
      \bm{y}_{2} & n_2
    \end{blockarray} $
  \end{adjustbox}
  ,\quad
  \bm{\mu} =
  \begin{adjustbox}{raise=-1ex} $\displaystyle
    \begin{blockarray}{[c]c}
      \bm{\mu}_{1}&n_1\\
      \bm{\mu}_{2}& n_2
    \end{blockarray} $
  \end{adjustbox}
\end{equation*}

\begin{equation*}
  \Sigma =
  \begin{adjustbox}{raise=-2.5ex} $\displaystyle
    \begin{blockarray}{ccc}
      \begin{block}{[cc]c}
        \Sigma_{11} & \Sigma_{12} &n_1\\
        \Sigma_{21} & \Sigma_{22} & n_2\\
      \end{block}
      n_1 & n_2 &
    \end{blockarray} $
  \end{adjustbox}
\end{equation*}
\end{document}

答案2

首先,永远不要使用eqnarray:参见eqnarray 与 alignalign,但如果显示只有单行,则不要使用。

但是,箱子满溢是由于\ldelim和造成的\rdelim,而不是 造成的eqnarray

在我看来,您使用的工具是错误的。

\documentclass[12pt]{article} 

\usepackage{amsmath}
\usepackage{bm} 

\begin{document}

\begin{equation*}
\bm{y} =
\begin{bmatrix}
\bm{y}_{1}\\ \bm{y}_{2}
\end{bmatrix}
\;
\begin{matrix}
n_1\\ n_2\\
\end{matrix}
,\qquad
\bm{\mu} =
\begin{bmatrix}
\bm{\mu}_{1} \\
\bm{\mu}_{2}
\end{bmatrix}
\;
\begin{matrix}
n_1\\
n_2
\end{matrix}
\end{equation*}

\end{document}

在此处输入图片描述

一个更复杂的宏,负责处理矩阵中更大的条目。

\documentclass[12pt]{article} 

\usepackage{amsmath}
\usepackage{bm}
\usepackage{xparse}

\ExplSyntaxOn
\NewDocumentCommand{\blockcolumn}{m}
 {
  \seq_clear:N \l_magica_blockcolumn_index_seq
  \seq_set_split:Nnn \l_magica_blockcolumn_rows_seq { \\ } { #1 }
  \seq_map_inline:Nn \l_magica_blockcolumn_rows_seq
   {
    \seq_set_split:Nnn \l__magica_blockcolumn_temp_seq { & } { ##1 }
    \seq_put_right:Nx \l_magica_blockcolumn_index_seq
     {
      \seq_item:Nn \l__magica_blockcolumn_temp_seq { 2 }
     }
   }
  \hbox_set:Nn \l_magica_blockcolumn_index_box
   {
    $\begin{matrix}
    \seq_use:Nn \l_magica_blockcolumn_index_seq { \\ }
    \end{matrix}$
   }
  \begin{bmatrix}
  \seq_use:Nn \l_magica_blockcolumn_rows_seq
   { \hspace{\dim_eval:n { -\box_wd:N \l_magica_blockcolumn_index_box-2\arraycolsep}} \\ }
  \hspace{\dim_eval:n { -\box_wd:N \l_magica_blockcolumn_index_box-2\arraycolsep}}
  \end{bmatrix}
 }
\seq_new:N \l_magica_blockcolumn_rows_seq
\seq_new:N \l_magica_blockcolumn_index_seq
\seq_new:N \l__magica_blockcolumn_temp_seq
\box_new:N \l_magica_blockcolumn_index_box
\ExplSyntaxOff

\begin{document}

\begin{equation*}
\bm{y}=
\blockcolumn{
\bm{y}_{1} & n_1\\
\bm{y}_{2} & n_2
}
\\
,\qquad
\bm{\mu} =
\blockcolumn{
\sum\limits_{i=1}^k \bm{\mu}_{1i} & n_1\\
\bm{\mu}_{2} & n_2
}
\end{equation*}

\end{document}

在此处输入图片描述

相关内容