I want to create a tutorial how to use TikZ now. Is there a listings configuration for TikZ as used in PGF/TikZ manual?

For example, I want to make \ as an integral part of tikz in \tikz, relevant macros must have consistent colors, no annoying line numbers, PDF copy-paste friendly, etc.

  • 1
    Christian Feuersänger once mentioned that the code to produce the listings might become available, but I'm not sure if this is the case. He's best to answer that...
    – Werner
    Sep 18, 2012 at 5:56
  • Isn't it available in the CVS version build? I remember Alain Matthes had a problem compiling it with LuaLaTeX.
    – percusse
    Sep 18, 2012 at 7:59
  • 1
    The sources of the manual are available. But I don't think that it uses listings to format the code. To me it looks like more or less normal verbatim. Sep 18, 2012 at 8:23
  • Related: tex.stackexchange.com/questions/53351/…
    – percusse
    Sep 18, 2012 at 8:25
  • 1
    Look for the pgfmanual-en-macros.tex file in your distribution. It contains the definition of the codexample environment... Sep 18, 2012 at 8:28

1 Answer 1


Werner is right, I once mentioned that the code to produce listings might become available. And I still believe it would be nice if it would.

However, the TikZ manual styles are still (a) quite useful and (b) almost undocumented and (c) untidy without much progress since that comment.

I have assembled a minimum working example which demonstrates a couple of key features such that you may be able to start such a document. I believe it is a good starting point, and it allows to skip a few unavoidable usability issues.

Perhaps someone of the power-users on this site might want to create a "right" package out of the complete styles - including documentation for the documentation.

In order to get this piece of code up and running, you NEED TO COPY pgfmanual-en-macros.tex from doc/generic/pgf/macros/pgfmanual-en-macros.tex into your local directory.

Then, use

pdflatex file.tex
makeindex file
pdflatex file.tex

to compile it.

% to allow compression of cross references. 
% both pgfmanual and pgfplots manual would be MUCH larger without it.
\documentclass{ltxdoc} % the pgf manual styles are based on ltxdoc


% necessary for the manual styles:

% if you need an index.

% for cross-references:
\usepackage[pdfborder=0 0 0]{hyperref}
        colorlinks=true,    % use true to enable colors below:
        %frenchlinks=false, % small caps instead of colors
        pdfborder=0 0 0,    % PDF link-darstellung, falls colorlinks=false. 0 0 0: nix. 0 0 1: default.
        %plainpages=false,  % Das ist notwendig, wenn die Seitenzahlen z.T. in Arabischen und z.T. in römischen Ziffern gemacht werden.

% just in case you need it:
\newcommand\Tikz{Ti\textit kZ}

% this is due to some stupidity in pgfmanual-en-macros.tex:
% if this macro is not defined, the automatic cross-referencing is
% disabled:

% this here contains definitions (and the ONLY documentation for these
% definitions) like
% \begin{command}{\macro}
% \end{command}
% \begin{key}{/some/key=\marg{value}}
% \end{key}
\input pgfmanual-en-macros.tex

% the index of PGF contains 
% ----
% This index only contains automatically generated entries. A good index should
% also contain carefully selected keywords. This index is not a good index.
% ---
% use this line to reset that entry:

% this here allows automatic cross referencing:

% this here configures automatic cross referencing.
% It works for ANY package that uses pgfkeys and is independent on tikz/pgf. 
    % whenever an unqualified key is found, the following key prefix
    % list is tried to find a match.
    /pdflinks/search key prefixes in={/tikz/,/pgf/},
    % the link prefix written to the pdf file:
    /pdflinks/internal link prefix=pgfp,
    /pdflinks/codeexample links=true,
    /pdflinks/warnings=false,   % for debugging 
    /pdflinks/show labels=false,% for debugging

% belongs to \usepackage{makeindex}


    This is some command definition.

\begin{key}{/tikz/key=\marg{value} (initially somevalue)}
    This is some key definition.

    Sets the color to red.

\begin{key}{/something/strange=\mchoice{choice1,choice2} (initially choice1)}
    A special key.

We want to reference |key|.

    \draw[red,->] (0,0) -- (1,1);

Note that |/something/strange| does not belong to \Tikz. Note that |\tikz| is a macro of \Tikz.

% belongs to \usepackage{makeindex}


PS the manual is a customized verbatim environment. It is unrelated to listings. In fact, the auto-cross referencing is unique to the PGF verbatim environment.


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.