Control the alignment of each “cell” in amsmath's aligned environment

In amsmath's aligned environment, the alignment of each "cell", or each "column" is predetermined, and seems to work in the following way: the first "column" is aligned to the right, the second to the left, the third to the right again, and so forth.

My question is, is there any way to adjust the alignment of each "cell" (left, center, or right)? As an example, I was trying to create a diagram with aligned:

  \begin{aligned} \sigma & \colon & F(\alpha) & \overset{\sim}{\to} & F'(\beta)\\ & & | & & |\\ \varphi & \colon & F & \overset{\sim}{\to} & F' \end{aligned}


The desired behavior is pretty obvious, but the actual output is

-
aligned may not be the best choice for your particular example- try tikz-cd instead. –  cmhughes Dec 15 '13 at 6:12
@cmhughes Well, I simply grabbed an example at hand, and it is not the best example illustrating the problem. Of course we can solve the very problem by using other environments—even tabular will be much more controllable. But that does not answer the question regarding aligned. –  4ae1e1 Dec 15 '13 at 6:15
An MWE would be helpful. –  vaettchen Dec 15 '13 at 6:22
aligned is not meant to be used for commutative diagrams. (i believe this is documented, but if not or it isn't clear, i will add a request for that to happen.) if you have just a rectangular diagram, then have a look at amscd. for anything more complicated, a dedicated package for diagrams is warranted. –  barbara beeton Dec 15 '13 at 20:15
Thanks everybody for suggesting creative/standard ways to do the tiny job at hand. However, as I have pointed out in some comment, I was questioning the "theoretical possibility" of alignment in aligned, which I couldn't find anywhere, rather than trying to get the simple job done. (If I simply needed to get the job done, I would ask Google rather than TeX.SX, which is kind of a waste of resources, you know; anyway, thanks for pointing out the right tools.) That's why I accepted the not-so-elegant answer, as it is the only one that properly addressed aligned. –  4ae1e1 Dec 15 '13 at 23:55

You may be better off with tikz-cd or ..... But here, you can use a newcommand:

 \newcommand*{\mbc}[2]{\makebox[\widthof{$F(\alpha)$}][#1]{$#2$}}


which makes a box of width same as $F(\alpha)$ with the help of calc package.

\documentclass{article}
\usepackage{amsmath,calc}
\newcommand*{\mbc}[2]{\makebox[\widthof{$F(\alpha)$}][#1]{$#2$}}
\begin{document}
\begin{aligned} \mbc{r}{\sigma} & \colon & \mbc{c}{F(\alpha)} & \overset{\sim}{\to} & F'(\beta)\\ & & \mbc{c}{|} & & \mbc{c}{|}\\ \phi & \colon & \mbc{c}{F} & \overset{\sim}{\to} & \mbc{c}{F'} \end{aligned}
\end{document}


Use c for center, l for left and r for right alignment.

-
Thanks. Given the not-so-elegant solution I would abandon the idea. You are right with "please remember that All that can be done may/should not be done." I won't get pissed off or something, so you don't need to remove it actually ;-) I was simply wondering about the theoretical possibility, and I simply grabbed the example at hand, which led me to the question but definitely isn't a good example for using aligned. –  4ae1e1 Dec 15 '13 at 6:36
@KevinSayHi Hehe, I thought it would be rude :-) You did right. Use a proper package always. :-) –  Harish Kumar Dec 15 '13 at 7:29

A tikz-cd attempt

\documentclass{article}
\usepackage{tikz-cd}
\begin{document}
\begin{tikzcd}
\sigma\colon\hspace*{-4.5em} & F(\alpha) \arrow{r}{\sim} \arrow[dash]{d}
& F'(\beta) \arrow[dash]{d} \\
\varphi\colon\hspace*{-4.5em} & F \arrow{r}{\sim}
& F'
\end{tikzcd}
\end{document}


Surely the code can be improved, I'm not a tikz expert at all...

This is the result if you substitute dash with equal

-

For such a simple construction you can use the good old CD environment:

\documentclass{article}
\usepackage{amsmath,amscd}
\begin{document}
$\begin{CD} \sigma\colon @. F(\alpha) @>\sim>> F'(\beta) \\ @. @| @| \\ \varphi\colon @. F @>\sim>> F' \end{CD}$
\end{document}


However, it's better to switch to modern packages such as tikz-cd that are more flexible and powerful.

-
I just think the CD syntax is really unreadable for most people, so I'd rather recommend the tixz-cd approach plus the vertical equal –  daleif Dec 15 '13 at 14:02
@daleif It's like cycling: once learnt you don't forget how to do it. ;-) I agree that using a full featured package is better; for a one shot diagram, CD can be very helpful. –  egreg Dec 15 '13 at 14:06
I'm editing a book at the moment that is using amscd. I'm redoing all of them. Mostly it is one lie exact sequences, so I just use modified \xrightarrows –  daleif Dec 15 '13 at 15:28