我用 TikZ 创建了时间轴。问题是,在同一节点结束的括号两端之间有一点间隙。
这是我的代码:
\begin{tikzpicture}[y=1cm, x=1cm, thick, font=\footnotesize]
% axis
\draw[line width=1.2pt, ->, >=latex'](0,0) -- coordinate (x axis) (10,0);
% time points
\draw (3,-4pt) node(t_k){} --
(3,4pt) node[anchor=south] {$t_{k}$};
\draw (5,-4pt) node(t_k_opt) {} --
(5,4pt) node[anchor=south] {};
\draw (7,-4pt) node(t_k_opt_impl) {} --
(7,4pt) node[anchor=south] {$t_{k}+\triangle^{\text{opt}}+\triangle^{\text{impl}}$};
% curly braces
\draw[decorate,decoration={brace,amplitude=3pt,mirror}]
(3,-2.5) node(t_k_unten){} --
(5,-2.5) node(t_k_opt_unten){};
\node at (4,-3){$\triangle^{\text{opt}}$};
\draw[decorate,decoration={brace,amplitude=3pt,mirror}]
(t_k_opt_unten) --
(7,-2.5) node(t_k_opt_impl_unten){};
\node at (6,-3){$\triangle^{\text{impl}}$};
% vertical dotted lines
\draw[dotted] (t_k)--(t_k_unten);
\draw[dotted] (t_k_opt)--(t_k_opt_unten);
\draw[dotted] (t_k_opt_impl)--(t_k_opt_impl_unten);
\end{tikzpicture}
如果有人能帮忙我会很高兴!
答案1
您需要使用coordinate
s 而不是node
s 来标记路径上的坐标以供以后使用)。我添加了draw=green
如下every node
所示的样式:
虚线在节点处结束,右括号也从节点的右边界开始。(因此您可以使用锚点,.center
但coordinate
s 更舒服。)
代码
\documentclass[tikz]{standalone}
\usetikzlibrary{arrows,decorations.pathreplacing}
\usepackage{amsmath}
\begin{document}
\begin{tikzpicture}[y=1cm, x=1cm, thick, font=\footnotesize]
% axis
\draw[line width=1.2pt, ->, >=latex'](0,0) -- coordinate (x axis) (10,0);
% time points
\draw (3,-4pt) coordinate (t_k) -- (3,4pt) node[anchor=south] {$t_{k}$};
\draw (5,-4pt) coordinate (t_k_opt) -- (5,4pt) node[anchor=south] {};
\draw (7,-4pt) coordinate (t_k_opt_impl) -- (7,4pt) node[anchor=south]
{$t_{k}+\triangle^{\text{opt}}+\triangle^{\text{impl}}$};
% curly braces
\draw[decorate,decoration={brace,amplitude=3pt,mirror}]
(3,-2.5) coordinate (t_k_unten) -- (5,-2.5) coordinate (t_k_opt_unten);
\node at (4,-3){$\triangle^{\text{opt}}$};
\draw[decorate,decoration={brace,amplitude=3pt,mirror}]
(t_k_opt_unten) -- (7,-2.5) coordinate (t_k_opt_impl_unten);
\node at (6,-3){$\triangle^{\text{impl}}$};
% vertical dotted lines
\draw[dotted] (t_k) -- (t_k_unten);
\draw[dotted] (t_k_opt) -- (t_k_opt_unten);
\draw[dotted] (t_k_opt_impl) -- (t_k_opt_impl_unten);
\end{tikzpicture}
\end{document}