2

I'm pretty new to Latex. I'm using a template from my institution so I don't have to be an expert... I want to implement this dimensional matrix:

\begin{table}[!htb]
\centering
    \begin{tabular}{c||c|c|c|c|c|}
          & W & $U_\infty$ & $\eta$ & $\rho$ & d \\
        \midrule
        \midrule
        M & 1 & 0 & 1 & 1 & 0 \\
        L & 1 & 1 & -1 & -3 & 1 \\
        T & -2 & -1 & -1 & 0 & 0 \\
        \bottomrule
    \end{tabular}
\label{...}
\end{table}

I want it to be displayed as a formula (\begin{equation} ...) in order to be able to reference it as an equation. It should have the same look though. I can't just use a normal matrix as I don't know how to put the variables and the dimensions in if I want the separating lines. How do I do that?

5

When you ask a question it is better to give a complete minimal working example that, in particular, compiles because this makes it much clearer what you want (for example, your question does not say that you are using booktabs) and also much easier for people to help you.

To answer your question, just put your table inside an equation using the array environment:

enter image description here

For the reasons explained in the booktabs manual I would drop the vertical bars and typeset this as:

enter image description here

Of course, you should do whatever suits you best!

Here is the full MWE for producing these tables.

\documentclass{article}
\usepackage{booktabs}
\begin{document}

\begin{equation}
    \begin{array}{c||c|c|c|c|c|}
          & W & U_\infty & \eta & \rho & d \\
        \midrule
        \midrule
        M & 1 & 0 & 1 & 1 & 0 \\
        L & 1 & 1 & -1 & -3 & 1 \\
        T & -2 & -1 & -1 & 0 & 0 \\
        \bottomrule
    \end{array}
    \label{E:mymatrix}
\end{equation}

\begin{equation}
    \begin{array}{cccccc}\toprule
          & W & U_\infty & \eta & \rho & d \\
        \midrule
        M & 1 & 0 & 1 & 1 & 0 \\
        L & 1 & 1 & -1 & -3 & 1 \\
        T & -2 & -1 & -1 & 0 & 0 \\
        \bottomrule
    \end{array}
    \label{E:mymatrix2}
\end{equation}

\end{document}
4

You can use the array environment which is the math mode version of tabular that assumes its entries in math mode

\documentclass{article}
\usepackage{amsmath,booktabs}

\begin{document}
\begin{equation}
    \begin{array}{c||c|c|c|c|c|}
          & W & U_\infty & \eta & \rho & d \\
        \midrule
        \midrule
        M & 1 & 0 & 1 & 1 & 0 \\
        L & 1 & 1 & -1 & -3 & 1 \\
        T & -2 & -1 & -1 & 0 & 0 \\
        \bottomrule
    \end{array}
\label{eq:lala}
\end{equation}
As can be seen from \eqref{eq:lala}, our eyes are working.
\end{document}

I wouldn't use the vertical lines though (actually no lines would be better)

4

An example with another alignment of the columns, and a different layout, which shows tables may have vertical and horizontal rules, and still look ‘professional’:

\documentclass{article}
\usepackage{amsmath,booktabs}
\usepackage[x11names,  table]{xcolor}
\usepackage{siunitx}

\begin{document}

\begin{equation}
\sisetup{table-format=-1,table-number-alignment=center}
\setlength\aboverulesep{0pt}\setlength\belowrulesep{0pt}
\setlength\extrarowheight{2pt}
    \begin{array}{c!{\color{LightSteelBlue3}\vrule width2pt}*{5}{S}}
          & {W} & {U_\infty} & {\eta} & {\rho} & {d} \\
        \arrayrulecolor{LightSteelBlue3}\midrule[1pt]
        M & 1 & 0 & 1 & 1 & 0 \\
        L & 1 & 1 & -1 & -3 & 1 \\
        T & -2 & -1 & -1 & 0 & 0
    \end{array}
\label{eq:lala}
\end{equation}

\end{document} 

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.