Math & Sciencecan't automatically align text in align environment

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
Theo
Posts: 1
Joined: Wed Apr 27, 2011 8:05 am

can't automatically align text in align environment

Post by Theo »

Hi I have succeeded to make the following equations nicely aligned but I had to do it manually by adding the \hspace commands to align the text. This took much too long to be worthwhile! There must be a way LaTeX can do this automatically.

Also I wanted to number each one of the three equations in my array environment but could not find the relevant help.

Please somebody?

My (halfbacked and time consuming solution - I also like to have these equations framed):

\begin{framed}
Summary of PPMA time-dependent trajectories
\begin{align}
x = x(t) = & \, x_i+{v_i}_x t \hspace{38mm} \text{(All regions)}\label{eqxt}\\
y = y(t) = & \left\{ \begin{array}{llll}
& \hspace{-5mm} \phantom{-}y_i+{v_i}_y t & (\text{region I: } t \leq t_2 = -y_i/{v_i}_y) \\
& \hspace{-5mm} \phantom{-}{v_i}_y (t-t_2) + \frac{1}{2} a (t-t_2)^2 & (\text{region II: } t_2 \leq t \leq t_3)\\
& \hspace{-5mm} -{v_i}_y(t-t_3) & (\text{region III: } t \geq t_3 = -y_i/{v_i}_y-2{v_i}_y/a )\\
\end{array}
\right.\label{eqyt}\\
z = z(t) = & \, z_i+{v_i}_z t \hspace{38mm} \text{(All regions)} & \label{eqzt}
\intertext{with}
a = & \, a_y = -(q/m) V_d/d < 0 \hspace{13mm} \text{(acceleration in II)} \label{eqa}\\
y(t_2) = & \, y(t_3) = 0 \hspace{36.5mm}\text{(ground plate of PPMA)} \label{eqyplate}
\end{align}
\end{framed}

Recommended reading 2024:

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

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

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

can't automatically align text in align environment

Post by localghost »

I can offer at least a partial solution. Try another approach with the alignat environment and two arrays. I would not number all the lines in the arrays because these are just cases for the value of one function thus represent one equation. It could be confusing.

Code: Select all

\documentclass[10pt,a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage{geometry}
\usepackage{mathtools}

\begin{document}
  \begin{alignat}{3}
    x &= x(t) &&= x_i+{v_i}_x t &&\quad \text{(All regions)}\label{eqxt}\\
    y &= y(t) &&= \left\{
                    \begin{array}{@{}l@{}}
                      \phantom{\mathrel{-}}y_i+{v_i}_y t \\
                      \phantom{\mathrel{-}}{v_i}_y (t-t_2) + \frac{1}{2} a (t-t_2)^2 \\
                      -{v_i}_y(t-t_3) \\
                    \end{array}\right. &&\quad
                    \begin{array}{@{}l@{}}
                      (\text{region I: } t \leq t_2 = -y_i/{v_i}_y) \\
                      (\text{region II: } t_2 \leq t \leq t_3) \\
                      (\text{region III: } t \geq t_3 = -y_i/{v_i}_y-2{v_i}_y/a )\\
                    \end{array} \label{eqyt} \\
    z &= z(t) &&= z_i+{v_i}_z t &&\quad \text{(All regions)} \label{eqzt}
    \intertext{with}
    a &= a_y &&= -(q/m) V_d/d < 0 &&\quad \text{(acceleration in II)} \label{eqa}\\
    y(t_2) &=  y(t_3) &&= 0 &&\quad \text{(ground plate of PPMA)} \label{eqyplate}
  \end{alignat}
\end{document}
Finally some remarks.
  • Please always check your examples for completeness and functionality. They must be compilable for others as provided.
  • The forum software offers a »Code« tag for formatting code thus better recognition. It can be found among others in the button list right above the input window.

Best regards and welcome to the board
Thorsten
Post Reply