1

I found this great answer. However, I encounter alignment issues with >=10 references.

For example:

enter image description here

Notice how items >= 10 are indented more than those <9. I would like to follow the (default) same alignment for all items.

Following the answer I used:

\documentclass{article}
\usepackage[backend=bibtex,style=numeric,sorting=ydnt]{biblatex}

\begin{filecontents}{library.bib} @article{foo1, author = {Author 1, A.}, title = {Title}, journal = {Journal}, year = {2013}, volume = {13}, pages = {123-234} }

@article{foo2, author = {Author 2, A.}, title = {Title}, journal = {Journal}, year = {2013}, volume = {13}, pages = {123-234} }

@article{foo3, author = {Author 3, A.}, title = {Title}, journal = {Journal}, year = {2013}, volume = {13}, pages = {123-234} }

@article{foo4, author = {Author 4, A.}, title = {Title}, journal = {Journal}, year = {2013}, volume = {13}, pages = {123-234} }

@article{foo5, author = {Author 5, A.}, title = {Title}, journal = {Journal}, year = {2013}, volume = {13}, pages = {123-234} }

@article{foo6, author = {Author 6, A.}, title = {Title}, journal = {Journal}, year = {2013}, volume = {13}, pages = {123-234} }

@article{foo7, author = {Author 7, A.}, title = {Title}, journal = {Journal}, year = {2013}, volume = {13}, pages = {123-234} }

@article{foo8, author = {Author 8, A.}, title = {Title}, journal = {Journal}, year = {2013}, volume = {13}, pages = {123-234} }

@article{foo9, author = {Author 9, A.}, title = {Title}, journal = {Journal}, year = {2013}, volume = {13}, pages = {123-234} }

@article{foo10, author = {Author 10, A.}, title = {Title}, journal = {Journal}, year = {2013}, volume = {13}, pages = {123-234} }

@article{foo11, author = {Author 11, A.}, title = {Title}, journal = {Journal}, year = {2013}, volume = {13}, pages = {123-234} } \end{filecontents}

% Count total number of entries in each refsection \AtDataInput{% \csnumgdef{entrycount:\therefsection}{% \csuse{entrycount:\therefsection}+1}}

% Print the labelnumber as the total number of entries in the % current refsection, minus the actual labelnumber, plus one \DeclareFieldFormat{labelnumber}{\mkbibdesc{#1}} \newrobustcmd*{\mkbibdesc}[1]{% \number\numexpr\csuse{entrycount:\therefsection}+1-#1\relax}

\addbibresource[label=myname]{library.bib}

\begin{document} \begin{refsection}[myname] \nocite{*} \printbibliography[title={My title}] \end{refsection} \end{document}

1 Answers1

4

The problem here is that biblatex needs to measure the width of the numeric labels for correct alignment. This usually happens when an entry is read from the .bbl file. Since the numbering changes depending on the number of entries in the .bbl file, the width measurement obtained at data input is incorrect.

The quickest solution with a modern biblatex is probably to pass the option locallabelwidth to printbibliography. That way the required width measurements are performed locally (for this specific bibliography only) when all the numbering is fixed.

\documentclass{article}
\usepackage[backend=bibtex,style=numeric,sorting=ydnt]{biblatex}

% Count total number of entries in each refsection \AtDataInput{% \csnumgdef{entrycount:\therefsection}{% \csuse{entrycount:\therefsection}+1}}

% Print the labelnumber as the total number of entries in the % current refsection, minus the actual labelnumber, plus one \DeclareFieldFormat{labelnumber}{\mkbibdesc{#1}} \newrobustcmd*{\mkbibdesc}[1]{% \number\numexpr\csuse{entrycount:\therefsection}+1-#1\relax}

\begin{filecontents}{library.bib} @article{foo1, author = {Author 1, A.}, title = {Title}, journal = {Journal}, year = {2013}, volume = {13}, pages = {123-234} } @article{foo2, author = {Author 2, A.}, title = {Title}, journal = {Journal}, year = {2013}, volume = {13}, pages = {123-234} } @article{foo3, author = {Author 3, A.}, title = {Title}, journal = {Journal}, year = {2013}, volume = {13}, pages = {123-234} } @article{foo4, author = {Author 4, A.}, title = {Title}, journal = {Journal}, year = {2013}, volume = {13}, pages = {123-234} } @article{foo5, author = {Author 5, A.}, title = {Title}, journal = {Journal}, year = {2013}, volume = {13}, pages = {123-234} } @article{foo6, author = {Author 6, A.}, title = {Title}, journal = {Journal}, year = {2013}, volume = {13}, pages = {123-234} } @article{foo7, author = {Author 7, A.}, title = {Title}, journal = {Journal}, year = {2013}, volume = {13}, pages = {123-234} } @article{foo8, author = {Author 8, A.}, title = {Title}, journal = {Journal}, year = {2013}, volume = {13}, pages = {123-234} } @article{foo9, author = {Author 9, A.}, title = {Title}, journal = {Journal}, year = {2013}, volume = {13}, pages = {123-234} } @article{foo10, author = {Author 10, A.}, title = {Title}, journal = {Journal}, year = {2013}, volume = {13}, pages = {123-234} } @article{foo11, author = {Author 11, A.}, title = {Title}, journal = {Journal}, year = {2013}, volume = {13}, pages = {123-234} } \end{filecontents} \addbibresource[label=myname]{library.bib}

\begin{document} \begin{refsection}[myname] \nocite{*} \printbibliography[title={My title},locallabelwidth] \end{refsection} \end{document}

Nicely aligned label numbers.

moewe
  • 175,683