[texhax] TikZ and plain TeX [got many, but not all, examples to work]

Suresh Govindachar sgovindachar at yahoo.com
Sun Mar 9 08:51:08 CET 2014


% I was able to get the expected output from many of the
% examples in the TikZ manual by adding the ''\usetikzlibrary{}''
% line shown below.
%
% I writing in plain TeX using MikTeX Windows 7, 64 bit;
% compiling with the command "pdftex foo.tex"
%
% However, there still remain some issues illustrated in the code below:
%
%     1) ultra thick option doesn't work
%     2) scaling option doesn't work
%     3) the example on page 44 doesn't even compile:
%        error message is about \frac on line 70
%              ! Undefined control sequence.
%% Plain TeX file
\input tikz.tex
\usetikzlibrary{intersections,arrows,angles,quotes,calc,decorations.pathmorphing,backgrounds,positioning,fit,petri}

\baselineskip=12pt
\hsize=6.3truein
\vsize=8.7truein


\tikzpicture{ultra thick}
\draw (0,0) -- (0,1);
\scope{thin}
\draw (1,0) -- (1,1);
\draw (2,0) -- (2,1);
\endscope
% adding following line does not help:
% \scope{ultra thick}
          \draw (3,0) -- (3,1);
% \endscope
\endtikzpicture

will repeat vertical lines, but with scaling -- scaling has no effect:

\tikzpicture{scale=30}
\draw (0,0) -- (0,1);
\scope{thin}
\draw (1,0) -- (1,1);
\draw (2,0) -- (2,1);
\endscope
% adding following line does not help:
% \scope{ultra thick}
          \draw (3,0) -- (3,1);
% \endscope
\endtikzpicture

% \bye

\tikzpicture[scale=3]
\clip (-2,-0.2) rectangle (2,0.8);
\draw[step=.5cm,gray,very thin] (-1.4,-1.4) grid (1.4,1.4);
\filldraw[fill=green!20,draw=green!50!black] (0,0) -- (3mm,0mm)
arc [start angle=0, end angle=30, radius=3mm] -- cycle;
\draw[->] (-1.5,0) -- (1.5,0) coordinate (x axis);
\draw[->] (0,-1.5) -- (0,1.5) coordinate (y axis);
\draw (0,0) circle [radius=1cm];
\draw[very thick,red]
(30:1cm) -- node[left=1pt,fill=white] {$\sin \alpha$} (30:1cm |- x axis);
\draw[very thick,blue]
(30:1cm |- x axis) -- node[below=2pt,fill=white] {$\cos \alpha$} (0,0);
\path [name path=upward line] (1,0) -- (1,1);
\path [name path=sloped line] (0,0) -- (30:1.5cm);
\draw [name intersections={of=upward line and sloped line, by=t}]
[very thick,orange] (1,0) -- node [right=1pt,fill=white]
{$\displaystyle \tan \alpha \color{black}=
\frac{{\color{red}\sin \alpha}}{\color{blue}\cos \alpha}$} (t);
\draw (0,0) -- (t);
\foreach \x/\xtext in {-1, -0.5/-\frac{1}{2}, 1}
\draw (\x cm,1pt) -- (\x cm,-1pt) node[anchor=north,fill=white] {$\xtext$};
\foreach \y/\ytext in {-1, -0.5/-\frac{1}{2}, 0.5/\frac{1}{2}, 1}
\draw (1pt,\y cm) -- (-1pt,\y cm) node[anchor=east,fill=white] {$\ytext$};
\endtikzpicture.

\bye




More information about the texhax mailing list