13

I am using Biblatex to handle the full citations in footnotes and the bibliography. With @online Bibtex/Biblatex entries, I understand the DOI and URL fields in a citation need to be in some special font, often typewriter, to distinguish ‘i' and ‘l’, for example. However, the font being different and a little larger than the rest, it looks bold to me and I don’t want the URL to be the first thing you notice in a page of an article. How to make the font smaller?

I found some bits here and there that offer another solution (\urlstyle{rm} or \urlstyle{same}), but it seems to require the url package to be loaded seperately -- I am just using Biblatex.

Update: thanks for the comment and the answer. I forgot to mention that I am using a special format, instead of URL I need "en ligne <>". See the MWE below and correct me if I do this the wrong way. In both situations (\urlstyle{same} or \UrlFont), I still get the prefix "en ligne" printed with that boldish URL font. Or maybe this is yet another font type. How to fix it all at once? I appreciate the \UrlFont method more because it allows me to change the font and the size at the same time. It should also be best to keep a monospace font for URLs and DOIs, too bad they look bold, even when it has been made smaller. Hence \small\rm instead of \small\tt in the following MWE.

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english,ngerman,frenchb]{babel}
\usepackage{csquotes}

\usepackage[style=verbose-trad1,backend=bibtex8]{biblatex}

\DeclareFieldFormat{url}{\addcolon\space\bibstring{en ligne <}\url{#1}\bibstring{>}}

\renewcommand{\UrlFont}{\small\rm}

\addbibresource{biblatex-examples.bib}
\begin{document}
\null\vfill\noindent
\cite{markey}

\cite{kastenholz}

\printbibliography
\end{document}

result

Update 2: Now the icing on the cake (both questions above have been answered), is it possible to make the url and doi font lighter, with some height trick or a color trick (gray or lightgrey)? I appreciate the leo style a lot, especially when you look at the printed result on the page -- I don't have that lighter effect at all when I try it. I can make another post for this if you want.

  • biblatex loads url internally, so \urlstyle{same} works like a charm here. – moewe Dec 23 '13 at 18:21
  • That's what I though but with Texworks (using bibtex8 backend) I get an Undefined control sequence. Same with LyX and bibtex8 although it actually prints the output anyway. With LyX and biber I now got the url un-bolded and no warning.:-) That's what I wanted. However, I am using a specific string instead of 'URL:', \DeclareFieldFormat{url}{\addcolon\space\bibstring{en ligne <}\url{#1}\bibstring{>}} (correct me if I do this in a bad way, I don't know if there is something similar to mkbibparens for <>) and that string (only "en ligne") is still using the weird font! – elge Dec 23 '13 at 18:44
  • 1
    It is generally not thought of as good practice to change the objective of a question after an old version of it has been satisfyingly answered, the preferred way is to ask a follow-up question. – moewe Dec 24 '13 at 10:24
  • The colour problem, however is easily addressed, so I will answer it here. Load a colour package such as \usepackage{xcolor}, and use \DeclareFieldFormat{url}{\bibstring{url}\space\mkbiblege{\textcolor{blue}{\url{#1}}}} or \DeclareFieldFormat{url}{\bibstring{url}\space\textcolor{blue}{\mkbiblege{\url{#1}}}}. – moewe Dec 24 '13 at 10:26
  • ok I remove update 3 and keep it in the comments (if that is what you mean with follow-up) – elge Dec 24 '13 at 11:02
6

I figured my long comments to your updated question were not that good so here goes a thorough explanation.

Your redefinition of the url field format contains two sources of error for biblatex.

\DeclareFieldFormat{url}{\addcolon\space\bibstring{en ligne <}\url{#1}\bibstring{>}}

Firstly, it starts with a command to add a colon and a space before printing any text at all, fortunately biblatex ignores this (there is no unnecessary colon before "en ligne" in your MWE), but we should get rid of it anyway.

Secondly, and more importantly, en ligne < is not actually a bibstring. bibstrings are certain localisation keys that change with the language, so \bibstring{editor} prints "editor" in an English, "Herausgeber" in a German and (apparently) "éditeur" in an French document. In order for this to work biblatex has to know these bibstrings and en ligne < is certainly not one of them (neither is > for that matter; a list of standard bibstrings can be found in the biblatex documentation §4.9.2 Localization Keys). Unknown bibstrings will trigger a warning (Bibliography string 'en ligne <' undefined) and their "key" will be printed in bold to clearly notify you in the document that something went wrong.

To print verbose text in biblatex use \printtext{foo} instead of \bibstring{foo}, but in \DeclareFieldFormat \printtext is not actually needed, so in this case

\DeclareFieldFormat{url}{en ligne <\url{#1}>}

might do what you want.

But you can use biblatex's localisation utilities for this.

\DefineBibliographyStrings{french}{
  url = {en ligne}
}

Will make sure the bibstring url contains "en ligne" in a French document, so \bibstring{url} prints "en ligne" in French and "address" in English.

We can also define a macro \mkbiblege analogous to \mkbibparens to wrap text in < and >.

\makeatletter
\newrobustcmd{\mkbiblege}[1]{%
  \begingroup
  \blx@blxinit
  \blx@setsfcodes
  <#1>
  \endgroup}
\makeatother

So we can define

\DeclareFieldFormat{url}{\bibstring{url}\space\mkbiblege{\url{#1}}}

Finally, our MWE

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english,ngerman,frenchb]{babel}
\usepackage{csquotes}
\usepackage[style=verbose-trad1,backend=bibtex8]{biblatex}

\renewcommand{\UrlFont}{\small\rm}

\DefineBibliographyStrings{french}{
  url = {en ligne},
}
\DefineBibliographyStrings{german}{
  url = {online},
}

\makeatletter
\newrobustcmd{\mkbiblege}[1]{%
  \begingroup
  \blx@blxinit
  \blx@setsfcodes
  <#1>
  \endgroup}
\makeatother

\DeclareFieldFormat{url}{\bibstring{url}\space\mkbiblege{\url{#1}}}
\addbibresource{biblatex-examples.bib}

\begin{document}
  \nocite{markey}
  \printbibliography
\end{document}

gives

enter image description here

  • Thank you @moewe, it works great with \mkbiblege. The simplier method worked with Texworks but for some unknown reason it didn't with LyX (the pdf just doesn't show up and I cannot see logs). Even commented, the printext line prevented it to work, strange. So I stick with mkbiblege. Many thanks:-) Note however that the url font is now back to normal -- the UrlFont doesn't seem to apply anymore. – elge Dec 24 '13 at 9:54
  • 1
    @elge What do you mean by "back to normal"? Andrew Swann's modification really should work here as well. They do in my MWE above at least. What was the outcome when you tried to compile my MWE? – moewe Dec 24 '13 at 10:04
  • I was wrong, I thought the size was back to normal. But when I try with scriptsize I can see the difference. In fact, I was looking at citations in footnotes, maybe that explains it (the footnote font size is already smaller...) – elge Dec 24 '13 at 10:08
10

You can set the \UrlFont including a sizing command:

Sample output

\documentclass{article}

\usepackage{biblatex}
\addbibresource{biblatex-examples.bib}

\renewcommand{\UrlFont}{\small\tt}

\begin{document}

\cite{ctan,markey,kastenholz}

\printbibliography

\end{document}

If you only want this to affect the bibliography, then place the command \renewcommand{\UrlFont}{\small\tt} just before \printbibliography instead of in the preamble.

  • Thank you. There is an issue with the url font size in footnotes specifically, because the font size is already smaller there. When using small, the url font is in fact bigger than the footnotesize text. What's the right way to address this, considering I use full citations in footnotes, which are reported in the final bibliography with a normal font size? – elge Dec 24 '13 at 11:05
  • I asked the question separately – elge Dec 24 '13 at 11:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.