GeneralAllignment for equations

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
volodja
Posts: 3
Joined: Mon Jun 11, 2007 5:53 pm

Allignment for equations

Post by volodja »

Hello! How to make equations aligned as in the problem 1 in the attached file?
Attachments
image002.jpg
image002.jpg (40.52 KiB) Viewed 9277 times

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
pumpkinegan
Posts: 91
Joined: Thu May 03, 2007 10:29 pm

Allignment for equations

Post by pumpkinegan »

Use the amsmath package (http://tug.ctan.org/tex-archive/macros/ ... msldoc.pdf) and the aligned environment:

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}
The ampersand (&) aligns the equation to the equals sign.

Patrick.
Ted
Posts: 94
Joined: Sat Jun 23, 2007 4:11 pm

Allignment for equations

Post by Ted »

Patrick's code isn't a perfect match, but the alignment matches. Here's a corrected version.

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*}
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.

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*}
As you can see, that' s a little simpler, BUT the alignment is a little less convenient. cases is usually used for alignment like:

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*}
So keep cases in mind for those ... um .... cases.
-- Ted [home/blog]
User avatar
pumpkinegan
Posts: 91
Joined: Thu May 03, 2007 10:29 pm

Allignment for equations

Post by pumpkinegan »

If you want to use the \mathbb fonts, remember to load the amsfonts package:

Code: Select all

\usepackage{amsmath,amsfonts}
volodja
Posts: 3
Joined: Mon Jun 11, 2007 5:53 pm

Re: Allignment for equations

Post by volodja »

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.
User avatar
Sebi
Posts: 20
Joined: Sat Jan 20, 2007 11:18 pm

Allignment for equations

Post by Sebi »

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*}
Like this?
volodja
Posts: 3
Joined: Mon Jun 11, 2007 5:53 pm

Allignment for equations

Post by volodja »

Compare these approaches:

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*}
Approach 2.

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*}
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.
Attachments
image002.jpg
image002.jpg (25.03 KiB) Viewed 9120 times
User avatar
countbela666
Posts: 64
Joined: Thu Apr 26, 2007 2:44 pm

Allignment for equations

Post by countbela666 »

Hi,

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}
Regards
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...
Post Reply