Skip to content

Commit

Permalink
LaTeX writer: add \leavevmode before hypertarget at start of paragr…
Browse files Browse the repository at this point in the history
…aph.

Closes #2704 (formatting problems in beamer citations).

See
http://tex.stackexchange.com/questions/22852/function-and-usage-of-leavevmode
  • Loading branch information
jgm committed Mar 2, 2017
1 parent 8709b7c commit 46135ac
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/Text/Pandoc/Writers/LaTeX.hs
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,14 @@ blockToLaTeX :: PandocMonad m
blockToLaTeX Null = return empty
blockToLaTeX (Div (identifier,classes,kvs) bs) = do
beamer <- gets stBeamer
linkAnchor <- hypertarget True identifier empty
linkAnchor' <- hypertarget True identifier empty
-- see #2704 for the motivation for adding \leavevmode:
let linkAnchor =
case bs of
Para _ : _
| not (isEmpty linkAnchor')
-> "\\leavevmode" <> linkAnchor' <> "%"
_ -> linkAnchor'

This comment has been minimized.

Copy link
@wilx

wilx Mar 2, 2017

Contributor

@jgm I have noticed small visual issue while constructing test case for #3255. I have not compiled this patched Pandoc yet but I have noticed that if the resulting LaTeX looks like this, without % on the second line, there is small horizontal space at the start of the reference:

\leavevmode\hypertarget{refs}{}%
\hypertarget{ref-aiid3749018}{}
Text

I think the % needs to be added to both lines or the text should immediately follow the \hypertarget without the intervening new line.

This comment has been minimized.

Copy link
@jgm

jgm via email Mar 3, 2017

Author Owner

This comment has been minimized.

Copy link
@jgm

jgm via email Mar 3, 2017

Author Owner
let align dir txt = inCmd "begin" dir $$ txt $$ inCmd "end" dir
let wrapDir = case lookup "dir" kvs of
Just "rtl" -> align "RTL"
Expand Down

0 comments on commit 46135ac

Please sign in to comment.