Setting variable with gdef does not work

by A Diyanat   Last Updated July 25, 2019 03:23 AM - source

Please consider the following MWE:

\documentclass{report}
\usepackage{amsthm}

\makeatletter
%Define variable
\gdef\@depRe{chapter}
\def\depRe#1{\gdef\@depRe{#1}}

%Usie variable
\theoremstyle{plain}
\newtheorem{theorem}{Theorem}[\@depRe]
\makeatother

%Set variable
\depRe{section}

\begin{document}
\chapter{Network}
\section{Cellular}
\begin{theorem}
This is an example.
\end{theorem}
\end{document}

As you can see, I defined 'depRe' variable and use it as theorem counter. But it does not worked for me and the value of 'depRe' (i.e. section) does not applied! Now put \depRe{section} before \newtheorem ..., so it works. Does any solution exist, which I can set 'depRe' after \newtheorem command?

It is worth noting that I have TexLive 2019.

Tags : macros amsmath


Related Questions


How do magic \dots work in amsmath?

Updated May 09, 2019 12:23 PM

Macro shortcut for \mathrm command

Updated September 29, 2017 20:23 PM

Star/Wye electrical connection math symbol

Updated March 26, 2019 15:23 PM

Incomplete iffalse using xstring

Updated June 10, 2017 07:23 AM