From 198862ee40702c8844e4d0503329b69a3062c49b Mon Sep 17 00:00:00 2001
From: John MacFarlane <jgm@berkeley.edu>
Date: Tue, 13 Oct 2015 21:48:14 -0700
Subject: [PATCH] LaTeX writer: add `\protect` to `\hyperdef` in inline
 context.

This way we don't get an error when this is used as a moveable
argument.

Closes #2136.
---
 src/Text/Pandoc/Writers/LaTeX.hs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs
index 0caa80795..b2e7dc1ba 100644
--- a/src/Text/Pandoc/Writers/LaTeX.hs
+++ b/src/Text/Pandoc/Writers/LaTeX.hs
@@ -748,7 +748,7 @@ inlineToLaTeX (Span (id',classes,kvs) ils) = do
   ref <- toLabel id'
   let linkAnchor = if null id'
                       then empty
-                      else "\\hyperdef{}" <> braces (text ref) <>
+                      else "\\protect\\hyperdef{}" <> braces (text ref) <>
                              braces ("\\label" <> braces (text ref))
   fmap (linkAnchor <>)
     ((if noEmph then inCmd "textup" else id) .