## LaTeX forum ⇒ Math & Science ⇒ Difficulties in aligning equations under the flalign environment Topic is solved

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Cham
Posts: 936
Joined: Sat Apr 02, 2011 4:06 pm

### Difficulties in aligning equations under the flalign environment

I'm having some glitches with the MWE code below :
Code: [Select all] [Expand/Collapse] [Download] ({untitled.tex})
\documentclass[12pt]{article}\usepackage[total={6.25in,10in},left=1.25in,top=0.5in,includehead,includefoot]{geometry}\usepackage{mathtools}\newcommand*{\1}{\hspace{1pt}}\newcommand*{\tsqrt}[1]{{\textstyle{\sqrt{#1}}}} \begin{document} Test :	\begin{flalign}		\mathrlap{\text{if $4 \, \omega_0^2 > \gamma^2$ :}} && \lambda &= \frac{1}{2} \1 \tsqrt{\displaystyle{4 \, \omega_0^2 - \gamma^2}}, & \\[12pt]		\mathrlap{\text{if $4 \, \omega_0^2 < \gamma^2$ :}} && \kappa &= \frac{1}{2} \1 \tsqrt{\displaystyle{\gamma^2 - 4 \, \omega_0^2}}. &	\end{flalign}	\begin{equation}		EQUATION	\end{equation} \end{document}

Here's a preview :
equs.jpg (12.45 KiB) Viewed 4516 times

As you can see, the equations aren't well centered above the "EQUATION" below them. I need them to be well balanced (i.e. centered). What am I doing wrong here?

Johannes_B
Site Moderator
Posts: 4161
Joined: Thu Nov 01, 2012 4:08 pm
The equation environment does not know the content of the box (flalign) above. So the first step is to put EQUATION into the same enviroment. The example below looks ok, but you will have some real equation there and that will need extra fiddeling.
The \mathrlap stuff looks like you are used to manual spacing anyway.

Code: [Select all] [Expand/Collapse] [Download] ({untitled.tex})
\documentclass[12pt]{article}    \usepackage[total={6.25in,10in},left=1.25in,top=0.5in,includehead,includefoot]{geometry}    \usepackage{mathtools}    \newcommand*{\1}{\hspace{1pt}}    \newcommand*{\tsqrt}[1]{{\textstyle{\sqrt{#1}}}}     \begin{document}     Test :    	\begin{flalign}    		\mathrlap{\text{if $4 \, \omega_0^2 > \gamma^2$ :}} && \lambda &= \frac{1}{2} \1 \tsqrt{\displaystyle{4 \, \omega_0^2 - \gamma^2}}, & \\[12pt]    		\mathrlap{\text{if $4 \, \omega_0^2 < \gamma^2$ :}} && \kappa &= \frac{1}{2} \1 \tsqrt{\displaystyle{\gamma^2 - 4 \, \omega_0^2}}. & \\     	&&&	EQUATION    	\end{flalign}     \end{document}
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.

Cham
Posts: 936
Joined: Sat Apr 02, 2011 4:06 pm
Johannes,

what I tried to say is that the two equations in the middle should still be centered, like "EQUATION", or if there's an "align" environment, like this :
Code: [Select all] [Expand/Collapse] [Download] ({untitled.tex})
\documentclass[12pt]{article}\usepackage[total={6.25in,10in},left=1.25in,top=0.5in,includehead,includefoot]{geometry}\usepackage{mathtools}\newcommand*{\1}{\hspace{1pt}}\newcommand*{\tsqrt}[1]{{\textstyle{\sqrt{#1}}}} \begin{document} Test :	\begin{flalign}		\mathrlap{\text{if $4 \, \omega_0^2 > \gamma^2$ :}} && \lambda &= \frac{1}{2} \1 \tsqrt{\displaystyle{4 \, \omega_0^2 - \gamma^2}}, & \\[12pt]		\mathrlap{\text{if $4 \, \omega_0^2 < \gamma^2$ :}} && \kappa &= \frac{1}{2} \1 \tsqrt{\displaystyle{\gamma^2 - 4 \, \omega_0^2}}. &	\end{flalign}	\begin{align}		\lambda &= \frac{1}{2} \1 \tsqrt{\displaystyle{4 \, \omega_0^2 - \gamma^2}}, \\[12pt]		\kappa &= \frac{1}{2} \1 \tsqrt{\displaystyle{\gamma^2 - 4 \, \omega_0^2}}.	\end{align}	\begin{equation}		EQUATION	\end{equation} \end{document}

You should notice the offset in the middle, relative to the align and equation environments. I used the mathrlap command to try to fix this issue, but it's not enough.

Cham
Posts: 936
Joined: Sat Apr 02, 2011 4:06 pm
I just noticed that the numbers are pushing the equations to the left, in the flalign environment. Why ? The same doesn't happens under the align and equation environments.

Cham
Posts: 936
Joined: Sat Apr 02, 2011 4:06 pm
O well, by fizzling the equations, I fixed the alignement problem. Issue solved.

Stefan Kottwitz
Site Admin
Posts: 9567
Joined: Mon Mar 10, 2008 9:44 pm
Great to hear! Do you have code or a screenshot to see the final result for me as a quiet reader in this topic?

Stefan
LaTeX.org admin

vaman
Posts: 4
Joined: Wed Oct 09, 2019 5:51 am
Code: [Select all] [Expand/Collapse] [Download] ({untitled.tex})
\documentclass[12pt]{article}    \begin{document}    \begin{tabular} {p{4cm}p{6cm} r}     Test : & &\\     	if	$4 \omega_0^2 > \gamma^2$ & $\lambda = \frac{1}{2} \sqrt{(4\omega_0^2 - \gamma^2)}$ & (1)\\    	& & \\ if $4 \omega_0^2 < \gamma^2$  &$\kappa = \frac{1}{2}\sqrt{ (\gamma^2 - 4 \omega_0^2)}$. & (2)\\    	  & &\\    		&EQUATION &\\    	\end{tabular}     \end{document}

Here is a simple way to do the same without any additional packages.

Return to “Math & Science”

### Who is online

Users browsing this forum: No registered users and 2 guests