“聚集”起来,比其“自然”宽度意外地宽

“聚集”起来,比其“自然”宽度意外地宽

我有一个gathered环境,multlined环境里面又有一个环境equation。出于某种原因,gathered环境比其自然宽度更宽。这是 MWE

\documentclass{article}

\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{amsmath}
\usepackage[utf8]{inputenc}
\usepackage{mathtools}

\begin{document}

Equation looks like expected:

\begin{equation}
  \left\lvert
    \begin{multlined}
      \Pr\left[
        1 \gets A(s)
      \middle\vert
        s \gets F(G)
      \right]\\
      {} - \Pr\left[
        1 \gets A(s')
      \middle\vert
        (s', t) \gets S(G)
      \right]
    \end{multlined}
  \right\rvert
\end{equation}

Equation with unexpected wide \verb#gathered#-environment

\begin{equation}
\left\lvert
  \begin{multlined}
    \Pr\left[
      1 \gets A\left(
        \begin{gathered}% <-- This is the problematic environment
          s',\\
          m
        \end{gathered}
      \right)
    \middle\vert
      \begin{gathered}
        s \gets F,\\
        m \gets M
      \end{gathered}
    \right]\\
    {} - \Pr\left[
      1 \gets A\left(
        \begin{gathered}
          s'\\
          m
        \end{gathered}
      \right)
    \middle\vert
      \begin{gathered}
        s' \gets F,\\
        c  \gets G
      \end{gathered}\right]
  \end{multlined}
\right\rvert
\end{equation}
\end{document}

笔记:array我知道我可以通过在第二个方程的括号内使用 - 环境来解决这个问题。但是,由于“语义”编程,我故意不这样做。我试图遵循规则(数学)向量被编码array为 ,对于单行来说太长的单个方程或项被放入 中,multline并且gather对于多个方程没有特殊对齐。虽然, left( \begin{gathered}s',\\m\end{gathered}\right)可能看起来像是一个向量,但实际上它不是。在完整的代码中s'm是两个方程。为了这个 MWE,我将它们缩短了。因此,我更愿意保留gathered

另外,我想知道什么这里出错了。

答案1

看起来像是 mathtools 和/或 amsmath 中的一个错误,但解决方法可能是

在此处输入图片描述

\documentclass{article}

\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{amsmath}
\usepackage[utf8]{inputenc}
\usepackage{mathtools}

\begin{document}

Equation looks like expected:

\begin{equation}
  \left\lvert
    \begin{multlined}
      \Pr\left[
        1 \gets A(s)
      \middle\vert
        s \gets F(G)
      \right]\\
      {} - \Pr\left[
        1 \gets A(s')
      \middle\vert
        (s', t) \gets S(G)
      \right]
    \end{multlined}
  \right\rvert
\end{equation}

Equation with unexpected wide \verb#gathered#-environment

\newsavebox\oops
\savebox\oops{$\begin{gathered}% <-- This is the problematic environment
          s',\\
          m
        \end{gathered}$}
\begin{equation}
\left\lvert
  \begin{multlined}
    \Pr\left[
      1 \gets A\left(\usebox\oops    \right)
    \middle\vert
      \begin{gathered}
        s \gets F,\\
        m \gets M
      \end{gathered}
    \right]\\
    {} - \Pr\left[
      1 \gets A\left(
        \begin{gathered}
          s'\\
          m
        \end{gathered}
      \right)
    \middle\vert
      \begin{gathered}
        s' \gets F,\\
        c  \gets G
      \end{gathered}\right]
  \end{multlined}
\right\rvert
\end{equation}
\end{document}

相关内容