This is a fairly unimportant itch, but if it is easy/exists, please let me know. The \newlabel macro defines a label and warns if another label wants to overwrite it. In analogy with \newcommand / \renewcommand / \providecommand,
Is there a
\providelabelmacro that defines a label only if it has not yet been defined?Is there a
\renewlabelmacro that overwrites a label if it exists
This is (marginally) useful when many chapters are in separate tex files and sometimes compiled by themselves, sometimes together with others (into a complete book). I would like to providelabels from a grepped file from other aux files that fill in only when not already included.
\usepackage{refcount} \newcommand\providelabel[1]{\ifnum\getrefnumber{#1}=0\relax\label{#1}\fi}. For the second,\labelwill overwrite the original label if it exists...of course, it will also generate a warning. – Steven B. Segletes Mar 12 '21 at 18:22\newlabelcommand is only used in.auxfiles. Never in documents. – egreg Mar 12 '21 at 18:35