Experimenting, it would appear that during the tikzpicture, \baselinestretch should be equal to whatever it was when the \begin{document} command was issued. Moreover, it should not be long (no matter what \baselinestretch was at the start) - this is an issue with the article.cls since that contains the line \renewcommand{\baselinestretch}{} which makes it \long, whereas latex.ltx simply contains \def\baselinestretch{1} so is not \long. The fact that article.cls makes it long is irrelevant by the time one gets into the document since \selectfont has implicitly made it not long again.
So until the bug is squished, here's a work-around. I've tested it with various combinations of setting \baselinestretch with and without \long and it seems to survive them all, but as I don't really understand what's going on here I can't be held responsible for any damage caused by this strange behaviour.
\documentclass[12pt]{article}
\usepackage{tikz}
\AtBeginDocument{\let\tikzbaselinestretch\baselinestretch}
\tikzset{every picture/.append style={
execute at begin picture={%
\edef\baselinestretch{\tikzbaselinestretch}%
}
}
}
\begin{document}
\begin{tikzpicture}[scale = 2]
\draw[very thick] (2,-0.2)+(30:1cm) arc (30:150:1cm);
\end{tikzpicture}
\renewcommand{\baselinestretch}{2}
\begin{tikzpicture}[scale = 2]
\draw[very thick] (2,-0.2)+(30:1cm) arc (30:150:1cm);
\end{tikzpicture}
\end{document}
(Method incorporates suggestions from Jake, and experiments based on Altermundus' answer.)
Absolutely definitely a bug. But it's deep.
The bug is actually in \pgfmathsetlength. Quoting from the code:
Furthermore, the font is setup before the assignment is
done, so that dimensions like 1em are evaluated correctly.
So within \pgfmathsetlength is a call to \pgfmath@selectfont. This is an alias of \selectfont (as we're using LaTeX) which calls \set@fontsize if \baselinestretch is not what it was the last time that \set@fontsize was called[1]. Then \set@fontsize executes \@defaultunits\@tempdimb#2pt\relax\@nnil. The upshot of is that if \baselinestretch has changed by some means other than a call to \set@fontsize then sometime in \pgfmathsetlength, \@tempdimb will get reassigned to something.
This, as Altermundus' hints at, causes problems for \pgfpatharc. Within that code is a call to \pgfpointpolar{\pgf@arc@angle}{\pgfutil@tempdima and \pgfutil@tempdimb}. In processing this, PGF calls \pgfmathsetlength but it does so before looking at the \pgfutil@tempdima and \pgfutil@tempdimb part. So before we look at it, \pgfutil@tempdimb gets reassigned and we've forgotten what it originally was.
So the problem is that \pgfutil@tempdimb (which is an alias for @tempdimb) gets set to a new value before it is used. Exactly how to fix this properly, I'll leave to the PGF team! A simple solution would be that after loading TikZ (or PGF) one puts:
\makeatletter
\newdimen\pgfutil@tempdimb
\makeatother
This separates the link between \pgfutil@tempdimb and \@tempdimb at the expense of using up a dimen register. An alternative would be to hack \set@fontsize so that the assignment to \@tempdimb occurred in a group. Taking a leaf out of TikZ/PGF's many smuggling routines, we could do:
\def\set@fontsize#1#2#3{%
\bgroup
\@defaultunits\@tempdimb#2pt\relax\@nnil
\edef\@smuggle{{\edef\noexpand\f@size{\strip@pt\@tempdimb}}}%
\expandafter\aftergroup\@smuggle
\egroup
\@defaultunits\@tempskipa#3pt\relax\@nnil
\edef\f@baselineskip{\the\@tempskipa}%
\edef\f@linespread{#1}%
\let\baselinestretch\f@linespread
\def\size@update{%
\baselineskip\f@baselineskip\relax
\baselineskip\f@linespread\baselineskip
\normalbaselineskip\baselineskip
\setbox\strutbox\hbox{%
\vrule\@height.7\baselineskip
\@depth.3\baselineskip
\@width\z@}%
\let\size@update\relax}%
}
(I think that works without making any extra global assignments, but I'm no expert.)
[1] In slightly longer form, \set@fontsize saves the current value of \baselinestretch as a macro, \f@linespread (which is not \long), and then \lets \baselinestretch to this macro. So after calling \set@fontsize then \baselinestretch and \f@linespread are guaranteed to be the same. If someone interferes with \baselinestretch in the meantime, even just to \renewcommand\baselinestretch{whatever it currently is}, then this comparison will fail and \set@fontsize gets called again. In this case, \baselinestretch has been made \long because I didn't do \renewcommand*.
\selectfontremoves it! (thought I don't know why) Seriously, what is the question? – ienissei Mar 27 '12 at 8:24\documentclass{minimal} \usepackage{pgf} \begin{document} \renewcommand{\baselinestretch}{} \begin{pgfpicture} \pgfpathmoveto{\pgfpointorigin} \pgfpatharc{0}{180}{5cm} \pgfusepath{draw} \end{pgfpicture} \end{document}, which should produce a circular arc, but doesn't. – Jake Mar 27 '12 at 9:12\baselinestretchin this way, but i think it shows that there is something strange in Tikz. On the other hand, this bug appear in a quite involved document class of mine, and i needed a long time to track it. So maybe if somebody encouters the same, he will know where to look for :) – nicolas roy Mar 27 '12 at 9:22