So this is my example, closely related to Remove extra curly braces. Apart from my application, trying to line-break the labels in the margin even if they do not have spaces in them, I am trying to understand what's going on.
\documentclass{article}
\usepackage{showlabels}
\usepackage{seqsplit}
\usepackage{xpatch}
\makeatletter
% line-break annotations, http://tex.stackexchange.com/a/148613/30810
\patchcmd{\showlabelsetlabel}{#1}{\parbox[t]{\marginparwidth}{\myseqsplit{#1}}}{}{err}
% remove extra curly braces, http://tex.stackexchange.com/a/300871/30810
\newcommand{\myseqsplit}[1]{\expandafter\seqsplit\expandafter{\@firstofone#1}}
% remove curly braces from text
\patchcmd{\SL@margintext}{\{\SL@prlabelname{#1}\}}{#1}{}{err}
% testing patch: overwrite *definition* of \SL@prlabelname (twice because two code paths) - no effect
% \patchcmd{\SL@margtext}{\xdef\SL@labelname{\SL@prlabelname{#1}}}{\xdef\SL@labelname{kooooooooooooooooooooooooooooooong}}{}{err}
% \patchcmd{\SL@margtext}{\xdef\SL@labelname{\SL@prlabelname{#1}}}{\xdef\SL@labelname{kooooooooooooooooooooooooooooooong}}{}{err}
% testing patch: overwrite *use* of \SL@prlabelname - has an effect
% \patchcmd{\@eqnnum}{\SL@eqntext{\SL@labelname}}{\SL@eqntext{pooooooooooooooooooooooooooooooong}}{}{err}
% down the road, show the argument being passed. no change with either patch!
\pretocmd{\SL@eqnlrtext}{\edef\test{#1}\meaning\test}{}{err}
\begin{document}
\begin{equation}
\label{looooooooooooooooooooooooooooooong}
\end{equation}
\end{document}
The first line should be fairly obvious, defining the parbox
to put the label in. The second is related to my aforementioned question, because I assumed extra curly brackets may be the culprits here (I don't think they are any more). The third simplifies the text in the parbox
to make it one single-group argument, see above.
Now, while this whole thing does work outside of an equation
environment (different code paths), it does not work within, and I was trying to investigate why. (This is why this MWE is pretty much boiled down to this single case.)
My two optional patches overwrite the definition and the use of \SL@labelname
. Interestingly, while overwriting the definition does not work (it works, but has no effect on line breaks), overwriting the use DOES work. Even more interestingly, the last patch further down the road is there to show the value of the argument, and this value does not seem to change between the different patches (at least not in a way that I can see a difference).