有人能解释如何使用 chronology.sty 或提供一些实时(有用)文档的链接吗?
更详细地说:我正在为我的学术论文制定大纲和时间表。我开始https://stackoverflow.com/questions/217834/how-to-create-a-timeline-with-latex我发现 Levi Wiseman 的 chronology.sty 产生了非常接近我想要的输出,但应该在http://tug.org/texlive/Contents/live/texmf-dist/doc/latex/chronology/chronology.pdf不再有效。我尽我所能检查了 chronology.sty 文件,并推断出参数 #1 = 步长、#2 = 年份开始、#3 = 年份停止、#4 = 单位和 #5 = 时间线宽度。但是我似乎无法让我的时间线按预期运行。
我希望我的时间线周期为 2013 年中至 2014 年末的 18 个月,每个月都有大分隔符,每周都有小分隔符。我的“事件”将需要 \decimaldate 精度。我知道该包可能有一些错误,请参阅链接年表随意添加空白。我会通过电子邮件将此请求发送给 Levi Wiseman。
答案1
这是使用不灵活且缓慢的时间线的第一个概念蒂克兹和日期编号,明天我会进一步研究这个问题:
代码
\documentclass[tikz,border=2mm]{standalone}
\usetikzlibrary{arrows}
\usepackage{datenumber}
\usepackage{xifthen}
\begin{document}
\setdatenumber{2013}{06}{19}
% 560 days or 80 weeks until new years eve 2014
\begin{tikzpicture}
\draw[-stealth] (0,0) -- (16,0) -- ++(0.3,0);
% 16cm = 80 weeks --> one week = 0.2cm
\pgfmathsetmacro{\width}{16/560}
\foreach \x in {0,...,80}
{ \draw (\x/5,0) -- (\x/5,-0.05) node[left,rotate=90,font=\tiny] {\thedateday-\thedatemonth-\thedateyear};
\addtocounter{datenumber}{7}
\setdatebynumber{\thedatenumber}
}
\setdatenumber{2013}{06}{19}
\foreach \x in {0,...,560}
{ \ifthenelse{\thedateday = 1}
{ \ifcase\thedatemonth
\or \xdef\monthname{Jan}
\or \xdef\monthname{Feb}
\or \xdef\monthname{Mar}
\or \xdef\monthname{Apr}
\or \xdef\monthname{May}
\or \xdef\monthname{Jun}
\or \xdef\monthname{Jul}
\or \xdef\monthname{Aug}
\or \xdef\monthname{Sep}
\or \xdef\monthname{Oct}
\or \xdef\monthname{Nov}
\or \xdef\monthname{Dec}
\else
\fi
\draw (\x/35,0) -- (\x/35,0.25) node[right,rotate=90,font=\tiny] {\monthname\ \thedateyear};
%\draw (\x/35,0) -- (\x/35,0.25) node[right,rotate=90,font=\tiny] {\thedatemonth \thedateyear};
}{}
\addtocounter{datenumber}{1}
\setdatebynumber{\thedatenumber}
}
\end{tikzpicture}
\end{document}
输出
编辑1:这是一个自动版本,实际上可以进行一些自定义,并且有一个添加条目的命令。还有很大的改进空间,例如,可以将时间线参数合并到命令中\drawtimeline
,键值界面会很好等等。
代码
\documentclass[tikz,border=2mm]{standalone}
\usetikzlibrary{arrows}
\usepackage{datenumber}
\usepackage{xifthen}
% counters for calculating with dates
\newcounter{startdate}
\newcounter{enddate}
\newcounter{tempdate}
\newcounter{dateone}
\newcounter{datetwo}
%
\newcommand{\startenddiff}[6]{%
\setmydatenumber{startdate}{#1}{#2}{#3}%
\setmydatenumber{enddate}{#4}{#5}{#6}%
\setmydatenumber{tempdate}{#4}{#5}{#6}%
\addtocounter{tempdate}{-\thestartdate}%
}
%
\newcommand{\datediff}[6]%
{ \setmydatenumber{dateone}{#1}{#2}{#3}
\setmydatenumber{datetwo}{#4}{#5}{#6}
\addtocounter{dateone}{-\thestartdate}
\addtocounter{datetwo}{-\thestartdate}
}
%
\newcommand{\drawtimeline}%
{ \setdatebynumber{\thestartdate}
\pgfmathtruncatemacro{\numberofdays}{\thetempdate}
\pgfmathsetmacro{\daywidth}{\timelinewidth/\numberofdays}
\draw[-stealth] (0,0) -- (\timelinewidth,0) -- ++(0.3,0);
\foreach \x in {0,...,\numberofdays}
{ \ifthenelse{\thedateday = 1}
{ \ifcase\thedatemonth
\or \xdef\monthname{Jan}
\or \xdef\monthname{Feb}
\or \xdef\monthname{Mar}
\or \xdef\monthname{Apr}
\or \xdef\monthname{May}
\or \xdef\monthname{Jun}
\or \xdef\monthname{Jul}
\or \xdef\monthname{Aug}
\or \xdef\monthname{Sep}
\or \xdef\monthname{Oct}
\or \xdef\monthname{Nov}
\or \xdef\monthname{Dec}
\else
\fi
\draw (\x*\daywidth,0) -- (\x*\daywidth,0.25) node[right,rotate=90,font=\tiny] {\monthname\ \thedateyear};
}{}
\ifthenelse{\equal{\datedayname}{Monday}}
{ \draw (\x*\daywidth,0) -- (\x*\daywidth,-0.05);
}{}
\addtocounter{datenumber}{1}
\setdatebynumber{\thedatenumber}
}
}
\newcommand{\timeentry}[8][gray]% [options] start date, end date, description
{ \datediff{#2}{#3}{#4}{#5}{#6}{#7}
\pgfmathtruncatemacro{\numberofdays}{\thetempdate}
\pgfmathsetmacro{\daywidth}{\timelinewidth/\numberofdays}
\draw[opacity=0.5,line width=1.5mm,line cap=round,#1] (\thedateone*\daywidth,0) -- (\thedatetwo*\daywidth,0) node[left,rotate=60,pos=0.5] {#8};
}
\begin{document}
% ===== user's choices =========================
\startenddiff{2013}{06}{20}{2014}{03}{31}
\pgfmathsetmacro{\timelinewidth}{16}% will be 0.3cm wider for arrow tip
% ==============================================
\begin{tikzpicture}
\drawtimeline
\timeentry{2013}{07}{20}{2013}{08}{01}{Test}
\timeentry{2013}{08}{20}{2013}{09}{01}{Test}
\timeentry{2013}{09}{20}{2013}{10}{01}{Test}
\timeentry{2013}{10}{20}{2013}{11}{01}{Test}
\timeentry{2013}{11}{20}{2013}{12}{01}{Test}
\end{tikzpicture}
% ===== user's choices =========================
\startenddiff{2013}{07}{01}{2013}{10}{01}
\pgfmathsetmacro{\timelinewidth}{10}% will be 0.3cm wider for arrow tip
% ==============================================
\begin{tikzpicture}
\drawtimeline
\timeentry[red,text opacity=1]{2013}{08}{14}{2013}{08}{19}{Test}
\timeentry[blue]{2013}{07}{08}{2013}{07}{15}{Test 2}
\end{tikzpicture}
% ===== user's choices =========================
\startenddiff{2013}{07}{01}{2014}{12}{31}
\pgfmathsetmacro{\timelinewidth}{20}% will be 0.3cm wider for arrow tip
% ==============================================
\begin{tikzpicture}
\drawtimeline
\timeentry[red!5]{2013}{07}{10}{2013}{08}{1}{Test}
\timeentry[red!10]{2013}{08}{10}{2013}{09}{1}{Test}
\timeentry[red!15]{2013}{09}{10}{2013}{10}{1}{Test}
\timeentry[red!20]{2013}{10}{10}{2013}{11}{1}{Test}
\timeentry[red!25]{2013}{11}{10}{2013}{12}{1}{Test}
\timeentry[red!30]{2013}{12}{10}{2014}{01}{1}{Test}
\timeentry[red!35]{2014}{01}{10}{2014}{02}{1}{Test}
\timeentry[red!40]{2014}{02}{10}{2014}{03}{1}{Test}
\timeentry[red!45]{2014}{03}{10}{2014}{04}{1}{Test}
\timeentry[red!50]{2014}{04}{10}{2014}{05}{1}{Test}
\timeentry[red!55]{2014}{05}{10}{2014}{06}{1}{Test}
\timeentry[red!60]{2014}{06}{10}{2014}{07}{1}{Test}
\timeentry[red!65]{2014}{07}{10}{2014}{08}{1}{Test}
\timeentry[red!70]{2014}{08}{10}{2014}{09}{1}{Test}
\timeentry[red!75]{2014}{09}{10}{2014}{10}{1}{Test}
\timeentry[red!80]{2014}{10}{10}{2014}{11}{1}{Test}
\timeentry[red!85]{2014}{11}{10}{2014}{12}{1}{Test}
\timeentry[red!90]{2014}{12}{10}{2015}{01}{1}{Test}
\end{tikzpicture}
\end{document}