7

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?

cgnieder
  • 66,645
nfv
  • 173

2 Answers2

6

Here's a way to implement the tabular idea you mention in your posting.

enter image description here

(Aside: Since B appears to be column vector, I will assume that u either is or evaluates to a scalar.)

\documentclass{article}
\usepackage{amsmath,array}
\newcolumntype{C}{>{{}}c<{{}}} % col. type for binary and relational opeators

\begin{document} [ % start of an unnumbered display-math group \setlength\arraycolsep{0pt} % default value: 5pt \begin{array}{cCccCcc} \dot{x} & = & A & x & + & B & u \[\jot] \dot{x} & = & \begingroup \setlength\arraycolsep{5pt} \begin{bmatrix} 1 & 2 & 3 & 4 \ 1 & 2 & 3 & 4 \ 1 & 2 & 3 & 4 \ 1 & 2 & 3 & 4 \end{bmatrix} \endgroup & x & + & \begin{bmatrix} 1 \ 2 \ 3 \ 4 \end{bmatrix} & u \end{array} ] \end{document}

Mico
  • 506,678
4

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}

Denis
  • 5,267