13

In the siunitx package (v1.3), I know that I can set various options with the \sisetup command. But what if I want a particular option to apply to only a small section of my document, with default behaviors for the rest of the document? How can I "unset" an option I have set and return to defaults?

Here is essentially what I'm trying to do:

Some text with SI units using default options.
\sisetup{prespace}
Some text with SI units using prespace option.
\sisetup{undo prespace, reset to default}
Some more text with SI units using default options.

Is this possible?

12

If the scope of the command is to be limited to a single table environment, say, then issuing the command \sisetup after the \begin{table} statement (but before a \begin{tabular}{...} statement) will automatically achieve your goal.

More generally, you could confine the scope of the \sisetup command by "encasing" it in a pair of \begingroup ... \endgroup commands or, less visually intrusive, with a pair of curly braces -- { and }.

Separately, the current version of the siunitx package is 2.3. If you're still working with version 1.3, as your question seems to indicate, you may want to consider upgrading the package to the latest version. :-)

  • All right, that works. It would still be nice if there were a way to reset default options with a command. But the functionality is what I needed. Thanks. – David Sempsrott Sep 30 '11 at 21:56
  • You may want to take up your issue with Joseph Wright, the author of the siunitx package and very active member (and moderator!) of this StackExchange group. – Mico Sep 30 '11 at 22:43
5

A simple way would be to use {} to make a group which restricts changes to be within that group:

\documentclass{article}
\usepackage{xcolor}
\usepackage{siunitx}

\begin{document}
{\sisetup{color = orange} 
5 \si{m^3}
}

\bigskip
5 \si{m^3}
\end{document}

enter image description here

  • In this case, \sisetup is not needed. One can use 5 \si[color = orange]{m^3} or, maybe even better \SI[color = orange]{5}{m^3}. – toliveira Oct 2 '18 at 15:35
  • 1
    @toliveira: Yes, in this MWE, it is simpler to specify the option. But, the question is about applying options to a "section of the document" and then unsetting them, hence the use of \sisetup instead of specifying all the desired options each time. – Peter Grill Oct 2 '18 at 16:48

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.