如何将大方程式置于页面中央?

如何将大方程式置于页面中央?

我有以下定义,我正尝试将其输入到我的 Latex 文档中。我尝试将其放在 \centerline{...} 和 \adjustbox{center}{...} 中,但尽管有外部 \[ ... \],我仍然不断收到有关事物未处于数学模式的错误。

\adjustbox{center}{
    \[\\
        \mathbf{M}_{a}^{b}(p) = \left\{\begin{array}{lr}
            \emptyset   
            &   (\floor{\frac{\max(a, b)}{p}} - \ceil{\frac{\min(a, b)}{p}} + 1) = 0 \\
            
            p \times \left\{
                \ceil{\frac{\min(a, b)}{p}}, \ceil{\frac{\min(a, b)}{p}} + 1,   
                ..., 
                \floor{\frac{\max(a, b)}{p}} - 1, \floor{\frac{\max(a, b)}{p}}
            \right\}    
            &   otherwise \\
        \end{array}\right\}
    \]
}

请告知在 Latex 中使用数学模式将这样的长定义居中的正确方法。

答案1

可能adjustbox在里面使用\[...\],但结果真的很糟糕:

\documentclass{article}
\usepackage{amsmath,mathtools}
\usepackage{adjustbox}

\usepackage{lipsum} % for context

\DeclarePairedDelimiter{\floor}{\lfloor}{\rfloor}
\DeclarePairedDelimiter{\ceil}{\lceil}{\rceil}

\begin{document}

\lipsum[1][1-5]
\[
\adjustbox{center}{$
\mathbf{M}_{a}^{b}(p) =
\left\{\begin{array}{lr}
  \emptyset & (\floor{\frac{\max(a, b)}{p}} - \ceil{\frac{\min(a, b)}{p}} + 1) = 0 \\
  p \times \left\{
                \ceil{\frac{\min(a, b)}{p}}, \ceil{\frac{\min(a, b)}{p}} + 1,   
                \dots, 
                \floor{\frac{\max(a, b)}{p}} - 1, \floor{\frac{\max(a, b)}{p}}
            \right\}    
  &   \text{otherwise}
\end{array}\right\}$}
\]
\lipsum[2]

\end{document}

在此处输入图片描述

该公式显然难以理解。

\documentclass{article}
\usepackage{amsmath,mathtools}
\usepackage{adjustbox}

\usepackage{lipsum} % for context

\DeclarePairedDelimiter{\floor}{\lfloor}{\rfloor}
\DeclarePairedDelimiter{\ceil}{\lceil}{\rceil}

\begin{document}

\lipsum[1][1-4]
We can define
$\mathbf{M}_{a}^{b}(p) = \emptyset$
when $(\floor{\frac{\max(a, b)}{p}} - \ceil{\frac{\min(a, b)}{p}} + 1) = 0$ and
\[\textstyle
\mathbf{M}_{a}^{b}(p)=
p \times \left\{
    \ceil*{\frac{\min(a, b)}{p}}, \ceil*{\frac{\min(a, b)}{p}} + 1,   
    \dots, 
    \floor*{\frac{\max(a, b)}{p}} - 1, \floor*{\frac{\max(a, b)}{p}}
\right\}
\]
otherwise. \lipsum[2]

\end{document}

在此处输入图片描述

答案2

通过使用\medmath\mfracnccmath以及casesmathtools,您可以将方程大小减少约 20%:

\documentclass{article}
%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%
\usepackage{lipsum}% For dummy text. Don't use in a real document

\usepackage{nccmath, mathtools}
\DeclarePairedDelimiter{\floor}{\lfloor}{\rfloor}
\DeclarePairedDelimiter{\ceil}{\lceil}{\rceil}

\begin{document}

\lipsum[11]
    \[\medmath{
\mathbf{M}_{a}^{b}(p) =
    \begin{dcases}
\emptyset   & \biggl(\floor*{\mfrac{\max(a, b)}{p}} - 
                        \ceil*{\mfrac{\min(a, b)}{p}} + 1\biggr) = 0 \\[1ex]
    \begin{multlined}
p \times \biggl\{\ceil*{\mfrac{\min(a, b)}{p}},
                 \ceil*{\mfrac{\min(a, b)}{p}} + 1,\dotsc, \\
    \dotsc,\floor*{\mfrac{\max(a, b)}{p}} - 1, \floor*{\mfrac{\max(a, b)}{p}}\Biggr\}
    \end{multlined}
            &   \text{otherwise}
    \end{dcases}}
\]
\lipsum[66]

\end{document}

在此处输入图片描述

相关内容