Math & Sciencealign function with long equations

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
LLLatexJ9
Posts: 1
Joined: Thu Aug 01, 2024 7:41 am

align function with long equations

Post by LLLatexJ9 »

Hi all,

I'm having two issues:
1. The align function is not aligning my equation to the centre of the page centred at the "=" sign
2. It is also not wrapping my equation around, I couldn't figure out how to make it do this

Any help would be much appreciated, please find the code below:

Code: Select all

\begin{align*}
\sum_{v \in V(G)} \deg_G(v) &= 2 \left| E(G) \right|
\\
\left| \{ \text{deg}_G(v) : \text{deg}_G(v) = 1 \} \right| + \left| \{ \text{deg}_G(v) : \text{deg}_G(v) = 2 \} \right| + \left| \{ \text{deg}_G(v) : \text{deg}_G(v) = 3 \} \right| &= 2\left| E(G) \right|\\
\left| \{ \text{deg}_G(v) : \text{deg}_G(v) = 1 \} \right| &= 2\left| E(G) \right| - \left| \{ \text{deg}_G(v) : \text{deg}_G(v) = 2 \} \right| - \left| \{ \text{deg}_G(v) : \text{deg}_G(v) = 3 \} \right|
\hfill\\
\end{align*}
Thanks
Last edited by Stefan Kottwitz on Thu Aug 01, 2024 1:54 pm, edited 1 time in total.
Reason: code marked

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
TikZ book
User avatar
Stefan Kottwitz
Site Admin
Posts: 10311
Joined: Mon Mar 10, 2008 9:44 pm

align function with long equations

Post by Stefan Kottwitz »

Hi,

welcome to the forum!

1. That's because the equation ist too wide and doesn't fit. It can only start at the left margin, so the "=" sign cannot be at the page center. You see it when you use a bigger paper in landscape mode:

Code: Select all

\documentclass{article}
\usepackage[a3paper,landscape]{geometry}
\usepackage{amsmath}
\begin{document}
\begin{align*}
\sum_{v \in V(G)} \deg_G(v) &= 2 \left| E(G) \right|
\\
\left| \{ \text{deg}_G(v) : \text{deg}_G(v) = 1 \} \right| + \left| \{ \text{deg}_G(v) : \text{deg}_G(v) = 2 \} \right| + \left| \{ \text{deg}_G(v) : \text{deg}_G(v) = 3 \} \right| &= 2\left| E(G) \right|\\
\left| \{ \text{deg}_G(v) : \text{deg}_G(v) = 1 \} \right| &= 2\left| E(G) \right| - \left| \{ \text{deg}_G(v) : \text{deg}_G(v) = 2 \} \right| - \left| \{ \text{deg}_G(v) : \text{deg}_G(v) = 3 \} \right|
\hfill\\
\end{align*}
\end{document}
2. There's no automatic line breaking in displayed equations, you need to do it manually. The breqn package supports automatic line breaking, but it's hard to apply here.

Stefan
LaTeX.org admin
Post Reply