1

I have been trying to use a parameter description provided by @egreg. (see How to write a perfect equation parameters description? ).

\newlength{\conditionwd}
\newenvironment{variables}[1][where\quad]
  {%
   #1\tabularx{\textwidth-\widthof{#1}}[t]{
     >{$}l<{$} @{${}:\enspace{}$} X@{}
   }%
  }
  {\endtabularx\\[\belowdisplayskip]}

That worked fine for me (I changed the style a bit from @egreg 's answer). I am however interested in adding the units as an additional column in this description.

Currently my example is as follows:

\begin{equation} \label{eq:bingham}
\uptau=\uptau_0+\upmu*\dot{\upgamma}
\end{equation}

\begin{variables}
\text{$ \uptau $} & shear stress\\
\text{$ \uptau_0 $} & yield stress\\
\text{$ \upmu $} & plastic viscosity \\
\text{$ \dot{\upgamma} $} & shear rate
\end{variables}

Producing:

enter image description here

Is there some way of producing a code similar to:

 \begin{variables}
    \text{$ \uptau $} & shear stress & [Pa]\\
    \text{$ \uptau_0 $} & yield stress & [Pa]\\
    \text{$ \upmu $} & plastic viscosity & [Pa*s]\\
    \text{$ \dot{\upgamma} $} & shear rate & [s^-1]
    \end{variables}

Which could produce something like: enter image description here

However, I want the units to be aligned on the [-bracket, and not manually have to algin the spacing.

Is that possible? Can somebody help with the solution? Many Thanks already!

  • Notice that putting units in square brackets is wrong. Brackets means "unit of" and should be used around a quantity, not around a unit. Thus, for instance, you can write $[\tau]=\mathrm{Pa}$. See for example this discussion and references therein. – Massimo Ortolano Sep 4 '16 at 18:27
5

This is basically just a tabular, so you could add another column, by inserting at the line >{$}l<{$} @{${}:\enspace{}$} X@{}. Here, I've changed the two columns into l-columns, change this to what you need depending on how much spacing you want, or assign it specifically with for instance p{3cm}.

Some expleneation

The columnspecification here seems a bit cryptics, so lets run through it. Here is the full line:

>{$}l<{$} @{${}:\enspace{}$} l>{(}l<{)}@{}

This are specifications for three columns, so I'll go through them one by one:

First column

>{$}l<{$} Would be the first column. Here we see some syntax from the arraypackage, and we find some info in the documentation, table 1, page 2 about this syntax:

>{decl.} Can be used before an l, r, c, p, m or a b option. It inserts decl. directly in front of the entry of the column.

<{decl.} Can be used after an l, r, c, p, m or a b option. It inserts decl. right after the entry of the column.

So, >{$}l<{$} would insert $ both before and after the contents of every cell in this column. The first cell here is set to \uptau, and it would then be transformed into $\uptau$. The column-type is l, for left-aligned.

Second column

@{${}:\enspace{}$}l This is really just a l-column (left-aligned), and the part in front is a syntax for the columnseperation. We see that because it starts with @. Since this is suppose to typeset math, we want the spacing the be consistent with that, and therefore $ are put around the \enspace, which is a length of whitespace. Have a look at What commands are there for horizontal spacing? for more info. A : (colon) is also inserted, to be output directly.

Third column

>{(}l<{)}.The mechanics of this is explained in the first column. In short it would add paranteses to the input.


Units

Units should not be typeset in squarebraces. This is a very common mistake. Here, I would instead put them in standard paranteces.

I've also added siunitx, which I think you will find very useful. It is great for typesetting numbers and units, whether it is within text, math or tables. It has some global settings which can be changed easily to suit your countries preferences.


Math-confusion

The first column of your environment will be typeset it mathmode. This can be seen with >{$}l<{$}. The code means that each cell will have $ both in front of and after it, so it will therefore be in math. You probably overlooked this, and tried to put $\uptau$ in the argument for the first cell. That would be a double switching, first into math mode, then into text-mode again, giving an error. To counter this, you seem to have put it inside \text{} again, which would introduce a triple switching. We could reduce all this clutter by simply using \uptau.

Correct me if I am wrong but in your equation, you seem to be using * as a multiplication symbol. This should in most cases either be typeset as nothing or as \cdot. Some texts liek to print it as a cross, with the \times-symbol, even though this has a very different meaning in math. I have taken the liberty to typeset the equation on three different lines, just to show the options. I would stick to the third one.


Finding documentation

Note that you can always locate the documentation using the command-line/terminal by writing texdoc siunitx, and that works for any package. The documentation is also available at http://ctan.org/pkg/siunitx


Output

enter image description here

Code

\documentclass[11pt]{article}
\usepackage{mathtools}
\usepackage{upgreek}
\usepackage{tabularx}
\usepackage{siunitx}

\newlength{\conditionwd}
\newenvironment{variables}[1][where\quad]
  {%
   #1\tabularx{\textwidth-\widthof{#1}}[t]{
     >{$}l<{$} @{${}:\enspace{}$} l>{(}l<{)}@{}
   }%
  }
  {\endtabularx\\[\belowdisplayskip]}
\begin{document}

\begin{align} \label{eq:bingham}
    \uptau&=\uptau_0+\upmu*\dot{\upgamma}\\
    \uptau&=\uptau_0+\upmu\cdot\dot{\upgamma}\\
    \uptau&=\uptau_0+\upmu\dot{\upgamma}
\end{align}

\begin{variables}
    \uptau          & shear stress\\
    \uptau_0        & yield stress\\
    \upmu           & plastic viscosity \\
    \dot{\upgamma}  & shear rate
\end{variables}

 \begin{variables}
    \uptau          & shear stress          & \si{\pascal}\\
    \uptau_0        & yield stress          & \si{\pascal}\\
    \upmu           & plastic viscosity     & \si{\pascal\second}\\
    \dot{\upgamma}  & shear rate            & \si{\per\second}
    \end{variables}
\end{document}
  • Hi @RunarTrollet many many thanks for your reply. That was a great help! I was trying to get past implementing the siunitx-package, as I hadn't done to up till now, but I may change that in future. I also saw the package textgreek exists. That would have definitely helped me. I was a bit confused with the math-mode. Thanks for the \cdot hint. I have just one question: could you break down >{$}l<{$} @{${}:\enspace{}$} l>{(}l<{)}@{}for me? I get now, that {} before and after are for the symbols of the column. But what are >< for. And what does the @ symbol mean? Many thanks!! – magicdivadd Sep 4 '16 at 15:02
  • Also, have a look at en.wikibooks.org/wiki/LaTeX/Tables#.40-expressions – Runar Sep 4 '16 at 16:34
  • @magicdivadd I added some explenation of the code. – Runar Sep 4 '16 at 17:58
  • Many Thanks! That was a great help :) And it looks great :) – magicdivadd Sep 5 '16 at 6:35

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.