Extension:PGFTikZ

The PGFTikZ extension generates images from PGF/TikZ input [].

Usage

 * Enter PGf/TikZ code between  ...  tags.
 * File line must be an image link line Help:Images e.g. SampleImage.png . Currently 'Image'/'Media' cannot be used instead of 'File' in the image link line.  Once the image is uploaded, it will be rendered as if only the image link line was passed.
 * Within the  ...  block, the preamble necessary to compile the LateX file should be added between  ...  tags.
 * After the preamble, the PGF/TikZ input can be entered as it would be after the \begin{document} entry of a LaTeX document (note that the \begin{document} and \end{document} markups should not be added in the PGFTikZ block).
 * Example (based on wikipedia:File:Neighbourhood_definition2.svg):



\usepackage{tikz} \usetikzlibrary{arrows} \usetikzlibrary{intersections} \usetikzlibrary{calc}

 \begin{tikzpicture}[scale=.8,every node/.style={minimum size=1cm}] %  \begin{scope}[ yshift=-83,every node/.append style={ yslant=0.5,xslant=-1},yslant=0.5,xslant=-1 ]      \draw[step=4mm, black] (0,0) grid (5,5); \draw[black,thick] (0,0) rectangle (5,5);%borders \fill[green] (2.05,2.05) rectangle (2.35,2.35); % center pixel \fill[green] (1.65,2.05) rectangle (1.95,2.35); %left \fill[green] (2.45,2.05) rectangle (2.75,2.35); %right \fill[green] (2.05,2.45) rectangle (2.35,2.75); %top \fill[green] (2.05,1.95) rectangle (2.35,1.65); %bottom % 8 -pixel setting \fill[green] (1.65,2.45) rectangle (1.95,2.75); %top-left \fill[green] (2.45,2.45) rectangle (2.75,2.75); %top-right \fill[green] (2.75,1.95) rectangle (2.45,1.65); %bottom-right \fill[green] (1.65,1.95) rectangle (1.95,1.65); %bottom-left % 2. ring \fill[green] (1.25,1.55) rectangle (1.55,1.25); %bottom-left \fill[green] (0.85,1.55) rectangle (1.15,1.25); %bottom-left \fill[green] (0.85,1.15) rectangle (1.15,0.85); %bottom-left \fill[green] (1.25,0.75) rectangle (1.55,0.45); %bottom-left \end{scope} %  \begin{scope}[ yshift=0,every node/.append style={ yslant=0.5,xslant=-1},yslant=0.5,xslant=-1 ]      \fill[white,fill opacity=0.9] (0,0) rectangle (5,5); \draw[step=4mm, black] (0,0) grid (5,5); %grid definition \draw[black,thick] (0,0) rectangle (5,5);%borders \fill[green] (2.05,2.05) rectangle (2.35,2.35); % center pixel \fill[green] (1.65,2.05) rectangle (1.95,2.35); %left \fill[green] (2.45,2.05) rectangle (2.75,2.35); % right \fill[green] (2.05,2.45) rectangle (2.35,2.75); % top \fill[green] (2.05,1.95) rectangle (2.35,1.65); % bottom % 4 -pixel setting \fill[green] (1.65,2.45) rectangle (1.95,2.75); %top-left \fill[green] (2.45,2.45) rectangle (2.75,2.75); %top-right \fill[green] (2.75,1.95) rectangle (2.45,1.65); %bottom-right \fill[green] (1.65,1.95) rectangle (1.95,1.65); %bottom-left % 2. ring \fill[orange] (1.25,1.55) rectangle (1.55,1.25); \fill[orange] (0.85,1.55) rectangle (1.15,1.25); \fill[orange] (0.85,1.15) rectangle (1.15,0.85); \fill[blue] (1.25,0.75) rectangle (1.55,0.45); \end{scope} % % draw annotations %  \draw[-latex,thick,orange](-3,5)node[left]{ } to[out=0,in=90] (-.4,1.4); \draw[-latex,thick,blue](-3,5)node[left]{ } to[out=0,in=90] (0.8,1.15); \draw[-latex,thick,green](-3,5)node[left]{3 patches} to[out=0,in=90] (0,2.8); %  \draw[-latex,thick,green](-3,-2)node[left]{1 patch} to[out=0,in=200] (-1,-.9); \draw[thick,gray!70!black](6,4) node {4 neighbourhood rule}; \draw[thick,gray!70!black](6,-2) node {8 neighbourhood rule}; % \end{tikzpicture} 

How it works

 * 1) The PGF/TikZ code (preamble and body) is extracted from the block, and stored in a temporary LaTeX file similar to the following one:

\documentclass{article} \def\pgfsysdriver{pgfsys-dvips.def} \usepackage[usenames]{color}

[... Content of PGFTikZPreamble block...]

\begin{document} \thispagestyle{empty}

[... Main content of PGFTikZ block...]

\end{document}

Configuration parameters
$wgPGFTikZDefaultDPI (300): Default resolution for generated images

$wgPGFTikZLaTeXPath ('latex'): Full path to LaTeX executable

$wgPGFTikZLaTeXOpts (''): Command line options to LaTeX command

$wgPGFTikZdvipsPath ('dvips'): Full path to dvips executable

$wgPGFTikZepstoolPath ('epstool'): Full path to epstool executable

Requirements
Programs:
 * latex with the PGF/TikZ package.
 * dvips
 * epstool
 * Enable file uploads (see Manual:Image administration)
 * Enable API (Manual:$wgEnableWriteAPI) and API write (Manual:$wgEnableAPI)
 * ImageMagick must be installed and enabled (see $wgUseImageMagick). The $wgImageMagickConvertCommand variable should point to the convert executable.

You may have to increase the amount of memory available for shell programs by modifying the $wgMaxShellMemory variable in LocalSettings.php.