3

I have an equation in multiple lines. I want to left-align the equations in three columns. How can I do this in Latex?

I am currently using

\begin{equation}
\begin{aligned}
&Column1& &Column2&  &Column3 \\
&Column1& &Column2&  &Column3 \\
&Column1& &Column2&  &Column3 \\
\end{equation} 
\end{aligned}

However, with the above expression the third column is right-aligned rather than being left aligned.

Here is an example:

\begin{equation}\label{formula:QPQC} \begin{aligned} &\underset{x}{\textbf{Maximize} }& &x^TFx+2f^Tx & & \\ &\textbf{Subject to} & &p_i^Tx+p_{i0}\geq 0 &i=1,\ldots,I \\ & & &v_m^Tx+v_{m0}=0 &m=1,\ldots,M \\ & & & x^TQ_zx+2q_z^Tx+q_{z0}=0 &z=1,\ldots,Z , \end{aligned} \end{equation}

5
  • With that input I get left alignment for all three columns. Can you show an example that doesn't?
    – egreg
    Feb 6, 2016 at 11:29
  • I added an example
    – Admia
    Feb 6, 2016 at 11:41
  • 2
    You're missing an & between the second and third column
    – egreg
    Feb 6, 2016 at 11:44
  • Oh! I forgot! Welcome to TeX.SX!
    – egreg
    Feb 6, 2016 at 11:48
  • @egreg an answer? :)
    – cmhughes
    Feb 6, 2016 at 11:56

1 Answer 1

4

You are missing an & between the second and third column.

Here are some suggestions for avoiding the mistake and for improving the output:

  1. give && in pairs next to each other and keep the alignment in the input

  2. define macros for “Maximize” and “Subject to”

  3. use \dots instead of \ldots.

\documentclass{article}
\usepackage{amsmath}

\newcommand{\Maximize}[1]{\underset{#1}{\mathbf{Maximize}}}
\newcommand{\Subjto}{\mathbf{Subject\ to}}

\begin{document}

\begin{equation}\label{formula:QPQC}
\begin{aligned}
&\Maximize{x} && x^TFx+2f^Tx &            &&             \\
&\Subjto      && p_i^Tx+p_{i0}\geq 0      && i=1,\dots,I \\
&             && v_m^Tx+v_{m0}=0          && m=1,\dots,M \\
&             && x^TQ_zx+2q_z^Tx+q_{z0}=0 && z=1,\dots,Z,
\end{aligned}
\end{equation}

\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .