6

The header might be a bit weird. But I would like to add a specified column type that is reserved to units.

For instance, take a look at the following working example:

\documentclass[10pt,a4paper]{report}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{siunitx}
\usepackage{array}
    \newcolumntype{M}{>{$} l <{$}}

\begin{document}

\begin{align}
R &= \sqrt{Q\: \frac{t}{\pi\: b\: n_{eff}}}
\end{align}

Where:\\

\begin{tabular}{M |l l}
R & Radius for BNBO & $\left[\si{\meter}\right]$ \\
Q & Extraction rate & $\left[\si{\cubic\meter\per\second}\right]$ \\
t & Time frame for BNBO & $\left[\si{\second}\right]$ \\
b & Aquifer thickness & $\left[\si{\meter}\right]$ \\
n_{eff} & Effective porosity & $\left[\si{--}\right]$ \\
\end{tabular}
\end{document}

This should return this:Columns test

Now, what I would like to do, is to be free of writing all the stuff before and after the unit. This means that instead of writing

$\left[\si{\cubic\meter\per\second}\right]$

I would simply just write

\cubic\meter\per\second

as the only thing for the unit description of Q.

As you can see, I have already defined a column with respect to math, the column M. I have tried to do it in a similar way with units, which returned an error. The code I tried was

\newcolumntype{U}{>{$\left[\si{ l <}\right]$}}

Inserting U into the third column and deleting math and siunitx environment, like this

\begin{tabular}{M |l U}
    R & Radius for BNBO & \meter \\
    Q & Extraction rate & \cubic\meter\per\second \\
    t & Time frame for BNBO & \si{\second \\
    b & Aquifer thickness & meter \\
    n_{eff} & Effective porosity & - \\
\end{tabular}

the following error occurs:

Package array Error: >{..} at wrong position: token ignored. \begin{tabular}{M |l U}

I can't really figure it out. Please help me!

Troy
  • 13,741

4 Answers4

8
  1. Please unlearn your habit of using \left ... \right all over

  2. Drop the [], they do nothing to the interpretation of that column

  3. use the s column, and in that column just write say \meter

In code

\documentclass[10pt,a4paper]{report}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{siunitx}
\usepackage{array,booktabs}
\newcolumntype{M}{>{$} c <{$}}
\newcommand\mc[1]{\multicolumn{1}{c}{#1}}
\begin{document}

\begin{tabular}{M l s } %|
\toprule
\mc{Variable} & Meaning & \mc{Unit} \\
\midrule
R & Radius for BNBO & \meter\\
Q & Extraction rate & \cubic\meter\per\second\\
t & Time frame for BNBO & \second\\
b & Aquifer thickness & \meter\\
n_{\textup{eff}} & Effective porosity & \mc{---} \\
\bottomrule
\end{tabular}
\end{document}

enter image description here

daleif
  • 54,450
  • 2
  • Variables that are physical quantities shouldn't have prescribed units; if the equation and values are dimensionally consistent, the equation holds.
  • – Paul Gessler Jan 30 '15 at 12:30
  • 1
    Since I intend to use the column type with no headlines (e.g. Unit headline), I prefer the square brackets []. And I would really like new column type with that. But thank you for the tip of using s column. – aloevgaard Jan 30 '15 at 12:43
  • I still think it is better for the reader. What if the person reading it does not know the meaning of [m]? – daleif Jan 30 '15 at 12:46
  • @AndreasLøvgaard Unnecessary cryptic writing. There is nothing wrong with a header line. Your Where: does not serve anything in your example in that regard also. – percusse Jan 30 '15 at 13:44
  • I just wanted to say thanks for this discussion; where I used to study, it was actually a formal convention that units should be put in square brackets [], which is how I came upon this question - so to me, it is not cryptic at all. @PaulGessler - no one disputes whether the equation will hold; but if I see the equation for the first time (and if I'm, say, slightly dumb), are you saying that it would be easier for me to understand the dimensional relationships by not having the units spelled out? – sdaau Feb 17 '15 at 01:09