我的最小工作示例如下。
\documentclass{article}
\usepackage{xcolor}
\usepackage{tikz}
\usepackage{graphicx}
\usepackage{pgfplots}
\usetikzlibrary{spy}
%\usepackage[font=normal,caption=false]{subfig}
%\usepackage{float}
\usetikzlibrary{lindenmayersystems}
\usetikzlibrary[shadings]
\pgfplotsset{compat=1.11}
\definecolor{bblue}{HTML}{4F81BD}
\definecolor{rred}{HTML}{C0504D}
\definecolor{ggreen}{HTML}{9BBB59}
\definecolor{ppurple}{HTML}{9F4C7C}
\begin{document}
\pgfdeclarelindenmayersystem{Koch curve}{
\rule{F -> F-F++F-F}}
\pgfdeclarelindenmayersystem{Sierpinski triangle}{
\rule{F -> G-F-G}
\rule{G -> F+G+F}}
\pgfdeclarelindenmayersystem{Fractal plant}{
\rule{X -> F-[[X]+X]+F[+FX]-X}
\rule{F -> FF}}
\pgfdeclarelindenmayersystem{Hilbert curve}{
\rule{L -> +RF-LFL-FR+}
\rule{R -> -LF+RFR+FL-}}
\resizebox{\textwidth}{!}{
\begin{tabular}{cccc}
\begin{tikzpicture}[spy using outlines={circle,yellow,magnification=2,size=4cm, connect spies}]
\draw [green!50!black, rotate=90]
[l-system={Fractal plant, axiom=X, order=6, step=2pt, angle=25}]
lindenmayer system;
\spy on (2.4,8) in node [right] at (2,1.25);
\end{tikzpicture}
&
\begin{tikzpicture}[spy using outlines={circle,black,magnification=2,size=4.5cm, connect spies}]
\shadedraw [bottom color=white, top color=red!80, draw=red!80!black]
[l-system={Hilbert curve, axiom=L, order=5, step=8pt, angle=90}]
lindenmayer system;
\spy on (5.9,1.3) in node [right] at (9,7);
\end{tikzpicture}
\\
\\
\begin{tikzpicture}[spy using outlines={circle,black,magnification=3.5,size=4.5cm, connect spies}]
\shadedraw [top color=white, bottom color=blue!80, draw=blue!80!black]
[l-system={Sierpinski triangle, step=2pt, angle=60, axiom=F, order=8}]
lindenmayer system -- cycle;
\spy on (5.7,1.3) in node [right] at (6,6);
\end{tikzpicture}
&
\begin{tikzpicture}
\shadedraw[shading=color wheel][spy using outlines={circle,black,magnification=3.5,size=4.5cm, connect spies}]
[l-system={Koch curve, step=2pt, angle=60, axiom=F++F++F, order=4}]
lindenmayer system -- cycle;
\spy on (4,6) in node [left] at (1,7);
\end{tikzpicture}
\end{tabular}}
\end{document}
我收到的错误如下。
! Undefined control sequence.
<argument> ...] lindenmayer system -- cycle; \spy
on (4,6) in node [left] at...
l.68 \end{tabular}}
?
Missing character: There is no o in font nullfont!
Missing character: There is no n in font nullfont!
Missing character: There is no ( in font nullfont!
Missing character: There is no 4 in font nullfont!
答案1
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{spy,decorations.fractals}
\usetikzlibrary{lindenmayersystems}
\usetikzlibrary{shadings}
\pgfdeclarelindenmayersystem{Koch curve}{
\rule{F -> F-F++F-F}}
\pgfdeclarelindenmayersystem{Sierpinski triangle}{
\rule{F -> G-F-G}
\rule{G -> F+G+F}}
\pgfdeclarelindenmayersystem{Fractal plant}{
\rule{X -> F-[[X]+X]+F[+FX]-X}
\rule{F -> FF}}
\pgfdeclarelindenmayersystem{Hilbert curve}{
\rule{L -> +RF-LFL-FR+}
\rule{R -> -LF+RFR+FL-}}
\begin{document}
\resizebox{\textwidth}{!}{\begin{tabular}{cccc}
\begin{tikzpicture}[spy using outlines={circle,yellow,magnification=2,size=4cm, connect spies}]
\draw [green!50!black, rotate=90]
[l-system={Fractal plant, axiom=X, order=6, step=2pt, angle=25}]
lindenmayer system;
\spy on (2.4,8) in node [right] at (2,1.25);
\end{tikzpicture}
&
\begin{tikzpicture}[spy using outlines={circle,black,magnification=2,size=4.5cm, connect spies}]
\shadedraw [bottom color=white, top color=red!80, draw=red!80!black]
[l-system={Hilbert curve, axiom=L, order=5, step=8pt, angle=90}]
lindenmayer system;
\spy on (5.9,1.3) in node [right] at (9,7);
\end{tikzpicture}
\\
\\
\begin{tikzpicture}[spy using outlines={circle,black,magnification=3.5,size=4.5cm, connect spies}]
\shadedraw [top color=white, bottom color=blue!80, draw=blue!80!black]
[l-system={Sierpinski triangle, step=2pt, angle=60, axiom=F, order=8}]
lindenmayer system -- cycle;
\spy on (5.7,1.3) in node [right] at (6,6);
\end{tikzpicture}
&
\begin{tikzpicture}[
spy using outlines={circle,black,magnification=3.5,size=4.5cm, connect spies}]
\shadedraw[shading=color wheel]
[l-system={Koch curve, step=2pt, angle=60, axiom=F++F++F, order=4}]
lindenmayer system -- cycle;
\spy on (4,6) in node [left] at (1,7);
\end{tikzpicture}
\end{tabular}}
\end{document}
答案2
对我来说,你的compat=1.11
没有工作(MacTeX 2015),但尽管如此,如果你看看你的最后一个,你不小心把命令tikzpicture
所需的间谍介绍spy
后你的shadedraw
。改变这些收益
\begin{tikzpicture}[spy using outlines={circle,black,magnification=3.5,size=4.5cm, connect spies}]
\shadedraw[shading=color wheel]
[l-system={Koch curve, step=2pt, angle=60, axiom=F++F++F, order=4}]
lindenmayer system -- cycle;
\spy on (4,6) in node [left] at (1,7);
\end{tikzpicture}
它在我这边编译(尽管如此,间谍已经关闭并且只是放大白色)。