Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider adding \MakeLinkTarget{} before \label for tables #406

Open
lierdakil opened this issue Sep 24, 2023 · 4 comments
Open

Consider adding \MakeLinkTarget{} before \label for tables #406

lierdakil opened this issue Sep 24, 2023 · 4 comments

Comments

@lierdakil
Copy link
Owner

Extracted from #402:

Of interest, in my testing over the last few weeks I discovered that with longtable if \label is prefixed with \MakeLinkTarget{} then the anchor is the same as with regular floats that respect the default hypcap=true option of the caption package (loaded by pandoc-crossref). This macro has been included in the hyperref package since release 7.00o of 2022-05-15, and is documented in hyperref-linktarget.pdf. Not sure if you would consider it worthwhile adding that, which I have been using in a lua filter run after pandoc-crossref.

@jpcirrus
Copy link

With LaTeX output, pandoc-crossref loads the caption package, which by default sets the option hypcap=true, thereby making the anchors of hyperref package links at the beginning of the (floating) environment, and raised by an amount as determined by the caption package option hypcapspace, which has the default value of 0.5\baselineskip. This results in some whitespace above the target in a PDF viewer e.g:

20230925T103844-Preview@2x

instead of:

20230925T103731-Preview@2x

However, this does not work for longtable environments (i.e. pandoc tables), where the option hypcapspace=0pt is always in effect. By prefixing the \label command of pandoc tables with the \MakeLinkTarget{} command from the hyperref package. The functionality of the hypcapspace option effectively also works for longtables, therefore matching the behaviour of all other floats.

Potential drawback: This command was only added to hyperref in release 7.00o, on 2022-05-15.

@lierdakil
Copy link
Owner Author

Where does \MakeLinkTarget{} put the actual bookmark? Is it ultimately attached to the float (good) or to the caption (bad)? I'm a bit unclear on how that would interact with \captionsetup[table]{position=bottom} (or equivalent)

@jpcirrus
Copy link

Pandoc tables (i.e. longtable) are written with the \caption command placed at the beginning of the environment, above \endfirsthead (i.e. the start of the table). Currently, it is not possible to change the position of the caption as written by pandoc, and it is unlikely to change either, considering longtable has the potential for multi-page tables. \captionsetup[table]{position=} has no effect on where the caption is output, but indicates whether the extra space that separates the caption and, in this case, table should be either above or below the caption. The default of auto is correct in the case of the standard classes, but say in KOMA-Script, the \KOMAoptions{captions=abovetable} option needs to be set. An exception to the above is with floats created by the float package (e.g. codelisting), where the position and spacing of the caption is solely determined by the \floatstyle command.

So, in this case of longtable, with the caption above the table, \MakeLinkTarget{} works correctly by raising the link target above the baseline of the caption.

@lierdakil
Copy link
Owner Author

Ah, right, my mistake, as I said, my LaTeX-fu is very rusty. Sounds good. As for the concern about MakeLinkTarget being rather new, we can just check if the command exists and alias it to noop if it doesn't. I'll see if I can get to it this weekend.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants