TeX - LaTeX Asked by Tuomo Sipola on April 25, 2021
Question: How to use fontspec
fonts so that hyperref
boxes are well formed and not too high?
Solved: I don’t know why but adding Extension=.ttf
inside setmainfont
options solves this.
What I expected: To use different fonts like Junicode with XeLaTeX using the fontspec
package in a document that has hyperref
links.
What I got: Link boxes are too high above the glyphs, as seen in the figure below. I have tested with Junicode and Cardo.
This is especially annoying when the boxes are not even visible in any sensibly typeset document (try uncommenting the colorlinks
line in the MWE).
As a reference, below is a figure where everything works nicely with the default Computer Modern font. Also, TeX Gyre Pagella and TeX Gyre Termes seem to work.
It seems that the fonts Junicode and Cardo themselves are the cause of this but is there some way to sidestep the issue?
MWE:
% To compile and experience the problem: xelatex file.tex
documentclass{book}
usepackage{fontspec}
setmainfont[
Mapping=tex-text,
Extension=.ttf %%% THIS LINE SOLVED THE PROBLEM
]{Junicode}
usepackage[xetex]{hyperref}%
urlstyle{rm}%
%%% You can try uncommenting the `colorlinks` option to experience how
%%% uncomfortable it is to try to click those invisible boxes that have
%%% wrong dimensions.
hypersetup{%
xetex,%
%colorlinks=true%
}
begin{document}
Test link: href{https://creativecommons.org/licenses/by-sa/4.0/}{CC BY-SA}
Curiously italics work: href{https://creativecommons.org/licenses/by-sa/4.0/}{textit{CC BY-SA}}
test some more href{https://www.google.com}{MakeLowercase{Google}} and more
Finnish newspaper! href{https://www.hs.fi/}{Helsingin Sanomat}
end{document}
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP