我想要很多盒子(见http://www.texample.net/tikz/examples/boxes-with-text-and-math/) 里面有文本和数学公式。这些框垂直排列,并用线连接。
我该如何使用 LaTeX 来实现这个功能?
答案1
这里有一个基于您链接的 TeXample。它使用“定位库”将框定位在彼此下方。
您需要为每个框指定自己的名称(例如box1
,,box2
...或任何其他标签),以便您可以在图片中引用它们。然后使用绘图命令将它们连接起来,就像\draw [your style] (box1) -- (box2);
代码:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes,snakes,positioning}
\usepackage{amsmath,amssymb}
\begin{document}
% Define box and box title style
\tikzstyle{mybox} = [draw=red, fill=blue!20, very thick,
rectangle, rounded corners, inner sep=10pt, inner ysep=20pt]
\tikzstyle{fancytitle} =[fill=red, text=white]
\begin{tikzpicture}
% First box
\node [mybox] (box1){%
\begin{minipage}{0.50\textwidth}
To calculate the horizontal position the kinematic differential
equations are needed:
\begin{align}
\dot{n} &= u\cos\psi -v\sin\psi \\
\dot{e} &= u\sin\psi + v\cos\psi
\end{align}
For small angles the following approximation can be used:
\begin{align}
\dot{n} &= u -v\delta_\psi \\
\dot{e} &= u\delta_\psi + v
\end{align}
\end{minipage}
};
% Fancy title of first box (remove if not required)
\node[fancytitle, right=10pt] at (box1.north west) {A fancy title};
\node[fancytitle, rounded corners] at (box1.east) {$\clubsuit$};
%
% Second Box, placed with 1cm distance below box1
\node [mybox,below=1cm of box1.south] (box2) {%
\begin{minipage}[t!]{0.5\textwidth}
Fermat's Last Theorem states that
\[
x^n + y^n = z^n
\]
has no non-zero integer solutions for $x$, $y$ and $z$ when $n > 2$.
\end{minipage}
};
% Draw a connection line between box1 and box2 with the same style like the box:
\draw [mybox] (box1) -- (box2);
% Now draw the fancy title (so that it is on top of the connection box)
\node[fancytitle] at (box2.north) {Fermat's Last Theorem};
% Third Box, placed with 1cm distance below box2
\node [mybox,below=1cm of box2.south] (box3) {%
\begin{minipage}[t!]{0.5\textwidth}
Fermat's Last Theorem states that
\[
x^n + y^n = z^n
\]
has no non-zero integer solutions for $x$, $y$ and $z$ when $n > 2$.
\end{minipage}
};
% Draw a connection line between box2 and box3 with the same style like the box:
\draw [mybox] (box2) -- (box3);
% Now draw the fancy title (so that it is on top of the connection box)
\node[fancytitle] at (box3.north) {Fermat's Last Theorem};
\end{tikzpicture}
%
\end{document}
结果:
答案2
您所要求的似乎很容易使用来实现TikZ
。 MWE 将是:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\tikzstyle{box} = [rectangle, draw, black]
\begin{tikzpicture}
\node (first) [box] {some text, and some maths: $a = 1$};
\node (second) [box,below of=first] {other text, and some more maths: $b = 2$};
\node (third) [box,below of=second] {$c = 3$};
\draw (first) -- (second) -- (third);
\end{tikzpicture}
\end{document}
最终结果如下: