我想要在tikzpicture
如下环境中制作一个时间线:
但是我的代码给出了以下信息:
所以我需要用括号括住我的节点的两条线!
我的代码现在如下所示:
\begin{figure}\label{fig: timeline}
\begin{center}
\begin{tikzpicture}
\draw (0,0) -- (11,0);
\foreach \x in {0.8,4,5.5,7,10.2}
\draw(\x cm,3pt) -- (\x cm, -3pt);
\draw (0.8,0) node[below=3pt] {$T_0$};
\draw (4,0) node[below=3pt] {$T_1$};
\draw (5.5,0) node[below=3pt] {$0$};
\draw (7,0) node[below=3pt] {$T_2$};
\draw (10.2,0) node[below=3pt] {$T_3$};
\draw (2.35,0) node[above=6pt, align=center] {(estimation \\ window]};
\end{tikzpicture}
\end{center}
\end{figure}
答案1
\documentclass[tikz,border=5mm]{standalone}
\newcommand{\mytab}[1]{%
\begin{tabular}{@{}c@{}}
#1
\end{tabular}
}
\begin{document}
\begin{tikzpicture}
\draw (0,0) -- (11,0);
\foreach \x in {0.8,4,5.5,7,10.2}
\draw(\x cm,3pt) -- (\x cm, -3pt);
\draw (0.8,0) node[below=3pt] {$T_0$};
\draw (4,0) node[below=3pt] {$T_1$};
\draw (5.5,0) node[below=3pt] {$0$};
\draw (7,0) node[below=3pt] {$T_2$};
\draw (10.2,0) node[below=3pt] {$T_3$};
\draw (2.35,0) node[above=6pt, align=center] {
$\left(\mytab{estimation \\ window}\right]$};
\end{tikzpicture}
\end{document}
答案2
不是很优雅,但是可以工作
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{figure}\label{fig: timeline} \begin{center} \begin{tikzpicture} \draw (0,0) -- (11,0); \foreach \x in {0.8,4,5.5,7,10.2} \draw(\x cm,3pt) -- (\x cm, -3pt); \draw (0.8,0) node[below=3pt] {$T_0$}; \draw (4,0) node[below=3pt] {$T_1$}; \draw (5.5,0) node[below=3pt] {$0$}; \draw (7,0) node[below=3pt] {$T_2$}; \draw (10.2,0) node[below=3pt] {$T_3$}; \draw (2.35,0) node[above=6pt, align=center] {$\left(\parbox{0.62in}{estimation \ window}\right]$}; \end{tikzpicture} \end{center} \end{figure}
\end{document}