# chemmacros: setting up \sisetup only once for all experimental environments

I am using the experimental environment of chemmacros spectroscopy module. Right now I am running \sisetup{} for every instance of the environment and was now wondering if there is a way to circumvent calling it every single time.

In my MWE I will just use one of the settings as an example.

\documentclass{scrbook}

\usepackage{chemmacros}
\chemsetup{modules=spectroscopy}

\sisetup{
round-mode = figures
}

\begin{document}
\num{3.456789}

\begin{experimental}
\sisetup{round-mode=off}
\num{3.456789} % I use \val{}, but this is for comparison
\end{experimental}

\end{document}


Basically, I would like to run \sisetup{} once for all experimental environments.

You could use the package etoolbox to automatically set \sisetup{round-mode=off} at the beginning of the experimental environment:

\documentclass{scrbook}

\usepackage{chemmacros}
\chemsetup{modules=spectroscopy}

\sisetup{
round-mode = figures
}

\usepackage{etoolbox}
\AtBeginEnvironment{experimental}{\sisetup{round-mode=off}}

\begin{document}
\num{3.456789}

\begin{experimental}
%        \sisetup{round-mode=off}
\num{3.456789} % I use \val{}, but this is for comparison
\end{experimental}

\num{3.456789}

\end{document}

• I was about to answer the same :) – clemens Oct 20 '17 at 14:43
• @clemens sorry :) – user36296 Oct 20 '17 at 14:44
• @samcarter nevermind – clemens Oct 20 '17 at 23:20