SvenPistre / cleveref-usedon

Patches the cleveref package and adds forward-referencing functionality
LaTeX Project Public License v1.3c
6 stars 1 forks source link

Bug: Error if label includes "=" #3

Open pwintz opened 1 year ago

pwintz commented 1 year ago

I have a document with a theorem labeled as result:bound on distance traveled by solution to dot x = f(x). When I use \cref[UsedBy]{result:bound on distance traveled by solution to dot x = f(x)} the following error occurs:

LaTeX3: Missing/extra '=' in
(LaTeX3)    'UsedBy@result:boundondistancetraveledbysolutiontodotx=f(x)=5'
(LaTeX3)    (in '..._keyval:Nn')

No error occurs if I use \cref{result:bound on distance traveled by solution to dot x = f(x)}.

Here's the relevant portion of my document configuration:

\usepackage[noabbrev, capitalise, nameinlink]{cleveref} 

    % Enable back reference to items that we reference. 
    \usepackage{cleveref-usedon}
    \RenewDocumentCommand{\UsedByMessage}{ m }{%
        % Using "\leavevmode" causes the margin note to be aligned with the top of the paragram. See https://tex.stackexchange.com/a/16161/153678
        \leavevmode\marginpar{\tiny[#1]}%
    }
Jinwen-XU commented 1 year ago

This is caused because = is used to match the keys and values in the property. Adding an extra group around the key name for protection would solve the problem.

\iow_now:cx { @auxout }
   {
      \prop_gput_from_keyval:Nn \token_to_str:N \g__UsedOn_kv_prop
         {{##1}=##2} % <-- here
   }