Math & ScienceRemove vertical Space around aligned Equations

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
ebjikki
Posts: 4
Joined: Sun Jun 03, 2012 12:11 am

Remove vertical Space around aligned Equations

Post by ebjikki »

Hey there, please can someone help me out? I need to nest a couple of math environments. I give here a small example. I get too much blank space above and below the alignedat (equation 4), see also attachment.

Code: Select all

\documentclass[10pt]{article}
\usepackage{amsmath, nccmath}

\begin{document}
\begin{fleqn}[0pt]
\begin{alignat}{2}
  & a = b \\
  & c = d \\
  & e = f
\end{alignat}
  \begin{gather}
  \begin{alignedat}{2}
  & g = h \\
  & + i \\
  & + j
  \end{alignedat}
  \end{gather}
\begin{alignat}{2}
  & k = l \\
  & m = n
\end{alignat}
\end{fleqn}
\end{document}
Adding something like \\[-1em] doesn't work well, I seem never to fit the right measure. Your suggestions are appreciated! Thank you so much for helping.
Attachments
demo.pdf
(20.88 KiB) Downloaded 621 times

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

User avatar
Stefan Kottwitz
Site Admin
Posts: 10359
Joined: Mon Mar 10, 2008 9:44 pm

Remove vertical Space around aligned Equations

Post by Stefan Kottwitz »

You could locally adjust the values \abovedisplayskip and \belowdisplayskip or even set them to 0 pt, within an environment or group.

Code: Select all

\documentclass[10pt]{article}
\usepackage{amsmath, nccmath}

\begin{document}
\begin{fleqn}[0pt]
\setlength{\abovedisplayskip}{0pt}
\setlength{\belowdisplayskip}{0pt}
\begin{alignat}{2}
  & a = b \\
  & c = d \\
  & e = f
\end{alignat}
  \begin{gather}
  \begin{alignedat}{2}
  & g = h \\
  & + i \\
  & + j
  \end{alignedat}
  \end{gather}
\begin{alignat}{2}
  & k = l \\
  & m = n
\end{alignat}
\end{fleqn}
\end{document}
Stefan
LaTeX.org admin
Post Reply