1

Following on from a question yesterday for which a successful answer was provided (`biblatex` and `\includestandalone` is causing unexpected indents in a `tikzpicture` nodes printed bibliography), a minor issue was encountered where the hanging indent was "off" for the references in the tikzpicture as can be seen in my main document:

actual report

I have reduced the code down to a minimal example to reproduce the issue which can be seen here:

enter image description here

I read from the documentation and the answer provided from the linked question by Ulrike that you can set locallabelwidth=true locally within a \printbibliography[...] options which I have done for the tikzpicture bibliography so the indent is correct in my main bibliography for the numeric-comp style - how can I control the hanging indent within a tikzpicture node so that it doesn't change the indent of my main bibliography please? I am not sure what needs changing to make the indent set. Not using locallabelwidth=true doesn't appear to be an option as it broke the indention of the entire tikzpicture bibliography (from the linked question) but I am not sure how to set the indent properly. My references in the tikzpicture vary from the double and triple digits so manually setting the double digit values would probably break the triple digit indentation.

\documentclass[oneside]{book}

\usepackage{tikz}
\usepackage[backend=biber,style=numeric-comp]{biblatex}
\addbibresource{biblatex-examples.bib}

\DeclareBibliographyCategory{flowchart}
\newcommand\ccite[1]{\cite{#1}\addtocategory{flowchart}{#1}}
\newcounter{num}
\newcommand{\increase}[1]{\setcounter{num}{#1}\addtocounter{num}{+98}\thenum}

\begin{document}
\begin{figure}[t]
\DeclareFieldFormat{labelnumber}{\increase{#1}}
\begin{tikzpicture}
\node at (2,0) {\ccite{baez/article}, \ccite{bertram}};
\node[align=left,text width=20cm] (refmenu) at (15,2) {\textbf{References}};
\node[align=left,text width=20cm] (refs) at (15,1) {\printbibliography[heading=none,category=flowchart,locallabelwidth=true]};
\end{tikzpicture}
\caption{Test figure}
\end{figure}
\end{document}​
3
  • There is a bug in the code for the local label width calculation. In your example the issue is avoided if we set defernumbers=true,, so that could be a workaround, but I'm not sure if that works in your actual document.
    – moewe
    Sep 23 at 9:39
  • Tracked at github.com/plk/biblatex/issues/1306, because I don't know if I can find the proper solution in the next few minutes.
    – moewe
    Sep 23 at 9:44
  • Thank you, I tried defernumbers=true but I prefer the numbering to start at 1 from the first citation, the tikzpicture is an appendix, I can live with the offset indent if needed more pedantic then anything! Thanks for opening an issue :)
    – JamesT
    Sep 23 at 9:52

2 Answers 2

2

The main issue here is that there were slight differences in the setup between the usual label width measuring and label width measuring for locallabelwidth that meant that in this setting all labels were treated as if there were 0. Obviously that does not give good results. The bug report is at https://github.com/plk/biblatex/issues/1306 and the issue should be resolved in the upcoming version of biblatex (3.20 - no ETA so far).

For now you can replicate the fix by putting the bit in between \makeatletter...\makeatother into your preamble. But please remember to remove it once biblatex is updated. This is a highly internal macro and its definition may change at any time.

\documentclass[oneside]{book}

\usepackage{tikz}
\usepackage[backend=biber,style=numeric-comp]{biblatex}
\addbibresource{biblatex-examples.bib}


\DeclareBibliographyCategory{flowchart}
\newcommand\ccite[1]{\cite{#1}\addtocategory{flowchart}{#1}}
\newcounter{num}
\newcommand{\increase}[1]{\setcounter{num}{#1}\addtocounter{num}{+98}\thenum}


\makeatletter
\def\blx@bbl@labelnumber{%
  % Used at endentry, when reading .bbl
  % only do this for the global sorting list otherwise we increment
  % the labelnumbers for each sortlist
  \ifdefempty\abx@field@localnumber
    {}% only if omitnumbers=true
    {\ifundef\abx@field@shorthand
      {\iftoggle{blx@defernumbers}
        % only if defernumbers=true, we have to define localnumber to
        % something to stop labelnumberwidth def complaining on first
        % post-backend run since there will be nothing in the .aux yet
        % for defernums localnumbers. On the second post-backend run,
        % it will have a value correct for generating labelnumberwidth
        % We also have to define a dummy value for labelnumber here for
        % first post-backend runs otherwise references to labelnumber
        % in cite styles like numeric-comp will die.
        {\ifundef\abx@field@localnumber
          {\numdef\abx@field@localnumber{0}%
           \blx@bbl@fielddef{labelnumber}{0}}%
          {}}
        {\csnumgdef{blx@labelnumber@\the\c@refsection}{%
            \csuse{blx@labelnumber@\the\c@refsection}+1}%
          \edef\abx@field@localnumber{%
            \csuse{blx@labelnumber@\the\c@refsection}}%
          \blx@bbl@fieldedef{labelnumber}{\abx@field@localnumber}%
          \blx@bbl@fieldedef{localnumber}{\abx@field@localnumber}}%
        \iftoggle{blx@skipbib}
          {}
          {\blx@bbl@labelnumberwidth@numeric{}}}
      {\csgappto\blx@bbl@data{\let\abx@field@labelnumber\abx@field@shorthand}%
        \iftoggle{blx@skipbib}
          {}
          {\blx@bbl@labelnumberwidth@shorthand{}}}}}
\makeatother

\begin{document}
\begin{figure}[t]
\DeclareFieldFormat{labelnumber}{\increase{#1}}
\begin{tikzpicture}
\node at (2,0) {\ccite{baez/article}, \ccite{bertram}};
\node[align=left,text width=20cm] (refmenu) at (15,2) {\textbf{References}};
\node[align=left,text width=20cm] (refs) at (15,1) {\printbibliography[heading=none,category=flowchart,locallabelwidth=true]};
\end{tikzpicture}
\caption{Test figure}
\end{figure}
\end{document}​

Properly aligned bib entries.

1

I do not understand your values for the text width, e.g. 20cm, and also for the x|y coordinates. However, maybe this is what you want?

\documentclass[oneside]{book}

\usepackage{tikz}
\usepackage[style=numeric-comp]{biblatex}
\addbibresource{biblatex-examples.bib}

\DeclareBibliographyCategory{flowchart}
\newcommand\ccite[1]{\cite{#1}\addtocategory{flowchart}{#1}}
\newcounter{num}
\newcommand{\increase}[1]{\setcounter{num}{#1}\addtocounter{num}{+98}\thenum}

\begin{document}
    \begin{figure}[t]
        \DeclareFieldFormat{labelnumber}{\increase{#1}}
        \begin{tikzpicture}
            \node at (0,-1) {\ccite{baez/article}, \ccite{bertram}};
            \node[align=left,text width=\linewidth] (refmenu) at (0,2.5) {\textbf{References}};
            \node[align=left,text width=\linewidth] (refs) at (0,1) 
            {\printbibliography[heading=none,category=flowchart,locallabelwidth=true]};
        \end{tikzpicture}
        \caption{Test figure}
    \end{figure}
\end{document}​

enter image description here

1
  • +1 thank you for the answer, I picked 20cm just to be arbitrary and make the MWE, the MWE just represented the issue being produced in my main document which wasn't resolved by changing the width to linewidth, thank you though :)
    – JamesT
    Sep 23 at 15:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .