Text FormattingHow to align text below equation?

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
selocol
Posts: 1
Joined: Sun Jul 19, 2009 4:46 pm

How to align text below equation?

Post by selocol »

Dear all, how do I align 'this is a variable' to the left side of 'x -> 5' and 'this is a number' to '5' without an arrow in the second line?

x -> 5
this is a variable (align here with ->) this is a number

In other words, I want a line below x -> 5, where I can comment on both sides, but I want a space to align with the arrow instead of another arrow. Following is my attempt, but the & doesn't seem to work by itself. I also tried /hspace after $, but that does not work either.

Code: Select all

\begin{align*}
	x &\rightarrow 5 \\
	this is a variable & this is a number \\
	\end{align*}
Secondly, I can't seem to align &\rightarrow with &\colon? How do I align two different symbols in \begin{align*}...\end{align*}?

Thank you for any help or suggestions.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

How to align text below equation?

Post by frabjous »

I had a little trouble understanding what you wanted, but maybe something like this?

(Using the amsmath package.)

Code: Select all

\begin{align*}
x &\rightarrow 5 \\
\text{this is a variable} &\mathrel{\phantom{\rightarrow}} \text{this is a number} \\
\end{align*} 
Post Reply