Code: Select all
\robustify{\label}
\iftoggle{PRINTLABELS}{
\let\oldLabel\label
\renewrobustcmd{\label}[1]{\oldLabel{#1}\text{Equation #1}\\}
}{}
Code: Select all
\renewcommand{\label}[1]{}
Code: Select all
\robustify{\label}
\iftoggle{PRINTLABELS}{
\let\oldLabel\label
\renewrobustcmd{\label}[1]{\oldLabel{#1}\text{Equation #1}\\}
}{}
Code: Select all
\renewcommand{\label}[1]{}
NEW: TikZ book now 40% off at Amazon.com for a short time.
And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p
\renewcommand
on the \label
macro?The package does nothing else. Just take a look at its (very short) source code.littlegolem wrote:[…] Isn't it possible to use\renewcommand
on the\label
macro?
It does. You probably haven't set the toggle to true. Or maybe you've set it only to true after the possible definition? This works:littlegolem wrote:... However, I still wonder why my small invention did not work...
Code: Select all
\documentclass{article}
\usepackage{mathtools}
\usepackage{etoolbox}
\newtoggle{PRINTLABELS}
\toggletrue{PRINTLABELS}% <= this enables the new definition
\robustify{\label}
\iftoggle{PRINTLABELS}{% <= you should set the % here if you want to avoid spurious spaces.
\let\oldLabel\label
\renewrobustcmd{\label}[1]{\oldLabel{#1}\text{~Equation #1}}%
}{}
\begin{document}
Text\label{bla}
\end{document}
Code: Select all
\documentclass{article}
\usepackage{mathtools}
\usepackage{etoolbox}
\newtoggle{PRINTLABELS}
\let\oldLabel\label
\renewrobustcmd\label[1]{%
\iftoggle{PRINTLABELS}{~Equation~#1}{}\oldLabel{#1}}
\begin{document}
Text\label{bla}
\toggletrue{PRINTLABELS}
Text\label{blub}
\end{document}
NEW: TikZ book now 40% off at Amazon.com for a short time.
And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p