答案1
这是在 LaTeX 课堂上为我的学生提供的一个例子(大约 2010-2014 年)
\documentclass{article}
%\usepackage[margin=1in]{geometry}
%\usepackage[latin1]{inputenc}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows}
\begin{document}
% Define block styles
\tikzstyle{decision} = [diamond, draw, fill=blue!20,
text width=4.5em, text badly centered, node distance=3cm, inner sep=0pt]
\tikzstyle{block} = [rectangle, draw, fill=blue!20,
text width=5em, text centered, rounded corners, minimum height=4em]
\tikzstyle{blockred} = [rectangle, draw, fill=red!20,
text width=5em, text centered, rounded corners, minimum height=4em]
\tikzstyle{line} = [draw, -latex']
\tikzstyle{cloud} = [draw, ellipse,fill=red!20, node distance=3cm,
minimum height=2em]
\begin{tikzpicture}[node distance = 2cm, auto]
% Place nodes
\node [block] (edit) {Edit source with \TeX{}maker};
\node [blockred, above of=edit] (setup) {Setup for document};
\node [block, right of=edit, node distance=3cm] (compile) {Compile source};
\node [block, below of=compile, node distance=3cm] (view) {View output};
\node [decision, below of=view, node distance=3cm] (decide) {Ready to Print?};
\node [blockred, right of=decide, node distance=5cm] (print) {Print document};
\path [line,dashed] (setup) -- (edit);
\path [line] (edit) -- (compile);
\path [line] (compile) -- (view);
\path [line] (view) -- (decide);
\path [line] (decide) -| node [near start] {no} (edit);
\path [line] (decide) -- node {yes} (print);
\end{tikzpicture}
\newpage
% Define block styles
\tikzstyle{decision} = [diamond, draw, fill=blue!20,
text width=4.5em, text badly centered, node distance=3cm, inner sep=0pt]
\tikzstyle{block} = [rectangle, draw, fill=blue!20,
text width=5em, text centered, rounded corners, minimum height=4em]
\tikzstyle{blockred} = [rectangle, draw, fill=red!20,
text width=30em, text centered, rounded corners, minimum height=4em]
\tikzstyle{line} = [draw, -latex']
\tikzstyle{cloud} = [draw, ellipse,fill=red!20, node distance=3cm,
minimum height=2em]
\begin{tikzpicture}[node distance = 2cm, auto]
%% Place nodes
\node [block] (edit) {Edit *.Rnw with \TeX{}maker and Save};
\node [blockred, above of=edit, node distance=4cm] (setup) {\LARGE{Setup}\break \footnotesize{New Folder} \break \footnotesize{Start R, Change dir} \break \footnotesize{Start \TeX{}maker, Create *.Rnw} \break \footnotesize{Go to \textbf{R}, Sweave("*.Rnw"), Verify no \textbf{R} errors} \break \footnotesize{Go to \TeX{}maker} \break \footnotesize{Compile and View initial output}};
%
\node [block, right of=edit, node distance=3cm] (sweave) {With R\break Sweave(" *.Rnw")};
\node [decision, below of=sweave, node distance=3cm] (rcheck) {Any R errors?};
\node [block, right of=rcheck, node distance=3cm] (compile) {In \TeX{}maker compile};
\node [block, below of=compile, node distance=3cm] (view) {View output};
\node [decision, below of=view, node distance=3cm] (decide) {Ready to Print?};
\node [block, below of=decide, node distance=3cm] (print) {Print document};
%
\path [line,dashed] (setup) -- (edit);
\path [line] (edit) -- (sweave);
\path [line] (sweave) -- (rcheck);
\path [line] (rcheck) -- node {no} (compile);
\path [line] (rcheck) -| node [near start] {yes} (edit);
\path [line] (compile) -- (view);
\path [line] (view) -- (decide);
\path [line] (decide) -| node [near start] {no} (edit);
\path [line] (decide) -- node {yes} (print);
%
\end{tikzpicture}
\end{document}
第一页的输出是:
第二页: