tecosaur / org-glossary

Mirror of https://git.tecosaur.net/tec/org-glossary
GNU General Public License v3.0
97 stars 4 forks source link

Acronyms in captions - LaTeX export error #12

Closed jdm204 closed 1 year ago

jdm204 commented 1 year ago

Hi, great package, thanks.

When I export to LaTeX with an acronym in a caption (for a figure), I get this error from lualatex:

! Argument of \Hy@tempa has an extra }.

When I look at the .tex the caption looks like this:

\caption{Testing \hyperlink{gls-5}{\label{gls-5-use-3}WWW}.}

After playing around for a bit, I found adding a \protect like so:

\caption{Testing \protect\hyperlink{gls-5}{\label{gls-5-use-3}WWW}.}

fixes the problem for reasons unknown to me.

Is this issue related to this package or org export in general? I'm trying to dig into it but I don't have much experience.

jdm204 commented 1 year ago

I found that I can just put this in my init

(org-glossary-set-export-spec 'latex t
      :use "\\protect\\hyperlink{gls-%K}{\\label{gls-%K-use-%r}%t}")

to avoid the problem---I'm unsure if this will cause other problems later but it's working for now.

tecosaur commented 1 year ago

Thanks for the report with fix. It looks like \protect is a fairly safe addition, so I'm inclined to make this change in the default value.

jdm204 commented 1 year ago

Great, FWIW I've now exported several documents with the \protect setting and I haven't seen any unwanted side effects!

tecosaur commented 1 year ago

I've just pushed d8071ef6ed95d31d69b069c0300f5cd40df198b9, which applies this change.

Thanks for letting me know about this :)