Open Ricq opened 5 years ago
This is mostly a tex question. I would have thought that the syntax pandoc is generated would bind the hypertarget to the chapter heading. If there's a better way to do it, we can adjust the latex writer accordingly.
Having the same issue, but with the default template. If I render to an intermediate .tex
file and manually edit that, moving the \hypertarget
after the \chapter
directive, the link instead points to just below the heading.
Instead of:
\hypertarget{section-1}{%
\chapter{Section 1}\label{section-1}}
I change it to:
\chapter{Section 1}\hypertarget{section-1}{\label{section-1}}
This is perhaps not ideal, but better than ~1,5 page too early, as @Ricq also notes. But if it's possible to get it at the heading, that would be ideal. My LaTeX-foo isn't strong enough to help with that, I'm afraid.
As described in this issue for the Eisvogel template I'm having issues with the way auto_identifiers generates hypertargets for chapters. The hypertarget is generated as an element in Latex just before the chapter element, but in the PDF conversion this hypertarget becomes linked to the paragraph before the chapter instead of the heading itself. In this way, hyperlinks to chapters are always targeting the page before, or in my two-sides book case, frequently one-and-a-half page before the chapter. This is quite confusing and annoying for the reader clicking the link.
To repeat what I wrote there: I'm building a book with multiple chapters, where I use Pandoc auto_identifiers function to be able to reference headings. I'm creating a two-sided book, where each chapter is on a new blank right page.
For example, a heading target in my markdown is:
I reference that chapter somewhere further in the book, like:
When I build a PDF (via Latex and Eisvogel), open the PDF and click the link, the link resolves to the previous page (with the blank left page that may be inserted because of the two-sided book, even the before last page). It seems that the hyperlink target is actually bound to the last line of text before the chapter heading. This is quite confusing for the reader.
If we look at the intermediate Latex file, this is what is generated:
It seems to me that the target is not linked to the chapter, but considered a seperate element in the layout, and is thereby not bound to the chapter text, but typeset before the blank page of the chapter.
Would it be possible in some way to make the
hypertarget
bind to the actual position of the heading in the resulting PDF?Example: clicking the link currently navigates me to the blue arrow, while I want to be directed to the red arrow.
The Eisvogel template author referred me here, and I guess I agree with him. Would it be possible for Pandoc's
auto_identifiers
extension to create ahypertarget
that is tied to the actual heading?P.S.: I'm using Pandoc 2.7.2.