Math & ScienceProper alignment of cases within align environment possible?

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
Phillip
Posts: 2
Joined: Tue Dec 30, 2014 8:39 pm

Proper alignment of cases within align environment possible?

Post by Phillip »

Dear community,

there are several equations with domains. Some of these equations include cases.

Do you know any way that allows a consistent horizontal alignment of the domains?

The environment cases inside align results in that domains are not aligned at the same position.

Example

\begin{align}
a_i &=
\begin{dcases}
b_i & i \leq 0 \\
c_i & i < 0
\end{dcases} \\
d_i &= e_i &\forall i
\end{align}


Thank you in advance and happy New Year!
Phillip
Attachments
Example
Example
Clipboard02.jpg (6.6 KiB) Viewed 28765 times

Recommended reading 2024:

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

NEW: TikZ book now 40% off at Amazon.com for a short time.

Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Proper alignment of cases within align environment possible?

Post by Johannes_B »

High and welcome, i did not test your example, because it is not compilable and my battery is low. But you are ending the line after the casses environment with a double backslash. If i understood you correctly, you need to write »for all i« just before ending the line, i.e. \end{cases} \forall i \\
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
Phillip
Posts: 2
Joined: Tue Dec 30, 2014 8:39 pm

Re: Proper alignment of cases within align environment possi

Post by Phillip »

Thanks for your quick response!

I think I did not clearly present the problem.

Please take a look at this picture. It is a photo montage. It shows what the result should look like. You can see that equality signs are aligned AND the domains are aligned.

Unfortunately, your suggestion does not result in such an output.
Attachments
photo montage of desired outcome
photo montage of desired outcome
Clipboard09.jpg (5.96 KiB) Viewed 28744 times
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Proper alignment of cases within align environment possible?

Post by Johannes_B »

Sorry for the late reply, your question somehow got lost within myy stack.

I am not sure if it is possible to align that properly, i would simply suggest to space this by hand. If you have to do this multiple times, this isn't a good solution though.

Code: Select all

\documentclass{article}
\usepackage{mathtools}
\begin{document}
\begin{align}
	a_i &=
	\begin{dcases}
		b_i & i \leq 0 \\
		c_i & i < 0
	\end{dcases} \\
	d_i &= e_i \quad\quad\forall i
\end{align}
\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.
Post Reply