如何使用LaTeX创建时间轴?

Mne*_*nth 74 timeline latex tex

在历史书籍中,您经常会有时间轴,其中事件和时段以相互正确的相对距离标记在一条线上.如何在LaTeX中创建类似的东西?

nib*_*bot 69

有一个新的chronology.sty列维怀斯曼.该文档(PDF)说:

LATEX的大多数时间线包和解决方案用于传达大量信息,因此是垂直设计的.如果您只是尝试为日期分配标签,则更传统的时间轴可能更合适.这就是年代史.

这是一些示例代码:

\documentclass{article}
\usepackage{chronology}
\begin{document}

\begin{chronology}[5]{1983}{2010}{3ex}[\textwidth]
\event{1984}{one}
\event[1985]{1986}{two}
\event{\decimaldate{25}{12}{2001}}{three}
\end{chronology}

\end{document}
Run Code Online (Sandbox Code Playgroud)

哪个产生这个输出:

来自chronology.sty的示例输出

  • 我试图修改chronology.sty文件以获得垂直时间轴但不太成功.它有垂直版本吗? (3认同)
  • 应该注意的是,该软件包似乎仅支持每个文档的一个时间轴.至少对我来说,当我尝试拥有多个错误时,我得到错误"command\c @ step has defined". (2认同)
  • 对于那些在编译此示例时遇到"缺少数字"错误的人,请参阅以下问题:http://tex.stackexchange.com/questions/233781/creating-a-timeline-with-chronology(remove` {3ex}`) . (2认同)
  • @highsciguy 我成功地使用了 `\begin{turn}{90}` 然后是时间顺序并以 `\end{turn}` 结束 (2认同)

Zoe*_*non 43

tikz包似乎有你想要的东西.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{snakes}

\begin{document}

  \begin{tikzpicture}[snake=zigzag, line before snake = 5mm, line after snake = 5mm]
    % draw horizontal line   
    \draw (0,0) -- (2,0);
    \draw[snake] (2,0) -- (4,0);
    \draw (4,0) -- (5,0);
    \draw[snake] (5,0) -- (7,0);

    % draw vertical lines
    \foreach \x in {0,1,2,4,5,7}
      \draw (\x cm,3pt) -- (\x cm,-3pt);

    % draw nodes
    \draw (0,0) node[below=3pt] {$ 0 $} node[above=3pt] {$   $};
    \draw (1,0) node[below=3pt] {$ 1 $} node[above=3pt] {$ 10 $};
    \draw (2,0) node[below=3pt] {$ 2 $} node[above=3pt] {$ 20 $};
    \draw (3,0) node[below=3pt] {$  $} node[above=3pt] {$  $};
    \draw (4,0) node[below=3pt] {$ 5 $} node[above=3pt] {$ 50 $};
    \draw (5,0) node[below=3pt] {$ 6 $} node[above=3pt] {$ 60 $};
    \draw (6,0) node[below=3pt] {$  $} node[above=3pt] {$  $};
    \draw (7,0) node[below=3pt] {$ n $} node[above=3pt] {$ 10n $};
  \end{tikzpicture}

\end{document}
Run Code Online (Sandbox Code Playgroud)

我对tikz不太专业,但这确实给出了一个很好的时间表,看起来像:

在此输入图像描述


Ale*_*tin 16

chronosys也提供了一个很好的解决方案.以下是用户手册中的示例:

在此输入图像描述

  • 谢谢!奇怪的是,编写文档的人一直把时间轴称为"带状装饰",好像和时间​​轴一样.只是把它放在这里以防其他人阅读文档. (3认同)
  • @JonathanKomar 它来自French frise,来自中世纪的拉丁frisium。它是指雕刻或彩绘装饰的宽阔水平带,或水平纸条。 (2认同)

小智 14

只是一个更新.

目前的TiKZ包将发出:包装tikz警告:蛇已被装饰品取代.请在输入行使用装饰库而不是蛇库...

所以代码的相关部分必须改为:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations}
\begin{document}
\begin{tikzpicture}
%draw horizontal line
\draw (0,0) -- (2,0);
\draw[decorate,decoration={snake,pre length=5mm, post length=5mm}] (2,0) -- (4,0);
\draw (4,0) -- (5,0);
\draw[decorate,decoration={snake,pre length=5mm, post length=5mm}] (5,0) -- (7,0);

%draw vertical lines
\foreach \x in {0,1,2,4,5,7}
\draw (\x cm,3pt) -- (\x cm,-3pt);

