Jak stworzyć oś czasu za pomocą LaTeX?
W książkach historycznych często występuje oś czasu, w której wydarzenia i okresy są zaznaczane na linii we właściwej względnej odległości od siebie. Jak można stworzyć coś podobnego w Latexie?
9 answers
Pakiet tikz wydaje się mieć to, czego chcesz.
\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}
Nie jestem zbyt ekspertem w tikz, ale to daje dobrą oś czasu, która wygląda jak:
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2015-04-16 14:52:30
Jest nowa chronologia.sty by Levi Wiseman . Dokumentacja (pdf) mówi:
Większość pakietów osi czasu i rozwiązań dla LATEX-a służy do przekazywania wielu informacji i dlatego są projektowane pionowo. Jeśli próbujesz przypisać etykiety do dat, bardziej odpowiednia może być bardziej tradycyjna oś czasu. To do czego służy chronologia.
Oto przykładowy kod:
\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}
Który wytwarza to wyjście:
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-12-09 19:36:25
Również Pakiet chronosys stanowi dobre rozwiązanie. Oto przykład z instrukcji obsługi:
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2013-07-25 12:06:59
/ Align = "left" /
Obecny pakiet TiKZ wyda: Pakiet tikz Ostrzeżenie: Węże zostały zastąpione przez odznaczenia Proszę użyć bibliotek dekoracji zamiast biblioteka węży na linii wejściowej. . .
Więc część kodu musi zostać zmieniona na:
\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}
HTH
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2010-11-13 04:31:25
Tim Storer napisał bardziej elastyczny i ładniej wyglądający timeline.sty
(Internet Archive Wayback Machine link, jako oryginał zniknął). Ponadto linia jest pozioma, a nie pionowa. Na przykład:
\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}
Tworzy oś czasu, która wygląda tak:
2008 2010
· · April, 2008 First Podcast ·
· July, 2008 Private Beta
· September, 2008 Public Beta
· 2009 IPO?
Osobiście uważam to za bardziej przyjemne rozwiązanie niż inne odpowiedzi. Ale również znajduję się modyfikując kod, aby zbliżyć się do tego, co myślę, że oś czasu powinna wyglądać. Więc jest moim zdaniem nie jest to ostateczne rozwiązanie.Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2012-06-18 13:56:04
Po pierwsze, wolę tikz
rozwiązanie kierowane, ponieważ daje większą swobodę. Po drugie, nie zamieszczam niczego zupełnie nowego. Jest to oczywiście podobne do odpowiedzi Zoe Gagnon, ponieważ pokazał drogę.
Potrzebowałem trochę czasu i zajęło mi to trochę czasu (co za niespodzianka!) aby to zrobić, więc dzielę się wynikami. Mam nadzieję, że ci się spodoba.
\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}
Jak widać, jest dostosowany do prezentacji beamera( wybierz część, a także opcję skalowania), ale jeśli naprawdę chcesz przetestować go w prezentacja, następnie należy przenieść \newlength\yearposx
poza definicję ramki, ponieważ w przeciwnym razie pojawi się błąd stwierdzający, że komenda \yearposx
jest już zdefiniowana (chyba że usuniesz część zaznaczenia i inne polecenia dzielące ramkę z ramki).
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-02-11 11:54:19
Jeśli szukasz diagramów sekwencji UML, może Cię zainteresować pkf-umlsd, który jest oparty na TiKZ. Ładne dema można znaleźć tutaj .
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2009-06-26 10:12:13
Jest oś czasu.sty
Składnia jest prostsza niż użycie tikz:
%%% In LaTeX:
%%% \begin{timeline}{length}(start,stop)
%%% .
%%% .
%%% .
%%% \end{timeline}
%%%
%%% in plain TeX
%%% \timeline{length}(start,stop)
%%% .
%%% .
%%% .
%%% \endtimeline
%%% in between the two, we may have:
%%% \item{date}{description}
%%% \item[sortkey]{date}{description}
%%% \optrule
%%%
%%% the options to timeline are:
%%% length The amount of vertical space that the timeline should
%%% use.
%%% (start,stop) indicate the range of the timeline. All dates or
%%% sortkeys should lie in the range [start,stop]
%%%
%%% \item without the sort key expects date to be a number (such as a
%%% year).
%%% \item with the sort key expects the sort key to be a number; date
%%% can be anything. This can be used for log scale time lines
%%% or dates that include months or days.
%%% putting \optrule inside of the timeline environment will cause a
%%% vertical rule to be drawn down the center of the timeline.
Użyłem DateTime Pythona.data.toordinal do konwersji dat na 'sort keys' w kontekście pakietu.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2011-03-21 02:35:43
Starałem się znaleźć odpowiedni sposób na stworzenie osi czasu, co w końcu mogłem zrobić z tą modyfikacją. Zwykle podczas tworzenia osi czasu problem polegał na tym, że nie mogłem dodać tekstu, aby wyjaśnić każdą datę wyraźnie dłuższym tekstem. Zmodyfikowałem i dalej wykorzystałem skrypt latex @ Zoe Gagnon. Zapraszamy do zapoznania się z poniższymi informacjami:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{snakes}
\usepackage{rotating}
\begin{document}
\begin{center}
\begin{tikzpicture}
% draw horizontal line
\draw (-5,0) -- (6,0);
% draw vertical lines
\foreach \x in {-5,-4,-3,-2, -1,0,1,2}
\draw (\x cm,3pt) -- (\x cm,-3pt);
% draw nodes
\draw (-5,0) node[below=3pt] {$ 0 $} node[above=3pt] {$ $};
\draw (-4,0) node[below=3pt] {$ 1 $} node[above=3pt] {$\begin{turn}{45}
All individuals vote
\end{turn}$};
\draw (-3,0) node[below=3pt] {$ 2 $} node[above=3pt] {$\begin{turn}{45}
Policy vector decided
\end{turn}$};
\draw (-2,0) node[below=3pt] {$ 3 $} node[above=3pt] {$\begin{turn}{45} Becoming a bureaucrat \end{turn} $};
\draw (-1,0) node[below=3pt] {$ 4 $} node[above=3pt] {$\begin{turn}{45} Bureaucrats' effort choice \end{turn}$};
\draw (0,0) node[below=3pt] {$ 5 $} node[above=3pt] {$\begin{turn}{45} Tax evasion decision made \end{turn}$};
\draw (1,0) node[below=3pt] {$ 6$} node[above=3pt] {$\begin{turn}{45} $p(x_{t})$ tax evaders caught \end{turn}$};
\draw (2,0) node[below=3pt] {$ 7 $} node[above=3pt] {$\begin{turn}{45} $q_{t}$ shirking bureaucrats \end{turn}$};
\draw (3,0) node[below=3pt] {$ $} node[above=3pt] {$\begin{turn}{45} Public service provided \end{turn} $};
\end{tikzpicture}
\end{center}
\end{document}
Dłuższe teksty nie są niestety dozwolone. Będzie to wyglądało tak:
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2021-01-11 15:02:56