大家好,我是一名本科生,对 LaTeX 还比较陌生。
我正在尝试绘制这样的时间线,
- 我可以增加/减少矩形的大小
- 沒有項目寫作
- 有一个勾号箭头。
- 消除连接矩形的线。
这是我的原始代码。
\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}