如何消除部分和方程之间的空格

如何消除部分和方程之间的空格

我正在制作一份备忘单,需要尽可能地删除不需要的空间。但是,我就是不知道如何删除 (子) 部分标题和公式之间添加的这个空格:

梅威瑟:

\documentclass[8pt]{extarticle}
\usepackage[paper=a5paper]{geometry}

\usepackage[english]{babel}

\usepackage{mathtools}
\usepackage{amssymb}
\usepackage[nodisplayskipstretch]{setspace}

\usepackage{titlesec}
\titlespacing{\section}{0pt}{0pt}{0pt}
\titlespacing{\subsection}{0pt}{0pt}{0pt}
\titlespacing{\subsubsection}{0pt}{0pt}{0pt}

\setlength{\parindent}{0pt}
\setlength{\parskip}{0pt}
\setlength{\parsep}{0pt}
\setlength{\lineskip}{0pt}
\setlength{\intextsep}{0pt}

% Display mode equation spacing
\expandafter\def\expandafter\normalsize\expandafter{%
    \normalsize
    \setlength\abovedisplayskip{0pt}
    \setlength\belowdisplayskip{0pt}
    \setlength\abovedisplayshortskip{0pt}
    \setlength\belowdisplayshortskip{0pt}
}

\begin{document}
\section{Section}
\begin{equation*}
q = q_0 + q_1i + q_2j + q_3k = (q_0,q_1,q_2,q_3)
\end{equation*}
\section{Section}
Some text
\begin{equation*}
q = q_0 + q_1i + q_2j + q_3k = (q_0,q_1,q_2,q_3)
\end{equation*}
More text
\end{document}

答案1

使用\noindent之前\begin{equation}

\section{Section}
\noindent\begin{equation*}
q = q_0 + q_1i + q_2j + q_3k = (q_0,q_1,q_2,q_3)
\end{equation*}

原因:在 之后 TeX 以垂直模式运行\section。如果 display math 以垂直模式启动,则立即打开水平模式,并在其前面加上\parindent。但是,当没有 时,您可以避免使用这一行\parindent。这可以通过 来实现\noindent

您可以\noindent在每一个之前插入\begin{equation}:如果水平模式已经打开,则不执行任何操作。您可以创建生成或重新定义的\noindent宏。\noindent\begin{equation}\begin{equation}

答案2

对于备忘单,我相信最好重新定义\section\subsection

\documentclass[8pt]{extarticle}
\usepackage[paper=a5paper]{geometry}

\usepackage[english]{babel}

\usepackage{mathtools}
\usepackage{amssymb}

\renewcommand{\section}[1]{%
  \par
  \stepcounter{section}%
  \everypar{\textbf{\thesection\ #1}\quad\everypar{}}%
}
\renewcommand{\subsection}[1]{%
  \par
  \stepcounter{subsection}%
  \everypar{\textbf{\thesubsection\ #1}\quad\everypar{}}%
}

\setlength{\parindent}{0pt}
\setlength{\parskip}{0pt}
\setlength{\parsep}{0pt}
\setlength{\lineskip}{0pt}

\AtBeginDocument{%
  \setlength\abovedisplayskip{0pt}%
  \setlength\belowdisplayskip{0pt}%
  \setlength\abovedisplayshortskip{0pt}%
  \setlength\belowdisplayshortskip{0pt}%
}

\begin{document}

\section{Section}
\begin{equation*}
q = q_0 + q_1i + q_2j + q_3k = (q_0,q_1,q_2,q_3)
\end{equation*}

\section{Section}
Some text for explaining the following equation
\begin{equation*}
q = q_0 + q_1i + q_2j + q_3k = (q_0,q_1,q_2,q_3)
\end{equation*}
More text follows the equation

\end{document}

在此处输入图片描述

答案3

解决问题的两种方法:

\documentclass[8pt]{extarticle}
\usepackage[paper=a5paper]{geometry}
\usepackage[english]{babel}
%\usepackage{parskip}
%\setlength{\parindent}{0pt}
\usepackage{mathtools}
\usepackage{amssymb}

\usepackage{titlesec}
\titlespacing{\section}{0pt}{0pt}{0pt}
\titlespacing{\subsection}{0pt}{0pt}{0pt}
\titlespacing{\subsubsection}{0pt}{0pt}{0pt}


\def\mycommand{\setlength{\abovedisplayskip}{0pt}%
\setlength{\belowdisplayskip}{0pt}%
\setlength{\abovedisplayshortskip}{0pt}%
\setlength{\belowdisplayshortskip}{0pt}}

\AtBeginDocument{\mycommand}

\let\oldnormalsize\selectfont
\def\selectfont{\oldnormalsize\mycommand}

\newenvironment{myeq}{\vspace{-10pt}\par\begin{equation*}}{\end{equation*}\vspace{-10pt}}

\newsavebox{\mybox}
\newlength{\mylength}
\def\myinleq#1{\savebox\mybox{$#1$}\settowidth{\mylength}{\usebox{\mybox}}\hspace{0.5\dimexpr\linewidth-\mylength-2\parindent\relax\relax}$#1$}

\begin{document}
\section{Section}
\begin{myeq}
q = q_0 + q_1i + q_2j + q_3k = (q_0,q_1,q_2,q_3)
\end{myeq}

\begin{myeq}
q_2 = q_0 + q_1i + q_2j + q_3k = (q_0,q_1,q_2,q_3)
\end{myeq}%emptyline needed here

\myinleq{q_3 = q_0 + q_1i + q_2j + q_3k = (q_0,q_1,q_2,q_3)}

\section{Section}
\noindent Some text
\begin{equation*}
q = q_0 + q_1i + q_2j + q_3k = (q_0,q_1,q_2,q_3)
\end{equation*}
More text
\end{document}

在此处输入图片描述

相关内容