是否有 PGF/TikZ 手册中使用的 TikZ 列表配置?

是否有 PGF/TikZ 手册中使用的 TikZ 列表配置?

我现在想创建一个如何使用 TikZ 的教程。是否有 PGF/TikZ 手册中使用的 TikZ 列表配置?

例如,我想将其作为中\的组成部分,相关的宏必须具有一致的颜色、没有烦人的行号、PDF 复制粘贴友好等。tikz\tikz

答案1

沃纳说得对,我曾经提到过,生成列表的代码可能会公开。我仍然相信,如果可以公开,那就太好了。

然而,TikZ 手册样式仍然 (a) 非常有用且 (b) 几乎没有记录且 (c) 杂乱无章,自该评论以来没有太大进展。

我整理了一个最小工作示例,演示了几个关键功能,以便您可以开始编写此类文档。我相信这是一个很好的起点,它可以跳过一些不可避免的可用性问题。

也许这个网站上的一些高级用户可能想要用完整的样式(包括文档的文档)创建一个“正确”的包。

为了使这段代码启动并运行,您需要将其复制pgfmanual-en-macros.texdoc/generic/pgf/macros/pgfmanual-en-macros.tex本地目录中。

然后,使用

pdflatex file.tex
makeindex file
pdflatex file.tex

来编译它。

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

\usepackage{tikz}

% necessary for the manual styles:
\usepackage{calc}

% if you need an index.
\usepackage{makeidx}


% for cross-references:
\usepackage[pdfborder=0 0 0]{hyperref}
    \hypersetup{%
        colorlinks=true,    % use true to enable colors below:
        linkcolor=blue,%red,
        filecolor=blue,%magenta,
        pagecolor=blue,%red,
        urlcolor=blue,%cyan,
        citecolor=blue,
        %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.
        %pdfsubject=,
    }

% 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:
\def\pgfautoxrefs{1}

% 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

\makeatletter
% 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:
\def\index@prologue{\section*{Index}\addcontentsline{toc}{section}{Index}
}
\makeatother


% this here allows automatic cross referencing:
\RequirePackage{pgfmanual}

% this here configures automatic cross referencing.
% It works for ANY package that uses pgfkeys and is independent on tikz/pgf. 
\pgfkeys{
    % 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}
\makeindex


\begin{document}

\begin{command}{{\tikz}\marg{macro}}
    This is some command definition.
\end{command}

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

\begin{key}{/tikz/red}
    Sets the color to red.
\end{key}

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

We want to reference |key|.

\begin{codeexample}[]
\begin{tikzpicture}
    \draw[red,->] (0,0) -- (1,1);
\end{tikzpicture}
\end{codeexample}

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

% belongs to \usepackage{makeindex}
\printindex

\end{document}

PS 本手册是定制的逐字环境。它与 无关listings。事实上,自动交叉引用是 PGF 逐字环境所独有的。

相关内容