\myequations 后的空白行

\myequations 后的空白行

我正在使用 \myequation,但后面插入了空白行,我该如何解决?

谢谢

LaTeX 中的示例:

%%Preamble
\documentclass[12pt]{report}
\usepackage{amsmath}
%Equations
\usepackage{tocloft} 
\newcommand{\listequationsname}{List of Equations}
\newlistof{myequations}{equ}{\listequationsname}
\newcommand{\myequations}[1]{%
\addcontentsline{equ}{myequations}{\protect\numberline{\theequation}#1}\par}
\setlength{\cftmyequationsnumwidth}{2.5em}
%%%%%%%%%%%%%%%%%
\begin{document}
\listofmyequations

\chapter{}

\begin{equation}  \label{eq:mlmM} 
y_i = X_i\beta + Z_i\gamma_i + \varepsilon_i
\end{equation} 
\myequations{Generalized Linear Mixed Models}

$$\begin{cases}
\gamma_i \sim N_q(0,\psi)\\
\varepsilon_i \sim N_n(0,\sigma^2\wedge _i)
\end{cases}$$\\

\end{document}

答案1

我建议采取一种不同的方法。

首先,永远不要$$在 LaTeX 中使用。其次,永远不要有两个连续的显示:使用gatheralign

使用以下代码,命令\myequations应该是里面方程,无论是equationalign还是gather

\documentclass[12pt]{report}
\usepackage{amsmath}
\usepackage{tocloft}
\usepackage{etoolbox}
\usepackage{lipsum}

\newcommand{\listequationsname}{List of Equations}
\newlistof{myequations}{equ}{\listequationsname}
\setlength{\cftmyequationsnumwidth}{2.5em}

\makeatletter
\appto{\endequation}{\myequations@hook\gdef\myequations@hook{}}
\appto{\endalign}{\myequations@hook\gdef\myequations@hook{}}
\appto{\endgather}{\myequations@hook\gdef\myequations@hook{}}
\newcommand{\myequations}[1]{%
  \ifmeasuring@\else
    \gappto\myequations@hook{%
      \vadjust{%
        \addcontentsline{equ}{myequations}{\protect\numberline{\theequation}#1}%
      }%
    }%
  \fi
}
\makeatother

\begin{document}

\listofmyequations

\chapter{Title}

\lipsum*[2]
\begin{equation}
y_i = X_i\beta + Z_i\gamma_i + \varepsilon_i
\label{eq:1} 
\myequations{Attempt}
\end{equation}
\lipsum*[2]
\begin{gather}
y_i = X_i\beta + Z_i\gamma_i + \varepsilon_i
\label{eq:mlmM} 
\myequations{Generalized Linear Mixed Models}
\\
\begin{cases}
\gamma_i \sim N_q(0,\psi)\\
\varepsilon_i \sim N_n(0,\sigma^2\wedge _i)
\notag
\end{cases}
\end{gather}
\lipsum[4]

\end{document}

在此处输入图片描述

答案2

如果我理解正确的话,您想要删除一些空格。但是您正在使用该命令手动插入它。

\newcommand{\myequations}[1]{%
\addcontentsline{equ}{myequations}{\protect\numberline{\theequation}#1}\par}

以 结尾\par。只需将其删除,空白就会减少。

相关内容