# Text column in array

I am trying to do something that seems relatively simple but I can't get it to work. Basically, I would like one of the columns in my math mode array to be text, so I am trying to use pre and post processing >{} and <{} like so

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align}
\begin{array}{{>{\text\bgroup}c<{\egroup}}@{:}c@{=}c}
a & x^2 & x^2 \\
b & y^2 & y^2 \\
c & z^2 &  z^2
\end{array}
\end{align}
\end{document}


This leads to an "illegal character in array arg" error. What is the right way to do this?

-

You're close. In the modified example below, I'm using the array environment and define a special column type, L', that's automatically in text mode. The reason this works is because l, c, and r are automatically in math mode in an array environment.

Note the second intercolumn specifier, @{{}={}}: The pairs of {} curly braces before and after the = sign are there to inform TeX that the = sign is to be treated as a so-called mathrel object. In case this sounds a bit cryptic: mathord, mathbin, and mathrel objects each have different amounts of whitespace before and after them. An easy way to make TeX treat a = symbol as a mathrel object even though it occurs in a non-equation setting is to pre- and post-fix it with (empty) math "atoms", viz., {}.

Note also that it's not necessary to use the align environment as there is really only one "equation" in the example.

\documentclass{article}
\usepackage{array,amsmath}
\newcolumntype{L}{>$l<$}
\begin{document}
\begin{equation*}

Thanks for your answer. I don't believe I was including the array package and depending on LaTeX's native array support. So for the line \newcolumntype{L}{>$l<$} to work, I guess I will have to use the array package and understand the syntax. –  fg nu Jul 11 '12 at 1:53
Okay, so that was pretty amazing. I was wondering why you were telling me all the stuff about mathrel till I added the math atoms and noticed the difference. Double thumbs up to you. ;) –  fg nu Jul 11 '12 at 2:00
@FgNu: The syntax isn't that difficult to master, trust me. Given that the l-type column is automatically in math mode when in an array environment, the >$ prefix serves to end math mode; conversely, the <$ specifier serves to re-enter math mode at the end of the cell's content. As long as you load the array package, you don't actually have to use the \newcolumntype command to set up a column of type L; it suffices (but is less readable, I'd say) to specify >$l<$. –  Mico Jul 11 '12 at 2:01