7

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

TheVal
  • 2,488
Ivan
  • 71
  • 3
    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

2 Answers2

11

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}
Jake
  • 232,450
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.

Delpha
  • 31