%draw nodes
\draw (0,0) node[below=3pt] {$ 0 $} node[above=3pt] {$   $};
\draw (1,0) node[below=3pt] {$ 1 $} node[above=3pt] {$ 10 $};
\draw (2,0) node[below=3pt] {$ 2 $} node[above=3pt] {$ 20 $};
\draw (3,0) node[below=3pt] {$  $} node[above=3pt] {$  $};
\draw (4,0) node[below=3pt] {$ 5 $} node[above=3pt] {$ 50 $};
\draw (5,0) node[below=3pt] {$ 6 $} node[above=3pt] {$ 60 $};
\draw (6,0) node[below=3pt] {$  $} node[above=3pt] {$  $};
\draw (7,0) node[below=3pt] {$ n $} node[above=3pt] {$ 10n $};
\end{tikzpicture}

\end{document}
Run Code Online (Sandbox Code Playgroud)

HTH

  • 我认为现在已成为:`\ usetikzlibrary {decorations.pathmorphing}`.另外,如果你想要一个紧密裁剪的图片插入另一个文件,请做`\ documentclass [tikz] {standalone}`. (2认同)

Jon*_*son 13

Tim Storer写了一个更灵活,更漂亮的外观timeline.sty(Internet Archive Wayback Machine链接,因为原版已经不见了).此外,该线是水平的而不是垂直的.例如:

\begin{timeline}{2008}{2010}{50}{250}
  \MonthAndYearEvent{4}{2008}{First Podcast}
  \MonthAndYearEvent{7}{2008}{Private Beta}
  \MonthAndYearEvent{9}{2008}{Public Beta}
  \YearEvent{2009}{IPO?}
\end{timeline}
Run Code Online (Sandbox Code Playgroud)

生成如下所示的时间轴:

2008                              2010
 · · April, 2008 First Podcast    ·
       · July, 2008 Private Beta
           · September, 2008 Public Beta
                · 2009 IPO?
Run Code Online (Sandbox Code Playgroud)

就个人而言,我发现这是一个比其他答案更令人满意的解决方案.但我也发现自己修改了代码,以便更接近我认为时间轴应该是什么样的东西.所以我认为没有明确的解决方案.


prz*_*moc 10

首先,我更喜欢tikz引导式解决方案,因为它可以为您提供更多自由.其次,我不会发布任何全新的内容.这显然与Zoe Gagnon的回答相似,因为他展示了道路.

我需要一些时间线,我花了一些时间(这真是一个惊喜!),所以我分享了结果.我希望你会喜欢它.

\documentclass[tikz]{standalone}
\usepackage{verbatim}
\begin{document}
\newlength\yearposx
\begin{tikzpicture}[scale=0.57] % timeline 1990-2010->
    % define coordinates (begin, used, end, arrow)
    \foreach \x in {1990,1992,2000,2002,2004,2005,2008,2009,2010,2011}{
        \pgfmathsetlength\yearposx{(\x-1990)*1cm};
        \coordinate (y\x)   at (\yearposx,0);
        \coordinate (y\x t) at (\yearposx,+3pt);
        \coordinate (y\x b) at (\yearposx,-3pt);
    }
    % draw horizontal line with arrow
    \draw [->] (y1990) -- (y2011);
    % draw ticks
   \foreach \x in {1992,2000,2002,2004,2005,2008,2009}
        \draw (y\x t) -- (y\x b);
    % annotate
    \foreach \x in {1992,2002,2005,2009}
        \node at (y\x) [below=3pt] {\x};
    \foreach \x in {2000,2004,2008}
        \node at (y\x) [above=3pt] {\x};
    \begin{comment}
    % for use in beamer class
    \only<2>    {\fill      (y1992) circle (5pt);}
    \only<3-5>  {\fill      (y2000) circle (5pt);}
    \only<4-5>  {\fill      (y2002) circle (5pt);}
    \only<5>    {\fill[red] (y2004) circle (5pt);}
    \only<6>    {\fill      (y2005) circle (5pt);}
    \only<7>    {\fill[red] (y2005) circle (5pt);}
    \only<8-11> {\fill      (y2008) circle (5pt);}
    \only<11>   {\fill      (y2009) circle (5pt);}
    \end{comment}
\end{tikzpicture}
\end{document}
Run Code Online (Sandbox Code Playgroud)

正如您所看到的,它是针对投影仪演示(选择部分和缩放选项)而定制的,但如果您真的想在演示文稿中对其进行测试,那么您应该移出\newlength\yearposx框架定义,否则您将得到错误的错误说明该命令\yearposx已经定义(除非您从帧中删除选择部分和任何其他帧分割命令).

在此输入图像描述