# How to print \url the right way: Wrong font used for no reason, line breaks getting lost

I have added links in my text by using \url and so have I in my bib: @Misc and then using \howpublished, there inside I use \url, too. I have done this before, but my problem is that neither in my text nor in the bibliography my links appear the "normal" or "right" way.

They are printed in the font style the rest of the text uses and not Courier New. If I use things like \urlstyle{tt}, it changes the font but the lines are getting too long. There are no line breaks any more. \usepackage[hyphens]{url} does not help, too.

Do you have an idea to print my urls in Courier New and having line breaks? Otherwise, especially in the bibliography, there are lines that should stop at https://tex.stackexchange.com/ or at https://tex.stackexchange, but stop at https://tex.stackexchange.com/questions/ and "ask" is printed to the next line.

\documentclass[fontsize=12pt,oneside,headsepline]{scrbook}
\usepackage[ngerman]{babel}
\usepackage{blindtext}
\usepackage{graphicx}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{microtype}
\usepackage[onehalfspacing]{setspace} %h
\usepackage[urlcolor = black,plainpages=false,pdfpagelabels=true,
bookmarksopen=true]{hyperref}

\usepackage[style=apa,natbib=true,backend=biber,uniquename=false,
pagetracker=true,sortcites=true,sorting=nyt,backref=true,
hyperref=true]{biblatex}

\DeclareLanguageMapping{german}{german-apa}
\DeclareFieldFormat{apacase}{#1}
\DefineBibliographyStrings{ngerman}{
andothers = {{et al\adddot}},  }

\usepackage{parskip}
\usepackage[german]{algorithm2e}
\usepackage{tabularx}
\usepackage{longtable}
\usepackage{tablefootnote}
\usepackage{lmodern}
\usepackage{subfigure}
\usepackage{comment}
\usepackage{placeins}
\usepackage{scrpage2}
\usepackage{nccmath}
\usepackage{tikz}
\usepackage{amsthm}
\newtheoremstyle{break}
{8pt}{}%
{\itshape}{}%
{\bfseries}{}%  % Note that final punctuation is omitted.
{\newline}{}
\theoremstyle{break}
\newtheorem{mydef}{Definition}[chapter]

\usepackage{tikz} % Für Zeichnungen mit dem tikz-Package

\usepackage{tablefootnote}

\usepackage[all]{nowidow}
\makeatletter
\@removefromreset{footnote}{chapter}
\@removefromreset{footnote}{part}
\makeatother

\begin{document}


EDIT:

bib:

@Misc{dictcc2016,
author       = {{dict.cc}},
title        = {{supervised}},
year         = {2016},
howpublished = {\url{https://www.dict.cc/?s=supervised}},
note         = {Accessed 24.11.2016},
}

\begin{document}

\end{document}


Using the bib entry above as well as the url in the document looks regarding the font style like this, at the moment.

For avoiding confusion, I did try various ways like using \urlstyle{tt} and so on, but it did not work so I deleted them again.

• do you really want Courier for the urls if the rest of the document is using latin modern (rather than latin modern monospace as used by \texttt)? As you haven't posted a usable example it is rather hard to guess how the urls are finally looking, or what to change. It would help if you could fix the example, deleting all packages not involved in this issue and adding a small test bibliography that is included by a small complete document. Jan 11 '17 at 13:15
• Unitl now, urls just look the same as the rest of the text does, so it is not easy to distinguish them from the rest. As I am open to any solution, what would you recommend? Is it not important to present URLs that look a bit different from the rest of my text? Jan 11 '17 at 13:24
• as I say it is hard to see what your urls are doing as the above example is (a) large and (b) generates no output. But using Courier font alongside latin modern would look rather horrible, I was asking if you just intended to mean monospace like \texttt (you do not load courier at all in he above as far as I can see) you have specified that links are coloured in hyperref so do you really need a font change as well? Jan 11 '17 at 13:31
• No I get it. I thought, that the mono space and courier new are the same. I read that mono space is default, but it isn't in my code for some reason. The links are not coloured any more when opening with an external editor Jan 11 '17 at 13:45
• please make a small example that shows the problem Jan 11 '17 at 13:47

Apparently, there's some declaration in biblatex that changes the URL style to rm.

Add \urlstyle{tt}. I reformatted your preamble, but

1. parskip should not be used with KoMa-script classes
2. subfigure has been deprecated for several years

Here's the complete file, where I used filecontents* just for making the example self-contained.

\begin{filecontents*}{\jobname.bib}
@Misc{dictcc2016,
author       = {{dict.cc}},
title        = {{supervised}},
year         = {2016},
howpublished = {\url{https://www.dict.cc/?s=supervised}},
note         = {Accessed 24.11.2016},
}
\end{filecontents*}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}
\usepackage{microtype}

\usepackage[onehalfspacing]{setspace} %h

\usepackage{blindtext}
\usepackage{graphicx}
\usepackage{url}
\usepackage[style=apa,natbib=true,backend=biber,uniquename=false,
pagetracker=true,sortcites=true,sorting=nyt,backref=true,
hyperref=true]{biblatex}
\usepackage{parskip}
\usepackage[german]{algorithm2e}
\usepackage{tabularx}
\usepackage{longtable}
\usepackage{tablefootnote}
\usepackage{lmodern}
\usepackage{subfigure}
\usepackage{comment}
\usepackage{placeins}
\usepackage{scrpage2}
\usepackage{nccmath}
\usepackage{tikz}
\usepackage{amsthm}

\usepackage{tablefootnote}
\usepackage[all]{nowidow}

\usepackage[urlcolor = black,plainpages=false,pdfpagelabels=true,
bookmarksopen=true]{hyperref}

\DeclareLanguageMapping{german}{german-apa}
\DeclareFieldFormat{apacase}{#1}
\DefineBibliographyStrings{ngerman}{
andothers = {{et al\adddot}},  }

\newtheoremstyle{break}
{8pt}{}%
{\itshape}{}%
{\bfseries}{}%  % Note that final punctuation is omitted.
{\newline}{}
\theoremstyle{break}
\newtheorem{mydef}{Definition}[chapter]

\makeatletter
\@removefromreset{footnote}{chapter}
\@removefromreset{footnote}{part}
\makeatother
\urlstyle{tt}

\begin{document}

\cite{dictcc2016}

\printbibliography

\end{document}


• Indeed apa.bbx has \urlstyle{rm} % APA examples all have URLs in same font as text. Feb 13 '17 at 17:02
• Now, when I use APA-style and a citation in the caption of a figure, there is a problem with the authors: Usually, after having citet something for the first time and there are more than 2 authors, only Mayer et al. appears in the text. This still works, but not for captions of figures. So there now appear a lot of names now. Do you know something about this issue? Thank you very much so far!:) Feb 28 '17 at 10:02
• @junkmaster Please ask a new question with example code Feb 28 '17 at 10:30

choose a monospace font:

\documentclass{scrbook}
\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[scaled=0.83]{beramono}
\usepackage{microtype}
\usepackage[hyphens]{url}
\usepackage{graphicx}
\begin{document}

foo
\url{http://tex.stackexchange.com/questions/348140/how-to-print-url-the-right-way-wrong-font-used-for-no-reason-line-breaks-gett}

\end{document}

• Thank you for your answer. Sadly, it did not help. What I found out is that it has to do something with biblatex as in: \usepackage[style=apa,natbib=true,backend=biber,uniquename=false,pagetracker=true,url=true]{biblatex} Jan 12 '17 at 13:19