I am looking for \iftoggledefined{<toggle name>}{<true>}{<false>}. I checked the etoolbox documentation and did not see such a thing.
Based on Difference between \newbool and \newtoggle from etoolbox package, one could use \ifcsdef{etb@tgl@#1}, but if the etoolbox code was ever change this test would break. Thus, would prefer to use an offical macro if it exists.
Question:
Can I obtain the same output as the given MWE
ToggleA: Exists
ToggleB: Does Not Exist
without relying on the internal etb@tgl@#1 code of etoolbox.
Code:
\documentclass{article}
\usepackage{etoolbox}
\makeatletter
\newcommand{\iftoggledefined}[3]{\ifcsdef{etb@tgl@#1}{#2}{#3}}
\makeatother
\newtoggle{ToggleA}
\begin{document}
ToggleA: \iftoggledefined{ToggleA}{Exists}{Does Not Exist}
ToggleB: \iftoggledefined{ToggleB}{Exists}{Does Not Exist}
\end{document}
\newtoggleuses\ifcsdef{etb@tgl@#1}, I guess that this is a safe test. – egreg Jan 28 '22 at 08:24