General ⇒ Allignment for equations
Allignment for equations
Hello! How to make equations aligned as in the problem 1 in the attached file?
- Attachments
-
- image002.jpg (40.52 KiB) Viewed 9278 times
- pumpkinegan
- Posts: 91
- Joined: Thu May 03, 2007 10:29 pm
Allignment for equations
Use the amsmath package (http://tug.ctan.org/tex-archive/macros/ ... msldoc.pdf) and the aligned environment:
The ampersand (&) aligns the equation to the equals sign.
Patrick.
Code: Select all
\begin{equation}
\left \{
\begin{aligned}
u_t + b \cdot D u + c u &= 0 \quad \text{in $\mathbf{R}^n \times (0,\infty)$} \\
u &= g \quad \text{on $\mathbf{R}^n \times (t = 0)$}.
\end{aligned}
\right.
\label{eqn:example}
\end{equation}
Patrick.
Allignment for equations
Patrick's code isn't a perfect match, but the alignment matches. Here's a corrected version.That is, those mathbf's should be mathbb. Additionally, the second argument of the second Cartesian product should have curly braces so it is a set. Oh, and I've stripped the label and tag.
However, you might like to consider the cases environment instead of surrounding an aligned with a curly brace. cases is also in amsmath.As you can see, that' s a little simpler, BUT the alignment is a little less convenient. cases is usually used for alignment like:So keep cases in mind for those ... um .... cases.
Code: Select all
\begin{equation*}
\left \{
\begin{aligned}
u_t + b \cdot D u + c u &= 0 \quad \text{in $\mathbb{R}^n \times (0,\infty)$} \\
u &= g \quad \text{on $\mathbb{R}^n \times \{t = 0\}$}.
\end{aligned}
\right.
\end{equation*}
However, you might like to consider the cases environment instead of surrounding an aligned with a curly brace. cases is also in amsmath.
Code: Select all
\begin{equation*}
\begin{cases}
u_t + b \cdot D u + c u &= 0 \quad \text{in $\mathbb{R}^n \times (0,\infty)$} \\
u &= g \quad \text{on $\mathbb{R}^n \times \{t = 0\}$}.
\end{cases}
\end{equation*}
Code: Select all
\begin{equation*}
f(x) \triangleq
\begin{cases}
0 &\text{if $x < 0$}, \\
x &\text{if $x \in [0,1]$}, \\
1 &\text{if $x > 1$}.
\end{cases}
\end{equation*}
- pumpkinegan
- Posts: 91
- Joined: Thu May 03, 2007 10:29 pm
Allignment for equations
If you want to use the \mathbb fonts, remember to load the amsfonts package:
Code: Select all
\usepackage{amsmath,amsfonts}
Re: Allignment for equations
Thank you very much. But I want the equations to be aligned not only in the "=" sign but also with respect to "in" and "on". If you write a longer expression instead of "g" in the second equation, you'll see that there's no alignment with respect to "in" and "on".
I tried substituting "\quad" with "&&" in the Patrick's example and obtained what desired. I wonder is it possible to make this "double alignment" in other environments like \cases etc.? It is also desirable that braces be input automatically as in \cases.
I tried substituting "\quad" with "&&" in the Patrick's example and obtained what desired. I wonder is it possible to make this "double alignment" in other environments like \cases etc.? It is also desirable that braces be input automatically as in \cases.
Allignment for equations
volodja wrote: Thank you very much. But I want the equations to be aligned not only in the "=" sign but also with respect to "in" and "on". If you write a longer expression instead of "g" in the second equation, you'll see that there's no alignment with respect to "in" and "on".
Code: Select all
\begin{equation*}
\left \{
\begin{aligned}
u_t + b \cdot D u + c u &= 0 &\text{in} \quad& \mathbb{R}^n \times (0,\infty) \\
u &= g & \text{on}\quad& \mathbb{R}^n \times \{t = 0\}.
\end{aligned}
\right.
\end{equation*}
Allignment for equations
Compare these approaches:
Approach 1 (of yours).
Approach 2.
I prefer the second one (below is the picture). Do you know other environments allowing to align equations the same way (as in approach 2)? It would be very good if braces be input automatically; I tried this trick with \cases but it didn't work.
Approach 1 (of yours).
Code: Select all
\begin{equation*}
\left \{
\begin{aligned}
u_t + b \cdot D u + c u &= 0 & \text{ inside } & \Omega \\
u &= g_1 + g_2 + g_3 & \text{ on } & \partial\Omega.
\end{aligned}
\right.
\end{equation*}
Code: Select all
\begin{equation*}
\left \{
\begin{aligned}
u_t + b \cdot D u + c u &= 0 && \text{ inside } \Omega \\
u &= g_1 + g_2 + g_3 && \text{ on } \partial\Omega.
\end{aligned}
\right.
\end{equation*}
- Attachments
-
- image002.jpg (25.03 KiB) Viewed 9121 times
- countbela666
- Posts: 64
- Joined: Thu Apr 26, 2007 2:44 pm
Allignment for equations
Hi,
you could very easily define your own cases environment based on the aligned environment to do the job:Regards
Marcel
you could very easily define your own cases environment based on the aligned environment to do the job:
Code: Select all
\documentclass{scrartcl}
\newenvironment{mycases}
{\left\{\begin{aligned}}
{\end{aligned}\right.}
\usepackage{amsmath}
\begin{document}
\begin{equation*}
\begin{mycases}
u_t + b \cdot D u + c u &= 0 && \text{ inside } \Omega \\
u &= g_1 + g_2 + g_3 && \text{ on } \partial\Omega.
\end{mycases}
\end{equation*}
\end{document}
Marcel
Listen to me children of the night, beyond the doors of darkness you will find
a thousand worlds for you to see here, take my hand and follow me...
a thousand worlds for you to see here, take my hand and follow me...