1

Consider the following code:

\begin{filecontents}{biblio.bib}
  @article{Key1,
    title = {First title},
    author = {First author},
    shorthand = {ShortHand},
    keywords = {shorthanded}
  }

  @article{Key2,
    title = {Second title},
    author = {Second author}
  }
\end{filecontents}

\documentclass{article}

\usepackage[style=numeric]{biblatex}

\addbibresource{biblio.bib}

\begin{document}

My text cites both \cite{Key1} and \cite{Key2}.

\printbibliography[keyword=shorthanded]

\printbibliography[notkeyword=shorthanded]

\end{document}

Here I print two distinct bibliographies differentiating by keyword, and the first kind of entries happen to be referenced by shorthands (conference names).

As you can see from the output, the large spacing due to the shorthand in the first bibliography is retained when printing the second.

output

This appears nice in the MWE, but in my real document the two bibliographies are printed on separate pages anyway (separate chapters* in a book class), so the vertical alignment is not needed, and the wasted horizontal space in the second one is annoying and useless.

How can I reset the second call to \printbibliography so to independently reserve the right horizontal space for its entries?

  • With multibib package it would be like you want by default. Check this if you don't have too many references and it helps: https://tex.stackexchange.com/a/457454/120578 – koleygr Oct 31 '18 at 19:47
  • Unfortunately I'm specifically using biblatex in many other ways so I need a solution working with it – Nicola Gigante Oct 31 '18 at 19:50

1 Answers1

2

You can use biblatex's option locallabelwidth=true.

I also suggest the use of \printshorthands instead of \printbibliography[keyword=shorthanded]. As a matter of fact, you could well forgo with the need to declare such a keyword altogether. See, for example, this lockstep's answer, incorporated below.

\begin{filecontents}{biblio.bib}
  @article{Key1,
    title = {First title},
    author = {First author},
    shorthand = {ShortHand},
  }

  @article{Key2,
    title = {Second title},
    author = {Second author}
  }
\end{filecontents}

\documentclass{article}

\usepackage[style=numeric,locallabelwidth=true]{biblatex}

% from https://tex.stackexchange.com/a/44436/105447
\defbibcheck{noshorthand}{%
  \iffieldundef{shorthand}{}{\skipentry}%
}

\addbibresource{biblio.bib}

\begin{document}

My text cites both \cite{Key1} and \cite{Key2}.

\printshorthands

\printbibliography[check=noshorthand]

\end{document}

enter image description here

gusbrs
  • 13,740
  • Thanks! I get an error Package xkeyval Error: 'locallabelwidth' undefined in families 'blx@opt@pre'. Do I have an outdated version of the biblatex package? – Nicola Gigante Oct 31 '18 at 19:54
  • That might be the case, which version are you using? (current is 3.11). – gusbrs Oct 31 '18 at 19:57
  • That is indeed a recent inclusion. Revision history for biblatex shows us "Added locallabelwidth option" for version 3.11. – gusbrs Oct 31 '18 at 20:00
  • Do you think there might be a way to hack the same effects in older versions? – Nicola Gigante Oct 31 '18 at 20:19
  • There usually is. labelwidth is among the inputs of defbibenvironment, so you might get a hook to intervene there. But, in this respect, two questions. Is there a reason for not updating? (I respect that, if there is, e.g. deadline approaching, overleaf, whatever). Second, how old? Which version are you acctually using? – gusbrs Oct 31 '18 at 20:23
  • Yes, the reason is the phd thesis deadline approaching in one hour and a half XD I do not know how to get the installed version of the package, honestly, but I'm running MacTeX 2017 – Nicola Gigante Oct 31 '18 at 20:26
  • That is a very good reason. See this answer https://tex.stackexchange.com/a/198780/105447. Btw, would you say marking this as a duplicate of that one is ok? I would've done it before, but I just found it. – gusbrs Oct 31 '18 at 20:29
  • That is actually a workaround, imho. The trick lies in \settowidth{\labelnumberwidth}{8888} which you will have to set manually according to the number of digits your bibliography has. But it certainly gets the job done. – gusbrs Oct 31 '18 at 20:31
  • Great! Very good luck with your thesis then! – gusbrs Oct 31 '18 at 20:59
  • 2
    thanks.. not just for this answer, but I'll greet TeX.SE in the acknowledgements for sure ;) – Nicola Gigante Oct 31 '18 at 21:00