3

When I use \begin{tikzpicture}[scale=X] with X<1/X>1 then font size of text in the picture is also changed. I need to use [scale=2] or [scale=0.5] and to preserve font size (e.g. normalsize).

\documentclass[a4paper]{article}

\usepackage{tikz} 
\usepackage{pgfplots}
\tikzset{every picture/.append style={font=\normalsize}}

\begin{document}
 Short text with normal size font.

 \begin{tikzpicture}[scale=2, font=\normalsize]
  \begin{axis}
   [
    ymin=0,ymax=12,xmin=0,xmax=3,
    ylabel={frequency},xlabel={group},
    xtick=data,xticklabels={A,B},
    ytick={0,10},
   ]

   \addplot plot coordinates
   {
    (1,10)
    (2,6)
   };
  \end{axis}
 \end{tikzpicture}

  Another short text with normal size font.

 \begin{tikzpicture}[scale=0.5, font=\normalsize]
  \begin{axis}
   [
    ymin=0,ymax=12,xmin=0,xmax=3,
    ylabel={frequency},xlabel={group},
    xtick=data,xticklabels={A,B},
    ytick={0,10},
   ]

   \addplot plot coordinates
   {
    (1,10)
    (2,6)
   };
  \end{axis}
 \end{tikzpicture}

 \end{document}

and here is result from my TeXstudio 2.6.0 under Win7

  • 2
    If your tikzpicture only contains a PGFPlots axis, you can move the scale=2 to the axis options: That way, the font sizes aren't affected. – Jake Sep 20 '13 at 18:00
  • Thank you, it seems to be very simple solution. It is strange that I found out only opposite problem = how to change by "scale" also font size. – Ivan Sep 20 '13 at 22:45
8

If your tikzpicture only contains a PGFPlots axis, you can move the scale=2 to the axis options: that way, the font sizes aren't affected.

\documentclass[a4paper]{article}

\usepackage{tikz} 
\usepackage{pgfplots}
\tikzset{every picture/.append style={font=\normalsize}}

\begin{document}
 Short text with normal size font.

 \begin{tikzpicture}
  \begin{axis}
   [
    scale=2,
    ymin=0,ymax=12,xmin=0,xmax=3,
    ylabel={frequency},xlabel={group},
    xtick=data,xticklabels={A,B},
    ytick={0,10},
   ]

   \addplot plot coordinates
   {
    (1,10)
    (2,6)
   };
  \end{axis}
 \end{tikzpicture}

  Another short text with normal size font.

 \begin{tikzpicture}
  \begin{axis}
   [
    ymin=0,ymax=12,xmin=0,xmax=3,
    ylabel={frequency},xlabel={group},
    xtick=data,xticklabels={A,B},
    ytick={0,10},
    scale=0.5
   ]

   \addplot plot coordinates
   {
    (1,10)
    (2,6)
   };
  \end{axis}
 \end{tikzpicture}

 \end{document}
2

Following the idea of this thread, you can set this property when using \input{} in case you generate your figure in an externate file. The following did the trick for me :

\begingroup
\pgfplotsset{every axis/.style={scale=2}}
\input{tikzfig}
\endgroup

Using :

\tikzset{every axis/.style={scale=2}}

would also be possible but generates a warning.

  • 1
    Welcome to TeX.SE! – Mensch Jul 16 at 8:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.