0

In my original version, the picture was sacaled nicely to the full width of the page. Unfortunatelly, I don't have a screenshot of that. Then I increased radius to 5 (everything fine), decreased it again, an now the picture is too small:

enter image description here

Any hint?

\documentclass[12pt]{article}

\usepackage{fancyhdr}
\usepackage{tikz}
\usepackage[ngerman]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{epstopdf}
\usepackage{mathtools}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{url}
\usepackage[parfill]{parskip}
\usepackage{enumerate}
\usepackage{framed}
\usepackage{xcolor}

\pagestyle{fancy}
\lhead{\textsf{x}}
\rhead{\textsf{x}}
\lfoot{\textsf{\tiny x \LaTeX \ | \today}}

\setlength{\headheight}{15pt} 

\begin{document}

$\blacksquare$ \textbf{x}

\begin{tikzpicture}[>=latex][transform canvas={scale=2.0}]
% Draw the lines at multiples of pi/6
\foreach \ang in {0,...,11} {
  \draw [lightgray] (0,0) -- (\ang*360/12:2.5);
}

% Draw the lines at multiples of pi/4
\foreach \ang in {0,...,7} {
  \draw [lightgray] (0,0) -- (\ang*360/8:2.5);
}

% Concentric circles and radius labels
\foreach \s in {0, 1, 2} {
  \draw [lightgray] (0,0) circle (\s + 0.5);
  \draw (0,0) circle (\s);
  \node [fill=white] at (\s, 0) [below] {\scriptsize $\s$};
}

% Add the labels at multiples of pi/4
\foreach \ang/\lab/\dir in {
  0 /0       /right,
  1 /{\pi/4} /{above right},
  2 /{\pi/2} /above,
  3 /{3\pi/4}/{above left},
  4 /{\pi}   /left,
  5 /{5\pi/4}/{below left},
  7 /{7\pi/4}/{below right},
  6 /{3\pi/2}/below} {
    \node [fill=white] at (\ang*360/8:2.6) [\dir] {\scriptsize $\lab$};
}
% The double-lined circle around the whole diagram
\draw [style=double] (0,0) circle (2.5);
\end{tikzpicture} 

\end{document}

Example from here. Related questions 1 and 2 didn't solve the problem or I missed something.

1

Idea taken from this very nice answer.

\documentclass[12pt]{article}
\usepackage{fancyhdr}
\usepackage{tikz}
\usepackage[ngerman]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{epstopdf}
\usepackage{mathtools}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{url}
\usepackage[parfill]{parskip}
\usepackage{enumerate}
\usepackage{framed}
\usepackage{xcolor}
\pagestyle{fancy}
\lhead{\textsf{x}}
\rhead{\textsf{x}}
\lfoot{\textsf{\tiny x \LaTeX \ | \today}}
\setlength{\headheight}{15pt} 
\makeatletter
\usepackage{environ}
\newsavebox{\measure@tikzpicture}
\NewEnviron{scaletikzpicturetowidth}[1]{%
  \def\tikz@width{#1}%
  \def\tikzscale{1}\begin{lrbox}{\measure@tikzpicture}%
  \BODY
  \end{lrbox}%
  \pgfmathparse{#1/\wd\measure@tikzpicture}%
  \edef\tikzscale{\pgfmathresult}%
  \BODY
}
\makeatother
\usepackage{lipsum}
\begin{document}
\lipsum[1]
\begin{center}
\begin{scaletikzpicturetowidth}{\textwidth}
\begin{tikzpicture}[scale=\tikzscale,>=latex]
\foreach \ang in {0,...,11} {
  \draw [lightgray] (0,0) -- (\ang*360/12:2.5);
}

% Draw the lines at multiples of pi/4
\foreach \ang in {0,...,7} {
  \draw [lightgray] (0,0) -- (\ang*360/8:2.5);
}

% Concentric circles and radius labels
\foreach \s in {0, 1, 2} {
  \draw [lightgray] (0,0) circle (\s + 0.5);
  \draw (0,0) circle (\s);
  \node [fill=white] at (\s, 0) [below] {\scriptsize $\s$};
}

% Add the labels at multiples of pi/4
\foreach \ang/\lab/\dir in {
  0 /0       /right,
  1 /{\pi/4} /{above right},
  2 /{\pi/2} /above,
  3 /{3\pi/4}/{above left},
  4 /{\pi}   /left,
  5 /{5\pi/4}/{below left},
  7 /{7\pi/4}/{below right},
  6 /{3\pi/2}/below} {
    \node [fill=white] at (\ang*360/8:2.6) [\dir] {\scriptsize $\lab$};
}
% The double-lined circle around the whole diagram
\draw [style=double] (0,0) circle (2.5);
\end{tikzpicture}
\end{scaletikzpicturetowidth}
\end{center}
\end{document}

enter image description here

  • Do you understand, why it worked in a first place? Really a pitty, that it changed ;-) – Christoph Mar 28 at 14:47
  • @Christoph What do you mean by "first place" and "it changed"? – user156344 Mar 28 at 14:48
  • As I tried to explain: It scaled nicely, but after increasing - decreasing the radius, the scaling didn't work anymore. (The fist picture I had looked similar to yours!). – Christoph Mar 28 at 14:52
  • 1
    @Christoph Could you add your (not working) code to your question? I can't reproduce the problem. – user156344 Mar 28 at 14:54
  • Strange, the code in my example above still reproduces the picture. I just tried it again with the same result! The width is less than half the available space... – Christoph Mar 28 at 16:12

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.