1

I have generated a bunch of files (exp1.tex-exp10.tex) for different experiments that define my variables by

\renewcommand{\minabserror}{\SI{0.01}{\meter}~}%
\renewcommand{\minabserrorat}{\SI{1.4}{\meter}~}%

In my float text, I can therefore write

\input{exp1}
The maximum rangee is \minabserror and occured at \minabserrorat.

\input{exp2}
The maximum range is \minabserror and occured at \minabserrorat.

, which will have the expected outcome.

When I do this in a table by

\begin{table}
\begin{tabular}{ccc}
number    &    minerror    &     location     \\
\input{exp1}
1         &    \minabserror &     \minabserrorat  \\
\input{exp2}
2         &    \minabserror &     \minabserrorat  \\
\end{tabular}
\caption{my summary table}
\end{table}

, my "variables" are not updated.

  • \renewcommand isn't global, i.e. it's only redefined in the table cell and then 'swallowed' by the cell group – user31729 May 9 '16 at 10:48
1

Use \gdef instead of \renewcommand, which is not global and does not survive from one table cell (where is used with \input) to the next table cell. However, \gdef (global def) does survive this cell grouping.

Depending on the precise usage there are better strategies or setups, most likely.

exp1.tex

\gdef\minabserror{\SI{0.01}{\meter}~}%
\gdef\minabserrorat{\SI{1.4}{\meter}~}%

and exp2.tex

\gdef\minabserror{\SI{0.05}{\meter}~}%
\gdef\minabserrorat{\SI{1.9}{\meter}~}%

The main document:

\documentclass{article}

\usepackage{siunitx}
\providecommand{\minabserror}{}
\providecommand{\minabserrorat}{}


\begin{document}
\begin{table}
\begin{tabular}{ccc}
number    &    minerror    &     location     \\
\input{exp1}
1         &    \minabserror &     \minabserrorat  \\
\input{exp2}
2         &    \minabserror &     \minabserrorat  \\
\end{tabular}
\caption{my summary table}
\end{table}
\end{document}

enter image description here

  • thanks, this is what i was looking for. any hints for better strategies? – cschmol May 9 '16 at 12:03
  • @cschmol: No, not really. This would require more insight in your real document, i.e. what you really want to achieve. – user31729 May 9 '16 at 12:04
  • ok, well anyway I don't have time for improvement now, submission in two days :/ – cschmol May 9 '16 at 13:15

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.