3

I have a figure drawn with pgfplots where I cite a reference in the legend. the issue I have is when I try to scale the whole figure, I noticed that the green hyper link for the reference is not scaled and inserted at the original place.

Here is an ECM with on the one hand the figure in whole size, and on the other hand the figure scaled.

\documentclass{article}
\usepackage{biblatex}
\usepackage{hyperref}
\usepackage{pgfplots}
\pgfplotsset{compat=1.5}
\addbibresource{biblatex-examples.bib}

\begin{document}

\begin{tikzpicture}
    \begin{axis}
    \addplot[red, domain=-3e-3:3e-3, samples=51]{exp(-x^2 / (2e-3^2)) / (1e-3 * sqrt(2*pi))};
    \addlegendentry{Text \cite{aksin}}
    \end{axis}
\end{tikzpicture}
%
\begin{tikzpicture}[scale=0.9]
    \begin{axis}
    \addplot[red, domain=-3e-3:3e-3, samples=51]{exp(-x^2 / (2e-3^2)) / (1e-3 * sqrt(2*pi))};
    \addlegendentry{Text \cite{aksin}}
    \end{axis}
\end{tikzpicture}

\printbibliography

\end{document}

On the linked export, we see that the second green boxed is not over the reference [1], but over the place it would have been if the figure were not scaled.

Is it possible to set the correct location for this box ?

two figures, one scaled

10
  • Related: tex.stackexchange.com/q/87026 (but no working TikZ fix in the answers). Commented 17 hours ago
  • 3
    Instead of scaling, maybe you could directly change the target size of the plot? E.g. \pgfplotsset{width=8cm} i.sstatic.net/Cbi2vuKr.png (this would also ensure a consistent font size instead of mixing them in a ransom letter style) Commented 17 hours ago
  • 2
    @MS-SPO This file is part of biblatex. If you have biblatex installed, you should also have this file. Commented 17 hours ago
  • 1
    @MS-SPO Just to make sure: did you run biber? Does biber give you any errors? Commented 17 hours ago
  • 1
    @MS-SPO Compile with latexmk and don't worry about such details :) Commented 16 hours ago

1 Answer 1

4

Instead of scaling, I would suggest to change the size of the plot, e.g. by setting the width=...

This not only avoids the problem with the hyperlink, but also ensures that the text size of the plot matches the size of the surrounding text.

If you need to reduce the size a lot, you could combine this with selecting a smaller font size, e.g. \footnotesize. Compared to randomly scaling letters, this has the advantage, that latex will choose appropriate glyph shapes, which are easier to read at that size. And sticking to a small pool of font sizes will ensure that your document does not end up looking like a ransom letter with each plot in a different size.

\documentclass{article}
\usepackage{biblatex}
\usepackage{hyperref}
\usepackage{pgfplots}
\pgfplotsset{compat=1.5}
\addbibresource{biblatex-examples.bib}

\begin{document}

\begin{tikzpicture}
    \begin{axis}
    \addplot[red, domain=-3e-3:3e-3, samples=51]{exp(-x^2 / (2e-3^2)) / (1e-3 * sqrt(2*pi))};
    \addlegendentry{Text \cite{aksin}}
    \end{axis}
\end{tikzpicture}

\begin{tikzpicture}
    \begin{axis}[width=8cm]
    \addplot[red, domain=-3e-3:3e-3, samples=51]{exp(-x^2 / (2e-3^2)) / (1e-3 * sqrt(2*pi))};
    \addlegendentry{Text \cite{aksin}}
    \end{axis}
\end{tikzpicture}

\printbibliography

\end{document}

enter image description here

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.