4

The Tilde (~) sign in the URL appears in the superscript position. How can I change it so that it gets the same position (near the normal line) as in the text here?

\documentclass[12pt,twoside]{report}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc} 
\usepackage{hyperref}
\hypersetup{
    bookmarksnumbered=true,
}
\usepackage{kantlipsum} 
\usepackage{biblatex}

\begin{filecontents}[overwrite]{references.bib} @online{pope2021, title = {Lectures on Geometry and Group Theory}, author = {Pope, C.}, date = {2021}, url = {https://people.tamu.edu/~c-pope/geom-group.pdf}, urldate = {2024-03-03}, } \end{filecontents}

\addbibresource{references.bib}

\title{Testing URL in bibliography} \author{Me}

\begin{document}

\chapter{Introduction} \kant[1] \url{https://people.tamu.edu/~c-pope/geom-group.pdf} \cite{pope2021}

\printbibliography[heading=bibintoc, title={References}]

\end{document}

cfr
  • 198,882
raf
  • 633
  • 1
    Off-topic: utf8 has been the default input encoding for all TeX engines for the last half dozen years or so. Unless your TeX distribution is prehistorically ancient, you needn't run \usepackage[utf8]{inputenc}. – Mico Mar 27 '24 at 17:09
  • 1
    You can change the font URLs are displayed in to one which contains a tilde more to your liking. – cfr Mar 27 '24 at 17:15
  • 1
    @Mico I wasn't aware of this utf8 thing. I kept using both \usepackage[utf8]{inputenc} and \usepackage[T1]{fontenc} from some other templates. Also, maybe I checked this answer (https://tex.stackexchange.com/a/44701/114006) as well. Thank you for clarifying it. – raf Mar 27 '24 at 18:33
  • 1
    @raf You still want \usepackage[T1]{fontenc}. I'd assume that's never going to be default. At least, there are excellent reasons it shouldn't be. – cfr Mar 28 '24 at 02:48
  • @cfr I like to know more about it. – raf Mar 28 '24 at 03:02
  • @raf About what? Why you probably want to keep it or why it shouldn't be default? Or something else? – cfr Mar 28 '24 at 03:10
  • @cfr you mean I should keep fontenc here, but it shouldn't be used by default, right? Why shouldn't it be? Can I safely omit both of them if not asked? – raf Mar 28 '24 at 04:01

2 Answers2

4

If you use Latin Modern rather than Computer Modern, you will get the low tilde by default and can keep the T1 encoding. I would use cfr-lm for Latin Modern, but lmodern is sufficient in this case. Latin Modern is based on Computer Modern but was developed later with a wider range of languages in mind.

\documentclass[12pt,twoside]{report}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc} 
\usepackage{lmodern}% I would use cfr-lm
\usepackage{hyperref}
\hypersetup{
    bookmarksnumbered=true,
}
\usepackage{kantlipsum} 
\usepackage{biblatex}

\begin{filecontents}[overwrite]{references.bib} @online{pope2021, title = {Lectures on Geometry and Group Theory}, author = {Pope, C.}, date = {2021}, url = {https://people.tamu.edu/~c-pope/geom-group.pdf}, urldate = {2024-03-03}, } \end{filecontents}

\addbibresource{references.bib}

\title{Testing URL in bibliography} \author{Me}

\begin{document}

\chapter{Introduction} \kant[1] \url{https://people.tamu.edu/~c-pope/geom-group.pdf} \cite{pope2021}

\printbibliography[heading=bibintoc, title={References}]

\end{document}

I'm not going to post an image because my images suck right now due to an Okular/KDE bug.

[But you should do what Mico said and load xurl, whether you stick to Computer Modern or decide to switch to Latin Modern.]

cfr
  • 198,882
  • 2
    +1 for "I would use cfr-lm". :-) – Mico Mar 27 '24 at 17:23
  • 1
    Thank you. I preferred not to load lmodern for this issue: https://tex.stackexchange.com/q/512659/114 – raf Mar 27 '24 at 18:40
  • 1
    @raf Thanks for drawing my attention to fixcmex and the issue it addresses. As that answer points out, Latin Modern is, in many respects, superior to Computer Modern. And as shown there, loading fixcmex fixes the issue and does so in the same way you're fixing it for Computer Modern when loading amsmath. So that's a slightly strange reason not to use LM, if you don't mind my saying so. – cfr Mar 28 '24 at 02:46
  • @cfr I get it your point. Thank you. – raf Mar 28 '24 at 03:03
3

Assuming you're using pdfLaTeX to compile your document and wish to keep using the default font family (which is called "Computer Roman"), one simple fix would consist of not loading the fontenc package with the option T1. However, depending on your document setup, this may cause new, and possibly nastier, problems. A much better choice would be to keep running \usepackage[T1]{fontenc} and to start loading the xurl package with the option lowtilde.

enter image description here

\documentclass[12pt,twoside]{report}
%%%%\usepackage[utf8]{inputenc} % not needed
\usepackage[T1]{fontenc} 
\usepackage[lowtilde]{xurl}
\usepackage[colorlinks,allcolors=blue]{hyperref}

\begin{document} \url{https://people.tamu.edu/~c-pope/geom-group.pdf} \end{document}

Mico
  • 506,678
  • 1
    It might be worth pointing out that option (a) is likely to lead to problems with other characters. I suspect a lot of users get those basic preamble lines from templates/editors etc. without knowing what they are for. – cfr Mar 27 '24 at 17:24
  • 1
    @cfr - I did write that the second option was much better; however, that may still have been too subtle. Let me come up with a more forceful recommendation. :-) – Mico Mar 27 '24 at 17:29
  • 2
    (+1) for xurl which I'd never heard of. Or never registered in my brain, anyway. Think I'm going to be adding it to my standard configurations .... – cfr Mar 27 '24 at 17:32
  • 1
    Thank you. In my main document, I loaded xurl after hyperref and biblatex. In that order, putting the option lowtilde didn't change anything. Seems like I need to load xurl first. Is there any automated way to keep my preamble (packages+setup) in a proper order? – raf Mar 27 '24 at 20:18
  • 1
    @raf - I believe what matters here is loading xurl before biblatex. Unfortunately, I'm not aware of any automated way of successfully sequencing the instructions contained in the preamble. – Mico Mar 27 '24 at 20:30
  • @Mico I just tested loading these 3 packages in the order hyperref, xurl, biblatex. Only putting xurl gives me the desired output. Is it recommended to keep the order xurl, biblatex, hyperref? – raf Mar 27 '24 at 21:03
  • 1
    @raf - I'm afraid I'm not much of an expert on which package loading sequence is best. That said, with few exceptions it's usually best to load hyperref last. (One of the exceptions is the cleveref package, which definitely should be loaded after hyperref.) Regarding the other two packages, I think you've established that xurl should be loaded before biblatex. – Mico Mar 28 '24 at 05:34
  • 1
    @Mico, I get your point. Thank you, – raf Mar 28 '24 at 08:42
  • 1
    Another package in my preamble is bookmark and it also requires to be loaded after hyperref. I came to know here's a dedicated discussion on the ordering conflicts: https://tex.stackexchange.com/q/1863/114006 – raf Mar 28 '24 at 10:18
  • 1
    @raf - There's a reason why I wrote "One of the exceptions". :-) As you've (re)discovered, bookmarks is another exception to the rule... – Mico Mar 28 '24 at 12:16