[Tex/LaTex] Text column in array

amsmatharraystables

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?

Best Answer

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*}
    \begin{array}{L@{\quad}c@{{}={}}c}
       some text:            & x^2 & x^2 \\
       more thoughts:        & y^2 & y^2 \\
       really deep thoughts: & z^2 & z^2
    \end{array}
\end{equation*}
\end{document}

enter image description here