Math Mode – Center Align Columns in Math Mode in LaTeX

align

How can I center align columns in math mode using align* or one of the similar environments? I read that the columns in align environments align in the rlrlr pattern. How do I change this to a ccccc pattern?

\begin{align*}
    \dot{x}=&A&x+&B&u\\
    ...
\end{align*}

align

To explore, I used the tabular environment switching from text to math mode here. The result is what I'm looking for, but it doesn't seem like the optimal method:

    \begin{tabular}[7]{ccccccc}
        $\dot{x}$ & $=$ & $A$ & $x$ & $+$ & $B$ & $u$\\
        ...
    \end{tabular}

tabular

Is there a better way to achieve this?

Best Answer

Use array or bmatrix

\documentclass[12pt]{book}
\usepackage[a4paper]{geometry}
\usepackage{mathtools}

\begin{document}
\begin{equation*}
\begin{array}{ccc}
x & f+g & r + t^{2}\\
a = b & \text{long text} & G = \Upsilon
\end{array}
\end{equation*}

\begin{equation*}
\begin{bmatrix}
a & b = b = u & c \\
d & e & f \\
g & h & i
\end{bmatrix}
\end{equation*}
\end{document}
Related Question