3

In some circumstances it is very nice to have a bibliography text typeset with protrusion enabled, especially when one uses a bibliography style in which a lot of lines begin with italics. However, the left side of a typical biblatex-generated bibliography doesn't protrude. MWE:

\documentclass[12pt]{article}
\usepackage[style=authoryear]{biblatex}
\usepackage[factor=6000]{microtype}
\usepackage{showframe}
\renewcommand*\ShowFrameLinethickness{.25pt}
\renewcommand*\ShowFrameColor{\color{green}}
\begin{filecontents}{\jobname.bib}
@BOOK{book1,
    AUTHOR = {\char"200B Author, A.},
    TITLE = {Title},
    LOCATION = {Location},
    YEAR = {2017}}
@BOOK{book2,
    AUTHOR = {Author, B.},
    TITLE = {Title},
    LOCATION = {Location},
    YEAR = {2017}}
\end{filecontents}
\addbibresource{\jobname.bib}
\renewcommand{\section}[2]{}
\begin{document}
\noindent Author\par
\nocite{book1,book2}
\printbibliography
\end{document}

which gives:

enter image description here

A quick look at the biblatex.sty reveals that \def\blx@bibitem on line 7746, using the default bibenvironment

\defbibenvironment{bibliography}
  {\list{}{%
     \leftmargin\bibhang
     \itemindent-\leftmargin
     \itemsep\bibitemsep
     \parsep\bibparsep}}
  {\endlist}
  {\item}

creates a \list and places an \item at the beginning of every line. Of course, any character after \item will not protrude to the left.

The pdfTeX manual (p. 34) states:

If you want to protrude some item other than a character (e.g. a \hbox ), you can do so by padding the item with an invisible zero--width character, for which protrusion is activated.

However, I don't want to protrude \items, but all characters differently according to their respective protrusion values.

So, I would be very grateful for any real workaround.

  • 1
    See here tex.stackexchange.com/a/13711/2388. While it would be imho possible to insert this code in the list, it is problematic (with pdflatex) when the author name begins with some non-ascii. The other idea would be to not to use a list in the bibliography. – Ulrike Fischer Aug 4 '17 at 19:22
  • @UlrikeFischer: ... as for the idea not to use list in the bibliography, I'm afraid I lack the knowledge to rewrite standard bibenvironments (e.g. bibliography, shorthand) without being sure I didn't break anything in the complicated biblatex's formation of item lines. And I can't find on SX or elsewhere any attempt to do something like that... :( – Aleksandar Zec Aug 5 '17 at 2:09
  • @UlrikeFischer: as for \protrudeleft -- it's very interesting. I'm trying to insert the code into \def\blx@bibitem#1, but first experiments show that it won't be that simple, because \protrudeleft needs an argument (i.e. it can't be used in a hooks such as \AtEveryBibitem). As for your remark about pdflatex and non-ascii characters -- I need them. Will the code behave differently with xelatex or lualatex? – Aleksandar Zec Aug 5 '17 at 2:47
  • 1
    Note that the bibliography is not alone: if you have headings on the left, you'll see the same thing. (This can be patched pretty easily for some classes, if you aren't using anything weird.) And, of course, all the other lists in your document .... – cfr Aug 5 '17 at 3:55
  • @cfr: Yes, I realized that... \protrudeleft would be from @Ulrike's first comment would be the perfect solution for such simpler cases, but it doesn't work for non-ascii characters. AFAIU, the perfect solution for all these cases would be what was mentioned in Ulrike's comment to this post: tex.stackexchange.com/a/13711/123303 ("pdftex really needs a primitive to simulate line beginnings/ends"). The link with the feature request is broken. Do you know anything about this? Any attempt to bring it to life? – Aleksandar Zec Aug 5 '17 at 17:22
3

As mentioned in my comment one can get correct protrusion after an \item with the \protrudeleft command describe in Microtype and quote environment leads to different indent of first line.

But it is rather difficult to use this in an automatic environment like the bibliography. At first the command needs at least the first char as argument, so with pdflatex and utf8 something like \protrudeleft Ä won't work as if would use only the first half of the Ä as argument, one need braces \protrudeleft{Ä} -- with lualatex or xelatex it would be easier, but even there one can't be sure that the first input token is really a char. But beside this: biblatex is doing so many things at the begin of an entry that it is very difficult (or even impossible) to inject such a low level command.

An more easier alternative is to try to avoid the use of a list for the bibliography. This works quite ok (the indent of the T from Title is due to the large microtype settings):

\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[style=authoryear]{biblatex}
\usepackage[factor=6000]{microtype}
\usepackage{showframe,xpatch}
\renewcommand*\ShowFrameLinethickness{.25pt}
\renewcommand*\ShowFrameColor{\color{green}}

\addbibresource{test.bib}
\renewcommand{\section}[2]{}


\defbibenvironment{bibliography}
  {\parindent=0pt 
   \bibitemsep=1ex
   \endgraf}
  {\endgraf}
  {\endgraf\vspace{\bibitemsep} \hangindent=\bibhang \hangafter=1}

\xapptocmd\finentrypunct{\par}{}{\fail} %the paragraph musst be closed before the \endgroup
\textwidth=3cm  
\begin{document}

\noindent Author\par
\noindent Äuthor\par

\nocite{book1,book2}

\printbibliography
\end{document}

enter image description here

  • thank you, this is amazing, and it works perfectly for all bibliography styles I use. The only thing I changed is \parskip=\bibitemsep (in the first argument) instead of \vspace{\bibitemsep} (in the last), in order to avoid an extra vertical space at the bottom of the page. Just out of curiosity: is there any special reason to use \endgraf instead of \par? – Aleksandar Zec Aug 5 '17 at 17:16
  • 1
    \par gives an error. Try it out. – Ulrike Fischer Aug 5 '17 at 17:20
  • I noticed that \par gives an error when I unsuccessfully tried to rewrite that bibenvironment myself, but I blamed my clumsiness and didn't tried it with your code. :) Indeed, it fails. Very interesting. So I have a good homework to understand why (well, as always after reading your solutions), because I didn't know for \endgraf... – Aleksandar Zec Aug 5 '17 at 17:33

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.