TeX - LaTeX Asked on June 20, 2021
I’m using XeLaTeX and fontspec. I want to change the font (to the courier font) that is shown when using url.
I don’t understand why "renewcommandUrlFont{courierfont}" works but "urlstyle{courierfont}" or "urlstyle{Courier}" don’t work. Using courierfont i get the error "!Missing endcsname inserted" and "!Extra endcsname".
output:
MWE:
documentclass[12pt]{article}
usepackage{fontspec}
usepackage{hyperref}
newfontfamily{courierfont}{Courier}
begin{document}
url{https://example.com/example}
urlstyle{courierfont}
url{https://example.com/example}
urlstyle{Courier}
url{https://example.com/example}
renewcommandUrlFont{courierfont}
url{https://example.com/example}
end{document}
There are just a few predefined URL styles. You need to define a new one, if you so want.
The key is to define the macro url@<name>style
that will redefine UrlFont
.
documentclass[12pt]{article}
usepackage{fontspec}
usepackage{hyperref}
newfontfamily{courierfont}{Courier}
makeatletter
newcommand{url@courierstyle}{defUrlFont{courierfont}}
makeatother
begin{document}
url{https://example.com/example}
urlstyle{courier}
url{https://example.com/example}
end{document}
Correct answer by egreg on June 20, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP