伸展聚集环境个人

伸展聚集环境个人

在我正在做的讲义中,我们使用了很多方程式。为了设置它们,我经常使用包gather的环境amsmath。但我并不喜欢它的标准外观。首先,我无法影响垂直空间(方程式之前或之后)的大小。这就是为什么我对环境做了一些改变gather并将其命名为Gather
我展示它的工作原理:

\makeatletter
\newlength{\mathe}
\mathe3pt
\newlength{\mathvariable}
\mathvariable3pt
\newlength{\foren}
\newcommand{\en}{\\[\foren]}        
\newcommand{\stretchtheequations}{0}

\newenvironment{Gather}[1][\stretchtheequations]{%
\setlength{\mathe}{#1\mathvariable}%
\setlength{\foren}{10.75pt+1.5\mathe}
\vskip-\parskip%
\vskip-\baselineskip%
\vskip\mathe% -24pt
  \start@gather\st@rredfalse%
}{%
  \math@cr \black@\totwidth@ \egroup%
  $$\ignorespacesafterend%
  \vskip-\parskip%
  \vskip\mathe% -24pt
}
\makeatother

它基于软件包gather中的标准环境amsmath
它将添加setlengthvskip命令,其余部分来自原始版本。

以下最小的例子可以帮助我解释我想要做的事情:

\documentclass[11pt]{memoir}
\parskip10pt

\usepackage[fleqn]{amsmath}
\usepackage{blindtext}
\usepackage{calc}
\usepackage{multicol}  
% include here the code above

\begin{document}

\blindtext\ -- equation is compressed
    \begin{Gather}[-2.5]
        a+b+c+d   \en
        a+b+c+d   \en
        a+b+c+d   
    \end{Gather}
\blindtext\ -- equation is stretched
    \begin{Gather}[3]
        a+b+c+d   \en
        a+b+c+d   \en
        a+b+c+d   
    \end{Gather}
\blindtext

\clearpage
Look, how it looks, with columnbreak inside the multicols environment:

\begin{multicols}{2}
    \blindtext
    \columnbreak
    \begin{gather}
        a+b+c+d
    \end{gather}
    \blindtext
    \\\bfseries The gather environment begins at the same height as the text at left side. That's exactly what I want with my new Gather environment.
\end{multicols}

\clearpage
Look, how it looks, with columnbreak inside the multicols environment:

\begin{multicols}{2}
    \blindtext
    \columnbreak
    \begin{Gather}
        a+b+c+d
    \end{Gather}
    \blindtext
    \\\bfseries The Gather environment begins NOT at the same height as the text at left side.
\end{multicols}

\cleartoverso
\blindtext

\clearpage
    \begin{Gather}
        a+b+c+d
    \end{Gather}
\blindtext
\end{document}

在第一页,您可以看到拉伸是如何工作的。
第 3 页显示,如果我使用gather内部环境multicols,则等式的第一行将与左侧文本的高度完全相同。
在第 4 页,您可以看到情况并非Gather如此。如果我使用之后的环境
,情况也是一样的(参见第 6 页和第 7 页)。Gather\clearpage

现在的问题是

我想创建一个与现在完全相同的环境,但有一个例外,如果在命令, ,Gather之后立即使用等式,则不会在等式前面添加任何垂直空格。 因此,行为与第 3 页 multicols 环境中和之后的行为相同。\clearpage\pagebreak\newpage
gather\columnbreak

答案1

我不太明白长度的设置,但这里有一些东西可以帮助你:

\makeatletter
\newenvironment{Gather}[1][0]
  {\abovedisplayskip=2pt \belowdisplayskip=\abovedisplayskip
   \setlength{\mathe}{#1\mathvariable}%
   \setlength{\foren}{10.75pt+1.5\mathe}%
   \start@gather\st@rredfalse}
  {\math@cr \black@\totwidth@ \egroup
   $$\ignorespacesafterend}
\makeatother

您可以对\abovedisplayskip和进行操作\belowdisplayskip,设置文本与Gather环境内容之间的距离。这样\parskip就不会插入任何胶水。

相关内容