1

I've got this code here

\documentclass[a4paper, 12pt]{scrartcl}

% ----- Packages ----- \usepackage[colorlinks=false,breaklinks=true]{hyperref} % make e.g. toc clickable

% ----- Settings ----- \KOMAoptions{ paper=a4, % set papersize fontsize=12pt, % set fontsize to 12pt parskip=half, % half a line will seperate paragraphs }

\begin{document} \tableofcontents \pagebreak

\section{Lorem Ipsum} \subsection{align left} \subsection{align right} \subsection{center}

\section{Section} \subsection{sub1} \subsection{sub2}

\end{document}

With produces with pdflatex this output: pdflatex which I think looks fine.

But when I now compile it with xelatex I get this: xelatex

With which I'm fine too, except that in my opinion the boxes produced by hyperref are way too large.

I already read something about boxes and XeTeX (page 25 in the manual), but somehow this is not helping. Does someone know a way arround this or how to reduce the size of the boxes (I only found the parameter to reduce the thickness of the box)?

EDIT: @Ruixi Zhang came up with the workaround of setting the pdflinkmargin (in hypersetup) to a negative value. This works when using only a small negative value (absolute small) then it looks ok (the left/right margin is reduced too by this parameter, so the boxes around links to footnotes are a bit slim), but not nice. So I'd still appreciate suggestions how to make this nice ;)

atticus
  • 557
  • 1
    The hyperlink box is generated by “measuring” its content. For pdfTeX, the height and depth information comes from the traditional TFM (TeX font metric) files. You can see 1.3 center has zero depth, while 1.2 align right descends below the baseline. But for XeTeX, OpenType font is used (so there will be different metric information available). In your output the “bounding boxes” are the same size in height and depth. Presumably, the height is Ascender and the depth is Descender in the OS/2 table. – Ruixi Zhang Jan 03 '21 at 01:40
  • Hm, that makes sense, but is there a way to manually intervene? Because in my opinion this doesn't look that nice... – atticus Jan 03 '21 at 13:39
  • 1
    Maybe this will do the trick: \setlength{\XeTeXLinkMargin}{0pt} or even \setlength{\XeTeXLinkMargin}{-1pt}. Check the hyperref manual for the \XeTeXLinkBox section. – Ruixi Zhang Jan 03 '21 at 14:20
  • No even with -.5cm or -5pt the boxes are still "too large". – atticus Jan 03 '21 at 14:32
  • 1
    Hmmm… Try \hypersetup{pdflinkmargin=-1pt}? This solution comes from https://tex.stackexchange.com/a/488496 (it appears that the size of link box is very driver dependent) But this may produce a link box too small on the left and right… – Ruixi Zhang Jan 03 '21 at 15:18
  • Yes exactly as you thought, when reducing too much, the box gets too small on the left. But I think for now this will be enough to make this look more nice. Nevertheless I'm still interested if there is a possibility to make this even better (only adjust the vertical margin or somehow use a pdflatex like engine for this) – atticus Jan 03 '21 at 18:51
  • 1
    Ask on the dvipdfmx mailing list https://tug.org/mailman/listinfo/dvipdfmx. Perhaps the developer can give some insight how the box is calculated and which options exist to reduce the height. – Ulrike Fischer Jan 10 '21 at 14:57
  • 1
    Haven't looked closely to see if it will be helpful, but see also https://tex.stackexchange.com/a/451037 and the other answers for some theoretical discussion. – ShreevatsaR Jan 13 '21 at 18:56
  • Oh thanks @ShreevatsaR the discussion is interesting. And thanks to @UlrikeFischer, the suggestion with the mailing list works, there is now a new option \AtBeginDvi{\special{dvipdfmx:config g 2pt,-2pt}} that can be used to specify these margins separately – atticus Jan 18 '21 at 21:40

0 Answers0