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:
which I think looks fine.
But when I now compile it with xelatex I get this:

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 ;)
pdfTeX, the height and depth information comes from the traditional TFM (TeX font metric) files. You can see1.3 centerhas zero depth, while1.2 align rightdescends below the baseline. But forXeTeX, 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 isAscenderand the depth isDescenderin theOS/2table. – Ruixi Zhang Jan 03 '21 at 01:40\setlength{\XeTeXLinkMargin}{0pt}or even\setlength{\XeTeXLinkMargin}{-1pt}. Check thehyperrefmanual for the\XeTeXLinkBoxsection. – Ruixi Zhang Jan 03 '21 at 14:20-.5cmor-5ptthe boxes are still "too large". – atticus Jan 03 '21 at 14:32\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:18pdflatexlike engine for this) – atticus Jan 03 '21 at 18:51\AtBeginDvi{\special{dvipdfmx:config g 2pt,-2pt}}that can be used to specify these margins separately – atticus Jan 18 '21 at 21:40