TikZ-花括号在同一节点结束,但有一个间隙

TikZ-花括号在同一节点结束,但有一个间隙

我用 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

您需要使用coordinates 而不是nodes 来标记路径上的坐标以供以后使用)。我添加了draw=green如下every node所示的样式:

在此处输入图片描述

虚线在节点处结束,右括号也从节点的右边界开始。(因此您可以使用锚点,.centercoordinates 更舒服。)

代码

\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}

输出

在此处输入图片描述

相关内容