0

I have a table which looks like this:

\begin{table}[!hbt] 
\centering
    \begin{tabular}{r r c l r}
     Min & $\mathbf{c}^\intercal\mathbf{x}$ & \\
     subject to & $A\mathbf{x}$ & $=$& $\mathbf{b}$ \\
     & $\mathbf{x}$ & $\geqslant$ & 0.
    \end{tabular} 
\end{table}

I want to give this table a number, just like an equation or an alignment would have. Is this possible? And if so, how can I acomplish this?

David W.
  • 103
  • 2
    You should give it a caption instead, that is the traditional way of numbering a table, especially a floating table like this one. – daleif Jun 04 '19 at 09:45
  • If you want to use the equation counter, put it in an euation environment. What's inside the tabular environment will be in text mode. – Bernard Jun 04 '19 at 09:54
  • @daleif I used the table environment to align my equations in a certain way. I do not use any lines, so It does not really look like a table. So a caption is not what I want. – David W. Jun 04 '19 at 09:57
  • @Bernard This works. Only the horizontal spacing is increasing now... – David W. Jun 04 '19 at 10:00
  • What do you mean exactly with ‘the horizontal spacing’? – Bernard Jun 04 '19 at 10:02

1 Answers1

1

I think a table is not the right tool for what you are trying to achieve. (Also, the table environment does nothing in your example.) Depending on what exactly you are trying to achieve, align, align* or aligned may be the best choice for you. I have included some examples below.

Some general notes: One of the strengths of LaTeX is being able to separate the typography from the source input. While this is only true to a certain degree when it comes to maths, I would recommend always defining macros that represent what you want to express semantically (e.g. \vec for vectors) and define their behavior in the preamble (e.g. "print this symbol in a bold font"). When you are not happy with how some of the symbols are predefined (e.g. you prefer \geqslant or you want multiplication (\times) to be typeset using a centered dot rather than a cross), just change them and keep using the macro in a semantically consistent way.

\numberthis taken from here.

\documentclass{article}

\usepackage{amsmath, amssymb}
\usepackage{bm}

\renewcommand*\vec[1]{\bm{#1}}
\newcommand*\transpose[1]{{{#1}^\intercal}}
\let\geq\geqslant

\newcommand*\numberthis{\addtocounter{equation}{1}\tag{\theequation}}

\begin{document}

\begin{equation}
    \begin{aligned}
        \llap{\text{Min}\qquad}
        \transpose{\vec c} \vec x   \\
        \llap{\text{subject to}\qquad}
        A \vec x &= \vec b  \\
        \vec x &\geq 0
     \end{aligned}
\end{equation}

\begin{align}
    \text{Min}&&
    \transpose{\vec c} \vec x   &&\\
    \text{subject to}&&
    A \vec x &= \vec b  \\&&
    \vec x &\geq 0
\end{align}

\begin{align*}
    \text{Min}&&
    \transpose{\vec c} \vec x   &&\\
    \text{subject to}&&
    A \vec x &= \vec b  \\&&
    \vec x &\geq 0 \numberthis
\end{align*}

\end{document}

MWE output

schtandard
  • 14,892