Skip to content

[SOLVED] \hyperlink raise an error inside \caption #2490

Closed
hadim opened this Issue · 4 comments

2 participants

@hadim

\hyperlink introduced in d5efa9b does not place nicely with \caption command and raise this kind of error :

! Argument of \caption@ydblarg has an extra }.
<inserted text> 
                \par 

An easy fix is to use is to use \protect wich fix the issue. I tested the following diff and it works for me :

$ git diff
diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs
index 9b345fc..7cbfce9 100644
--- a/src/Text/Pandoc/Writers/LaTeX.hs
+++ b/src/Text/Pandoc/Writers/LaTeX.hs
@@ -881,7 +881,7 @@ inlineToLaTeX Space = return space
 inlineToLaTeX (Link txt ('#':ident, _)) = do
   contents <- inlineListToLaTeX txt
   lab <- toLabel ident
-  return $ text "\\hyperlink" <> braces (text lab) <> braces contents
+  return $ text "\\protect\\hyperlink" <> braces (text lab) <> braces contents
 inlineToLaTeX (Link txt (src, _)) =
   case txt of
         [Str x] | escapeURI x == src ->  -- autolink
@hadim

@jgm, since the diff is really small, I don't open a PR and let you do the commit.

@hadim

I have a question related to citation. Why does the citation links only applied on the year and note the whole citation ?

@jgm
Owner
@jgm jgm added a commit that closed this issue
@jgm LaTeX writer: add `\protect` to `\hyperlink`.
Thanks to Hadrien Mary for the problem and solution.

Closes #2490.
1d53d45
@jgm jgm closed this in 1d53d45
@hadim

Thank you !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.