Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

For dvisvgm backend, position tracking gets broken in the bibliography #1115

Open
nathanael-naeri opened this issue Dec 19, 2021 · 2 comments

Comments

@nathanael-naeri
Copy link

Brief outline of the bug

I am preparing a fairly complex diagram where some nodes contain bibliographic citations. The bibliography itself is printed in another node. This works perfectly with the pdflatex and dvips backend drivers, but fails with the dvisvgm driver, which is the one I'd like to use. The bibliographic references are not printed next to their labels ([1], [2]...) in the bibliography, but away from them.

Using PGF 3.1.9a in TeXLive 2021. Not sure if this should be reported against PGF or dvisvgm, but I also wouldn't know where to report against dvisvgm.

I hope you can help, thank you very much in advance!

Minimal working example (MWE)

To compile to SVG:

  1. latex mwe.tex
  2. biber mwe.bcf to create mwe.bbl from mwe.bib
  3. latex mwe.tex twice
  4. dvisvgm --bbox=papersize --no-fonts mwe.dvi to create mwe.svg, with --no-fonts to replace fonts by plain graphics path so that the file can be viewed with external renderers that don't support embedded fonts

To compile to PDF, remove class option dvisvgm and use pdflatex and biber.

LaTeX file mwe.tex:

\documentclass[dvisvgm,tikz]{standalone}

% For references and citations
\usepackage{biblatex}
\addbibresource{mwe.bib}

% For multipart nodes
\usetikzlibrary{shapes.multipart}

% For placing nodes relative to other nodes
\usetikzlibrary{positioning}

% The picture
\begin{document}
\begin{tikzpicture}

% Diagram
\begin{scope}[
  every node/.style={
    draw,rounded corners,
    rectangle split,
    rectangle split parts=3,
    rectangle split ignore empty parts=true,
    rectangle split part fill={pink,pink,yellow},
    text width=4cm,
    align=center,font=\bfseries},
  every two node part/.style={
    align=left,font=\mdseries},
  every three node part/.style={
    align=left,font=\mdseries}]

  \node (1)
    {Step 1
      \nodepart{two}
      Description here \cite{ref1}
      \nodepart{three}
      Additional comment here};

  \node (2) [below=of 1]
    {Step 2
      \nodepart{two}
      Description here \cite{ref2}}
    edge [<-] (1);

\end{scope}

% References
\node (bib) [below=of 2]
  [draw,rounded corners,text width=6cm]
  {% Bibliography without its usual section-like heading
   \printbibliography[heading=none]
   % Note: the vertical space before the bibliography normally separates
   % the bibliography from its heading, when the heading is printed. It
   % can be canceled by redefining \bibsetup to \vspace{-\baselineskip}.
   % I am leaving this trick out of this MWE.
   };

\end{tikzpicture}
\end{document}

BibTeX file mwe.bib:

@report{ref1,
  title={Title 1},
}

@report{ref2,
  title={Title 2},
}

Resulting SVG file, showing problem:

mwe-svg

Resulting PDF file, showing expected behavior:

mwe-pdf

Also, bibliography file mwe.bbl output by Biber from mwe.bib (my understanding is that it is \input-ed by \printbibliography):

% $ biblatex auxiliary file $
% $ biblatex bbl format version 3.1 $
% Do not modify the above lines!
%
% This is an auxiliary file used by the 'biblatex' package.
% This file may safely be deleted. It will be recreated by
% biber as required.
%
\begingroup
\makeatletter
\@ifundefined{[email protected]}
  {\@latex@error
     {Missing 'biblatex' package}
     {The bibliography requires the 'biblatex' package.}
      \aftergroup\endinput}
  {}
\endgroup


\refsection{0}
  \datalist[entry]{nty/global//global/global}
    \entry{ref1}{report}{}
      \field{sortinit}{T}
      \field{sortinithash}{9af77f0292593c26bde9a56e688eaee9}
      \field{labeltitlesource}{title}
      \field{title}{Title 1}
    \endentry
    \entry{ref2}{report}{}
      \field{sortinit}{T}
      \field{sortinithash}{9af77f0292593c26bde9a56e688eaee9}
      \field{labeltitlesource}{title}
      \field{title}{Title 2}
    \endentry
  \enddatalist
\endrefsection
\endinput
@hmenke
Copy link
Member

hmenke commented Dec 19, 2021

Can you please try the “fix“ from #1109? I have the feeling that this is a duplicate.

@nathanael-naeri
Copy link
Author

Yay, it works! Thanks. Adding the following commands to the preamble results in the bibliographic text being printed where it should:

\makeatletter
\def\pgfsys@text@to@black@hook{}
\makeatother

I had noticed issue #1109 of course but didn't even think that the "fix" could work, as it appears to be related to text colors, which I'm not using.

Please feel free to close. Hopefully the "fix" can be merged upstream, if it doesn't break anything elsewhere.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants