想知道如何绘制时间线

想知道如何绘制时间线

大家好,我是一名本科生,对 LaTeX 还比较陌生。

我正在尝试绘制这样的时间线,

  1. 我可以增加/减少矩形的大小
  2. 沒有項目寫作
  3. 有一个勾号箭头。
  4. 消除连接矩形的线。

在此处输入图片描述

这是我的原始代码。

\doublespacing
\begin{figure}[h]
\caption{Timing.}
\tikzset{dataset/.style = {rectangle, draw, text width = 2in, minimum height=1in}}
\begin{tikzpicture}[auto, font={\scriptsize}]

    \node [dataset] (tm) {\textbf{Date \emph{t} = 1} 
                            \begin{enumerate}[itemsep=0pt,partopsep=0pt,topsep=0pt,label=(\alph*)]  
                                \item{First-period contract is offered after the firm learns $\theta_1$.}
                                \item{The firm chooses whether to reveal $\bar{\theta_t}$.} 
                            \end{enumerate}\par};
    \node [dataset, right of=tm, node distance=3in] (dmv) {\textbf{Date \emph{t} = 2} 
                            \begin{enumerate}[itemsep=0pt,partopsep=0pt,topsep=0pt,label=(\alph*)] 
                                \item{$\bar{\theta_t}$ becomes public.}  
                                 \item{Tradeoff.}  
                            \end{enumerate}\par};

    \path [-] (tm) edge node[above, sloped] {} (dmv);
\end{tikzpicture}
    \label{fig:dataset}
\end{figure}   

通过代码我得到了这个,

在此处输入图片描述

非常感谢。

答案1

在此处输入图片描述

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning, arrows.meta}
\begin{document}
    \begin{figure}
        \centering
\begin{tikzpicture}
  \draw[->] (0,0) to  (10,0);
  \foreach \x/\q in {1/t=1,6/t=2}{
    \draw[line width=1pt, red] (\x,-2mm) node[below, black](a\x){\q} -- (\x,2mm);
}
\node [above=of a1, draw, blue, semithick, rounded corners, align=left, minimum width=1in, minimum height=2cm] {some sample text };
\node [above=of a6, draw, blue, semithick, rounded corners, align=left, minimum width=1in,minimum height=2cm] {some sample text};
\end{tikzpicture}
\caption{Time Line Diagram} \label{fig:M1}
\end{figure}
\end{document}

为了将文本拆分到新行,请添加文本宽度 =....

否则框将自动扩展以适合下面的测试内容

在此处输入图片描述

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning, arrows.meta}
\begin{document}
    \begin{figure}
        \centering
\begin{tikzpicture}
  \draw[->] (0,0) to  (10,0);
  \foreach \x/\q in {1/t=1,6/t=2}{
    \draw[line width=1pt, red] (\x,-2mm) node[below, black](a\x){\q} -- (\x,2mm);
}
\node [above=of a1, draw, blue, semithick, rounded corners, align=left, minimum width=1in, minimum height=2cm, text width=1in] {some sample text some sample text some sample text some sample text };
\node [above=of a6, draw, blue, semithick, rounded corners, align=left, minimum width=1in,minimum height=2cm] {some sample text some sample text};
\end{tikzpicture}
\caption{Time Line Diagram} \label{fig:M1}
\end{figure}
\end{document}

相关内容