# fontspec changes indentation of biblatex bibliography

MWE:

test.tex:

% !TeX program = xelatex
\documentclass[paper=A4,fontsize=12pt]{scrartcl}
\usepackage{fontspec}
\usepackage[backend=biber,style=authoryear,citestyle=authoryear]{biblatex}
\begin{document}
\cite{Test.2018}
\printbibliography
\end{document}


resources.bib:

@misc{Test.2018,
author = {{Test}},
year = {2018},
title = {Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.}
}


Adding \usepackage{fontspec} decreases the indentation of the biblatex entries in the bibliography, removing it increases it again. Why?

I came across this problem after trying to break a long url in the bibliography of an article. The decreased indentation changes the breakpoint. Furthermore it makes the url overflow by one stubborn character even though I set biburllcpenalty and biburlucpenalty accordingly. Without using fontspec there is no overflow.

Probably someone who knows KOMA-Script better may be able to give a more precise answer. But, as far as I was able to understand, this behavior hangs on how scrartcl class handles \parindent which is, in turn, used by biblatex to set the bibliography hanging indent.

biblatex uses the length \bibhang on the bibenvironment of the authoryear style. And it is set in biblatex.def with:

\setlength{\bibhang}{\ifnumequal{\parindent}{0}{1em}{\parindent}}


Which will set \bibhang to \parindent but default \bibhang to 1em if \parindent is 0 for some reason, which is not the case here (that is \parindent is not 0, so \bibhang actually receives \parindent).

Now if we build the document below with XeLaTeX:

\documentclass[paper=A4,fontsize=12pt]{scrartcl}

\typeout{\the\parindent}

\begin{document}

\the\parindent

\end{document}


The PDF will print "12.0pt", but we will find "20.0pt" in the log.

This means that, for some reason, \parindent is 20pt in the preamble, and 12pt in the document. biblatex sets \bibhang in the preamble, thus, in the absence of other intervening packages, takes the value of 20pt.

Now, if we add fontspec to the document:

\documentclass[paper=A4,fontsize=12pt]{scrartcl}

\usepackage{fontspec}

\typeout{\the\parindent}

\begin{document}

\the\parindent

\end{document}


We will find "12pt" in both the document and the log. So, if biblatex is called after fontspec, it will receive now the value of 12pt.

This doesn't really mean that fontspec is responsible for this setting on it's own. As far as I grasp, it is more likely bringing some KOMA hook anticipating the setting which would otherwise come "at begin document". For example, if we substitute the call to fontspec with KOMA's \recalctypearea, we get the same result: 12pt in both the document and the log.

\documentclass[paper=A4,fontsize=12pt]{scrartcl}

\recalctypearea

\typeout{\the\parindent}

\begin{document}

\the\parindent

\end{document}


This explains why, in scrartcl class, if you load biblatex after fontspec you get different \bibhangs. But I cannot really explain why \parindent works the way it does in scrartcl.

Still, as you probably want fontspec anyway in your document, this discussion is more of a curiosity. You woudn't want to remove fontspec just because, by sheer chance (yes, a change in \bibhang may trigger an overfull hbox in you url) it allows for a better line break in a single bib entry. So you'll have to look for some other form to break your entry's url (there are several answers in this site on this subject).

• +1. A very thorough analysis! – Mico Dec 16 '18 at 6:23
• If biblatex uses parindent in the preamble it is a biblatex error. Packages shouldn't expect font dependant values to be correct there. – Ulrike Fischer Dec 16 '18 at 9:30
• – moewe Dec 16 '18 at 10:16
• @UlrikeFischer See link above. Is there any way to delay the expansion here? I don't want to set the \bibhang in the preamble to avoid having to have the user go through \AtBeginDocument hooks. – moewe Dec 16 '18 at 10:23
• @YoungUn Some, in no particular order, and non exhaustive: tex.stackexchange.com/q/372003/105447 ; tex.stackexchange.com/q/115690/105447 ; tex.stackexchange.com/q/15653/105447 ; tex.stackexchange.com/q/78093/105447 . If those, or other you may find, do not help, I suggest you ask a new question, then adding the example you later added. Here I focused on your question, as initially posed. – gusbrs Dec 16 '18 at 17:52