From 29c62c64f5dfd989cca00028fff8936a324873b9 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Wed, 1 Nov 2017 14:33:22 +0900 Subject: [PATCH] Fix #4206: latex: reST label between paragraphs loses paragraph break --- CHANGES | 2 ++ sphinx/writers/latex.py | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/CHANGES b/CHANGES index d7250ae15..4bd9b4622 100644 --- a/CHANGES +++ b/CHANGES @@ -20,6 +20,8 @@ Features added Bugs fixed ---------- +* #4206: latex: reST label between paragraphs loses paragraph break + Testing -------- diff --git a/sphinx/writers/latex.py b/sphinx/writers/latex.py index 83ccd54de..df39c84fd 100644 --- a/sphinx/writers/latex.py +++ b/sphinx/writers/latex.py @@ -1919,6 +1919,12 @@ class LaTeXTranslator(nodes.NodeVisitor): # will be generated differently if id.startswith('index-'): return + + # insert blank line, if the target follows a paragraph node + index = node.parent.index(node) + if index > 0 and isinstance(node.parent[index - 1], nodes.paragraph): + self.body.append('\n') + # do not generate \phantomsection in \section{} anchor = not self.in_title self.body.append(self.hypertarget(id, anchor=anchor))