我想减少时间线包 chronosys 中事件日期和事件文本之间的空间

我想减少时间线包 chronosys 中事件日期和事件文本之间的空间

我的代码

\documentclass[10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{chronosys}
\usepackage{geometry}

\begin{document}


\startchronology[startyear=-3000,stopyear=-2000, startdate=false, color=blue!40, stopdate=false, arrow=true, height=3pt]
\setupchronoevent{textstyle=\scriptsize,datestyle=\scriptsize}
\chronograduation[event]{100}
\chronoevent[markdepth=60pt]{-2080}{IM15 (C)}
\chronoevent[markdepth=-80pt]{-2115}{IM13 (C)}
\chronoevent[markdepth=20pt]{-2115}{IM26 (B)}
\chronoevent[markdepth=100pt]{-2170}{IM20 (B)} 
\chronoevent[markdepth=-120pt]{-2190}{IIIM76 (E)}
\chronoevent[markdepth=70pt]{-2200}{IIIM353 (C)}
\chronoevent[markdepth=30pt]{-2245}{IIM69 (C)}
\chronoevent[markdepth=-70pt]{-2250}{IIM281 (C)}
\chronoevent[markdepth=-50pt]{-2145}{IM10 (B)}
\chronoevent[markdepth=-30pt]{-2240}{IIM163 (C)}
\chronoevent[markdepth=-70pt]{-2475}{IM90 (C)}
\chronoevent[markdepth=20pt]{-2480}{IM90 (B)}
\chronoevent[markdepth=-20pt]{-2500}{IIM63 (C)}
\chronoevent[markdepth=70pt]{-2550}{IM21 (A)}
\chronoevent[markdepth=-50pt]{-2570}{IM163 (B)}
\chronoevent[markdepth=30pt]{-2620}{IIM13 (C)}
\chronoevent[markdepth=-40pt]{-2690}{IM5 (B)}
\chronoevent[markdepth=40pt]{-2760}{IM130 (B)}
\chronoevent[markdepth=-15pt]{-2770}{IM65 (C)}
\chronoevent{-2935}{IM157 (B)}
\stopchronology
\end{document}

结果是:

在此处输入图片描述

我的问题:如何减少事件日期和文本之间的间距?

\chronoperiode可以让它像这样工作

\chronoperiode[dateselevation=12pt]{-3000}{-2500}{blablabla}

但这不适用于\chronoevent

答案1

您必须手动更新\dochronoevent宏,因为它是在不同的类别代码设置下构建的:

在此处输入图片描述

\documentclass{article}

\usepackage{chronosys}

\begingroup
\makeatletter
\catcode`\!=11%

\gdef\dochronoevent[#1]#2#3{%
\if!chronearg \!chrtraitingargvirgule{#1}{!chr@event}\fi
% % %
\csname !chreventbarre\!chr@eventbarre\endcsname 
\csname !chreventmark\!chr@eventmark\endcsname 
\csname !chreventdate\!chr@eventdate\endcsname
\csname !chreventconversionmonth\!chr@eventconversionmonth\endcsname 
\csname !chreventyear\!chr@eventyear\endcsname
\csname !chreventifcolorbox\!chr@eventifcolorbox\endcsname
\!chreventmarkdepth\!chr@eventmarkdepth 
\!chreventiconheight\!chr@eventiconheight
\ifx\!chr@eventtextwidth\!chreventdefaulttesttextwidth 
   \!chrperiodeventtextwidth=-1pt%
\else \!chrperiodeventtextwidth\!chr@eventtextwidth
\fi
\ifdim\!chreventmarkdepth<\z@\relax
  \!chreventlocationuptrue
\else
  \!chreventlocationupfalse
\fi
% % % Evaluation de la precision de la date de l'evenement
\!chreventevalspecification{#2}%
\ifnum\count@<4\relax
  \ifcase\count@
    \or \!chreventspecifieddayfalse\!chreventspecifiedmonthfalse 
        \edef\!chreventyear{\csname !chreventspecifiedargument1\endcsname}%
    \or \!chreventspecifieddayfalse\!chreventspecifiedmonthtrue
        \edef\!chreventyear{\csname !chreventspecifiedargument2\endcsname}%
        \edef\!chreventmonth{\csname !chreventspecifiedargument1\endcsname}%
    \or \!chreventspecifieddaytrue\!chreventspecifiedmonthtrue
        \edef\!chreventyear{\csname !chreventspecifiedargument3\endcsname}%
        \edef\!chreventmonth{\csname !chreventspecifiedargument2\endcsname}%
        \edef\!chreventday{\csname !chreventspecifiedargument1\endcsname}%
  \fi %
% %On s'assure que les dates sont bien comprises dans les bornes
\ifnum\!chreventyear>\numexpr\!chrstartyear-1\relax
\ifnum\!chreventyear<\numexpr\!chrstopyear+1\relax
      \if!chreventspecifiedmonth
        \if!chreventspecifiedday 
          \count@\numexpr\!chreventday+\!chreventmonth*30\relax
        \else %
          \count@\numexpr\!chreventmonth*30\relax
        \fi
      \else \count@\z@
      \fi %
      \!chr!dimentraitement\dimexpr(\!chr!unitperyear)/365*\count@\relax%
     \count@\numexpr\!chreventyear-\!chrstartyear\relax 
     \advance\!chr!dimentraitement\dimexpr\count@\!chr!unitperyear\relax
% % % Affichage
     \dimen@i\wd\!chrflechebox
     \setbox\!chrflechebox\hbox{%
       \unhbox\!chrflechebox\kern-\dimen@i\kern\!chr!dimentraitement
       \if!chreventbarre
        \begingroup{%
        \!chrusecolor{black}%
        \kern-0.4pt\relax\vrule width0.4pt height\!chrheight depth\z@\relax
        }%
        \endgroup
       \fi
       \kern-0.4pt\raise\!chreventiconheight \hbox to\z@{\hss\!chr@eventicon\hss}%
       \lower\dimexpr\!chreventmarkdepth+2pt\relax
       \hbox to\z@{%
         \vbox to\z@{%
           \if!chreventlocationup\relax\vss\fi
           \if!chreventdate\hbox to\z@{%
             \hss \if!chreventifcolorbox \expandafter\!chreventcolorbox\fi
             {\!chr@eventdatestyle{%
               \if!chreventspecifiedday %
                 {\!chr@eventdatesstyle{\!chreventday}}\!chr@eventdatesseparation
               \fi
             {\!chr@eventdatesstyle{%
               \if!chreventspecifiedmonth 
                 \if!chreventconversionmonth\expandafter \chron@selectmonth
                 \fi 
                 \!chreventmonth
               \fi
               }%
             }%
             \if!chreventspecifiedmonth\if!chreventyear \!chr@eventdatesseparation\fi\fi 
             \if!chreventyear{\!chr@eventdatesstyle{\!chreventyear}}\fi%
             }}%
             \hss
           }%
           \fi
           \vspace{-3pt}% <------------------------- Reduce gap between date/title
           \ifdim\!chrperiodeventtextwidth > \z@ 
             \hbox to\z@{%
               \hss\setbox\z@\hbox{%
                 \vbox{%
                   \hsize\!chrperiodeventtextwidth\relax\!chr@eventtextstyle{#3}%
                   \vskip1pt\relax
                 }%
               }%
               \dimen@i\dimexpr\wd\z@+4pt\relax
               \dimen@ii\dimexpr\ht\z@+\dp\z@+2pt\relax
               \setbox\z@\hbox to\z@{%
                 \hss\begingroup{\!chrusecolor{\!chr@eventcolorbox}\vrule height\dimen@ii width\dimen@i depth2pt\relax}\endgroup \kern-\dimen@i\kern2pt\relax%
                 \box\z@\hss
               }%
               \box\z@
             }%
           \else 
             \hbox to\z@{%
               \hss\if!chreventifcolorbox\expandafter\!chreventcolorbox\fi{%
               \!chr@eventtextstyle{#3}}\hss
             }%
           \fi 
           \unless\if!chreventlocationup\relax\vss\fi
         }%
       }%
       \if!chreventmark
         \if!chreventlocationup\relax
         %\!chrstarttikzpicture \!chrdraw(0,0)--(0,\the\!chreventmarkdepth+5pt);\!chrstoptikzpicture
           \vrule height\dimexpr-\!chreventmarkdepth-5pt\relax depth\z@ \kern-0.4pt\relax
         \else \vrule height\z@ depth\!chreventmarkdepth
         \fi
         \kern-0.4pt\relax
       \fi  
       \setbox0\vbox{%
         \if!chreventdate
           \hbox{#2}%
         \fi
         \hbox{%
          \ifdim\!chrperiodeventtextwidth > \z@ 
            \vbox {%
             \hsize\!chrperiodeventtextwidth #3%
            }%
          \else #3%
          \fi 
         }%
       }%
      \begingroup\dimen@\dimexpr\dp0+\ht0+2pt\relax
      \dimen@i\dimexpr\dimen@-\!chreventmarkdepth\relax
      \if!chreventlocationup
        \ifdim \dimen@i >\!chrskipbefore \global\!chrskipbefore\dimen@i \fi
      \else
        \ifdim \dimen@ >\!chrskipafter \global\!chrskipafter\dimen@ \fi
      \fi
      \endgroup
    }%
\fi\fi\fi}%

\endgroup

\begin{document}

\startchronology[startyear=-3000,stopyear=-2000, startdate=false, color=blue!40, stopdate=false, arrow=true, height=3pt]
  \setupchronoevent{textstyle=\scriptsize,datestyle=\scriptsize}
  \chronograduation[event]{100}
  \chronoevent[markdepth=60pt]{-2080}{IM15 (C)}
  \chronoevent[markdepth=-80pt]{-2115}{IM13 (C)}
  \chronoevent[markdepth=20pt]{-2115}{IM26 (B)}
  \chronoevent[markdepth=100pt]{-2170}{IM20 (B)} 
  \chronoevent[markdepth=-120pt]{-2190}{IIIM76 (E)}
  \chronoevent[markdepth=70pt]{-2200}{IIIM353 (C)}
  \chronoevent[markdepth=30pt]{-2245}{IIM69 (C)}
  \chronoevent[markdepth=-70pt]{-2250}{IIM281 (C)}
  \chronoevent[markdepth=-50pt]{-2145}{IM10 (B)}
  \chronoevent[markdepth=-30pt]{-2240}{IIM163 (C)}
  \chronoevent[markdepth=-70pt]{-2475}{IM90 (C)}
  \chronoevent[markdepth=20pt]{-2480}{IM90 (B)}
  \chronoevent[markdepth=-20pt]{-2500}{IIM63 (C)}
  \chronoevent[markdepth=70pt]{-2550}{IM21 (A)}
  \chronoevent[markdepth=-50pt]{-2570}{IM163 (B)}
  \chronoevent[markdepth=30pt]{-2620}{IIM13 (C)}
  \chronoevent[markdepth=-40pt]{-2690}{IM5 (B)}
  \chronoevent[markdepth=40pt]{-2760}{IM130 (B)}
  \chronoevent[markdepth=-15pt]{-2770}{IM65 (C)}
  \chronoevent{-2935}{IM157 (B)}
\stopchronology

\end{document}

我在上面的代码中突出显示了日期/标题之间添加的负垂直间隙:\vspace{-3pt}提供了足够的减少而不会导致框背景重叠。

答案2

chronos 的当前版本可在以下位置获得:
https://tex.stackexchange.com/a/342699/ (2016年12月6日)

chronosys以下是使用增强版代码的替代方案这个答案这个答案

编辑该代码已进一步改编为这个答案

编辑 编辑现在可以自定义事件中显示的日期格式,具体说明如下这个答案

这样做的好处是,它比 更容易修改chronosys。外观可以根据您的喜好进行调整。这是基于chronosys您发布的版本的版本。它显示了日期和事件描述之间的缩小间距。

chronos 替代品

本质上,序言很长,因为它复制了chronosys使用 PGF/TikZ 的相关部分,特别着眼于使代码灵活且易于定制。完成后,时间线本身可以绘制如下。

\begin{tikzpicture}
  [

开始tikzpicture准备指定一些选项。

    chronos={%

这将触发时间线配置。如果为 指定了值chronos,它将应用请求的设置。如果没有,它将使用默认值。

      timeline width=120mm,
      timeline height=3pt,

主时间线的宽度和高度。

      start date={-3000}-01-01,
      end date={-2000}-01-01,

ISO 格式的开始和结束日期。年份必须用花括号括起来,以免解析器将负号误认为破折号。

      events/.append style={font=\scriptsize},

这会添加到默认events样式。events设置单日期和时间扩展事件的样式。如果需要,可以使用例如分别自定义每个样式。

      period event/.append style={<keys for extended events>},
      event/.append style={<keys for single-date events>},

这里不需要这个,因为无论如何我们都不需要任何时间延长的事件。

      timeline year={font=\tiny},

附加键可用于自定义时间线上标记年份的节点的外观。

      timeline line={blue!40, shorten >=-20mm, -{Triangle Cap[length=20mm]}},

这设置了主时间线的样式。

      only years,

默认情况下,代码假定事件日期是完全确定的,即YYYY-MM-DD。由于我们只有年份,我们将告诉 TikZ,这样我们就不必-MM-DD每次指定日期时都手动添加虚拟日期。

      step years=100,

默认情况下,代码会尝试标记时间轴上的每一年。对于 A4 来说,1000 年太多了,因此我们将使用稍大一些的步骤。

      timeline years=below,

默认情况下,年份写在时间轴上方。此设置将其放在下方。

      timeline marks,

这会在主时间线和包含年份的节点之间创建小线。

    }
  ]

如果我们愿意,我们可以使用以下键进一步自定义该行

      lines/.append style={<keys for lines drawn to events>},
      event line/.append style={<keys for lines drawn to one-day events>},
      period event line/.append style={<keys for lines drawn to temporally extended events>},
      period/.append style={<keys for marking extended events on the timeline itself>},
      timeline mark={<additional keys to customise appearance of lines drawn from timeline to years>},
      background={<colour of page>},
      timeline border inner colour=<colour for shaded border>,
      timeline border outer colour=<other colour for shading>,
      timeline border height=<height for shaded border>,
      timeline no years,
      event years on line,

背景颜色默认设置为white。这会影响包含事件日期和文本以及时间线上年份的节点的默认外观。

如果您希望从头开始配置,当然可以使用.style而不是.append style

回到我们的时间线,我们准备添加一些事件。

代码提供了两个命令,用于将单日和时间延长的事件添加到时间线。

  • \chronosevent [<options for event line>] {<date>} [<options for event node>] {<text>} (<distance of event node from timeline>)

  • \chronosperiod [<options for line marking period on timeline>] [<start date>] [<options for period event line>] {<end date>} [<options for period event node>] {<text>} (<distance of period event node from timeline>)

\chronosevent扩展语法和其姊妹命令的示例,\chronosperiod包括在我之前的回答。尽管我为了适应您的时间表而改变了实现方式,但是命令的语法保持不变。

此外,

  • \chronosspecialdate{<text>}可用于将下一个日期或年份替换\chronosevent为其他名称。例如,\chronosspecialdate{Christmas} \chronosevent{1123-12-25}{Merriment}

我们的情况很简单。我们正在一致地格式化事件,因此我们不需要可选参数来自定义每个事件的外观。由于我们只有一天的事件,所以这就\chronosevent足够了,我们不需要自定义除时间线偏移之外的任何东西,我们可以简单地使用

\chronosevent {<year>}{<text>}(<dimension>}

如下

  \chronosevent {-2080}{IM15 (C)}(60pt)
  \chronosevent {-2115}{IM13 (C)}(-80pt)
  \chronosevent {-2115}{IM26 (B)}(20pt)
  \chronosevent {-2170}{IM20 (B)}(100pt)
  \chronosevent {-2190}{IIIM76 (E)}(-120pt)
  \chronosevent {-2200}{IIIM353 (C)}(70pt)
  \chronosevent {-2245}{IIM69 (C)}(30pt)
  \chronosevent {-2250}{IIM281 (C)}(-70pt)
  \chronosevent {-2145}{IM10 (B)}(-50pt)
  \chronosevent {-2240}{IIM163 (C)}(-30pt)
  \chronosevent {-2475}{IM90 (C)}(-70pt)
  \chronosevent {-2480}{IM90 (B)}(20pt)
  \chronosevent {-2500}{IIM63 (C)}(-20pt)
  \chronosevent {-2550}{IM21 (A)}(70pt)
  \chronosevent {-2570}{IM163 (B)}(-50pt)
  \chronosevent {-2620}{IIM13 (C)}(30pt)
  \chronosevent {-2690}{IM5 (B)}(-40pt)
  \chronosevent {-2760}{IM130 (B)}(40pt)
  \chronosevent {-2770}{IM65 (C)}(-15pt)
  \chronosevent {-2935}{IM157 (R)}

就这些

\end{tikzpicture}

因此我们关闭tikzpicture环境以完成。

代码:

\pdfminorversion=7
\documentclass[border=10pt,multi,tikz,svgnames,HTML,rgb]{standalone}
\usepackage{pgfcalendar}
\usepackage{datenumber,xparse,fp}
\usetikzlibrary{arrows.meta,backgrounds,fixedpointarithmetic}
\makeatletter
\ExplSyntaxOn
\tl_new:N \l_chronos_dateformat_tl
\tl_set:Nn \l_chronos_dateformat_tl { Y/m/d }
% YY yn lle YYYY
\cs_new_protected_nopar:Npn \chronos_year_shorten:n #1
{
  \chronos_year_shorten_aux:w #1 \q_stop % expl3 manuaal, 46
}
\cs_new_protected_nopar:Npn \chronos_year_shorten_aux:w #1 #2 #3 #4 \q_stop
{
  #3 #4
}
\cs_generate_variant:Nn \chronos_year_shorten:n { V , c }
% dangos dyddiadau
\cs_new_protected_nopar:Npn \chronos_show_date:n #1
{
  \tl_map_inline:Nn \l_chronos_dateformat_tl
  {
    \str_case:nnF { ##1 }
    {
      { a } { \pgfcalendarweekdayshortname{\thechronos@weekday} }
      { A } { \pgfcalendarweekdayname{\thechronos@weekday} }
      { b } { \pgfcalendarmonthshortname{\csname chronos@#1month\endcsname} }
      { B } { \pgfcalendarmonthname{\csname chronos@#1month\endcsname} }
      { d } { \csname chronos@#1day\endcsname }
      { m } { \csname chronos@#1month\endcsname }
      { y } { \chronos_year_shorten:c { chronos@#1year } }
      { Y } { \csname chronos@#1year\endcsname }
      { @ } { ~ }
    }
    {
      ##1
    }
  }
}
% user interface
\NewDocumentCommand \chronossetdateformat { m }
{
  \tl_set:Nn \l_chronos_dateformat_tl { #1 }
  \tl_replace_all:Nnn \l_chronos_dateformat_tl { ~ } { @ }
}
% for pgf/tikz convenience
\NewDocumentCommand \chronos@showdate { m }
{
  \pgfcalendarjuliantoweekday{\csname thechronos@#1date\endcsname}{\c@chronos@weekday}%
  \chronos_show_date:n { #1 }
}
\ExplSyntaxOff
\newcounter{chronos@date}
\newcounter{chronos@startdate}
\newcounter{chronos@enddate}
\newcounter{chronos@startyear}
\newcounter{chronos@endyear}
\newcounter{chronos@yeardate}
\newcounter{chronos@thingdate}
\newcounter{chronos@otherthingdate}
\newcounter{chronos@weekday}
\newif\ifchronos@marks
\chronos@marksfalse
\newif\ifchronos@timeline@showyears
\chronos@timeline@showyearstrue
\newif\ifchronos@eventyearsonline
\chronos@eventyearsonlinefalse
\pgfkeys{/pgf/number format,
  int detect,
  set thousands separator={},
}
\tikzset{%
  /handlers/.chronos too/.code={%
    \edef\chronos@tempc{\pgfkeyscurrentpath}%
    \edef\chronos@tempd{#1}%
    \tikzset{%
      \pgfkeyscurrentpath @too/.code={%
        \tikzset{%
          /chronos/\chronos@tempd/.append style={##1},
        }%
      },
      \chronos@tempc/.forward to=\chronos@tempc @too,
    }%
  },
  chronos/.code={% https://tex.stackexchange.com/a/159856/ - Claudio Fiandrino
    \tikzset{%
      align=center,
      anchor=mid,
      fixed point arithmetic,
      /chronos/.cd,
      #1,
    }%
    \pgfmathsetmacro\chronos@unit{(\chronos@width-20pt)/(\thechronos@enddate-\thechronos@startdate)}%
    \draw [/chronos/timeline@line, line width=\chronos@height] (-10pt,0) coordinate (chronos pre) -- +(\chronos@width,0) coordinate (chronos post);
    \coordinate (chronos base) at (0,-.5*\chronos@height);
    \coordinate (chronos top) at (0,.5*\chronos@height);
    \coordinate (chronos foot) at (0,{-.5*\chronos@height-\chronos@borderheight});
    \coordinate (chronos head) at (0,{.5*\chronos@height+\chronos@borderheight});
    \coordinate (chronos start) at (0,0);
    \coordinate (chronos end) at ([xshift=-10pt]chronos post);
    \ifdim\chronos@borderheight>0pt
      \fill [bottom color=chronos@borderinner, top color=chronos@borderouter] (chronos pre |- chronos head) rectangle (chronos post |- chronos top);
      \fill [top color=chronos@borderinner, bottom color=chronos@borderouter] (chronos pre |- chronos base) rectangle (chronos post |- chronos foot);
    \fi
    \ifchronos@timeline@showyears
      \pgfmathsetcounter{chronos@startyear}{\chronos@startyear}%
      \pgfmathsetcounter{chronos@endyear}{\chronos@endyear}%
      \def\tempa{none}%
      \ifx\chronos@stepfrom\tempa
        \def\tempa{01}%
        \ifx\chronos@startmonth\tempa
          \ifx\chronos@startday\tempa
            \else\stepcounter{chronos@startyear}%
          \fi
          \else\stepcounter{chronos@startyear}%
        \fi
      \else
        \pgfmathsetcounter{chronos@startyear}{\chronos@stepfrom}%
      \fi
      \def\tempa{12}%
      \def\tempb{31}%
      \ifx\chronos@endmonth\tempa
        \ifx\chronos@endday\tempb
          \stepcounter{chronos@endyear}%
        \fi
      \fi
      \pgfmathsetmacro\chronos@nextstep{int(\thechronos@startyear+\chronos@stepyears)}%
      \foreach \i in {\thechronos@startyear,\chronos@nextstep,...,\thechronos@endyear} {%
        \pgfcalendardatetojulian{{\i}-01-01}{\c@chronos@yeardate}%
        \pgfmathsetmacro\chronos@tempa{(\thechronos@yeardate-\thechronos@startdate)*\chronos@unit}%
        \def\tempa{on line}%
        \ifx\tempa\chronos@timelineyears
          \node (chronos@year@\i) [/chronos/.cd, timeline@years, timeline year on line] at (\chronos@tempa pt,0) {\i};
          \ifchronos@marks
             \path [/chronos/timeline mark on line] (chronos@year@\i.south) -- (chronos@year@\i |- chronos base);
             \path [/chronos/timeline mark on line] (chronos@year@\i.north) --  (chronos@year@\i |- chronos top);
          \fi
        \else
          \node (chronos@year@\i) [/chronos/.cd, timeline@years, timeline year off line] at (\chronos@tempa pt,0) {\i};
          \ifchronos@marks
            \path [shorten <=.5*\chronos@height, /chronos/timeline mark off line] (\chronos@tempa pt, 0) -- (chronos@year@\i);
          \fi
        \fi
      }%
    \fi
    \ifchronos@eventyearsonline
    \tikzset{%
      /chronos/timeline years=on line,
    }%
    \fi
  },
  chronos set date/.code args={#1:#2:#3:#4}{%
    \pgfcalendardatetojulian{{#1}-#2-#3}{\c@chronos@date}%
    \setcounter{chronos@#4date}{\thechronos@date}%
    \expandafter\def\csname chronos@#4year\endcsname{#1}%
    \expandafter\def\csname chronos@#4month\endcsname{#2}%
    \expandafter\def\csname chronos@#4day\endcsname{#3}%
  },
  chronos date/.style args={#1-#2-#3}{%
    /tikz/chronos set date/.expanded={#1:#2:#3:thing}%
  },
  chronos period date/.style args={#1-#2-#3}{%
    /tikz/chronos set date/.expanded={#1:#2:#3:otherthing}%
  },
  /chronos/.search also={/tikz},
  /chronos/.cd,
  step years/.store in=\chronos@stepyears,
  step from year/.store in=\chronos@stepfrom,
  start date/.style args={#1-#2-#3}{%
    /tikz/chronos set date/.expanded={#1:#2:#3:start},
  },
  end date/.style args={#1-#2-#3}{%
    /tikz/chronos set date/.expanded={#1:#2:#3:end},
  },
  timeline width/.store in=\chronos@width,
  timeline height/.store in=\chronos@height,
  width/.forward to=/chronos/timeline width,
  height/.forward to=/chronos/timeline height,
  timeline border height/.store in=\chronos@borderheight,
  timeline border inner colour/.code={\colorlet{chronos@borderinner}{#1}},
  timeline border outer colour/.code={\colorlet{chronos@borderouter}{#1}},
  timeline years set/.store in=\chronos@timelineyears,
  timeline years/.is choice,
  timeline years/.forward to=/chronos/timeline years set,
  timeline years/above/.code={%
    \tikzset{%
      /chronos/timeline@years/.style={above, anchor=south, yshift=.5*\chronos@height},
    }%
  },
  timeline years/below/.code={%
    \tikzset{%
      /chronos/timeline@years/.style={below, anchor=north, yshift=-.5*\chronos@height},
    }%
  },
  timeline years/on line/.code={%
    \tikzset{%
      /chronos/timeline@years/.style={anchor=center},
    }%
  },
  only years/.code={%
    \chronossetdateformat{Y}%
    \tikzset{%
      /tikz/chronos date/.style={%
        /tikz/chronos set date/.expanded={##1:01:01:thing}%
      },
      /tikz/chronos period date/.style={%
        /tikz/chronos set date/.expanded={##1:01:01:otherthing}%
      },
    }%
  },
  only text/.code={%
    \tikzset{/chronos/only years}%
    \chronossetdateformat{}%
  },
  background/.code={%
    \colorlet{chronos@background}{#1}%
  },
  timeline marks/.is if=chronos@marks,
  timeline show years/.is if=chronos@timeline@showyears,
  timeline no years/.code={%
    \tikzset{%
      /chronos/timeline show years=false,
    }%
  },
  lines/.style={draw, {Triangle[width=0pt 3,reversed,length=0pt 1.5]}-{Triangle[width=0pt 3,reversed,length=0pt 1.5]}, shorten <={.5*\chronos@height}},
  events/.style={fill=chronos@background, fill opacity=.75, text opacity=1, draw opacity=1, rounded corners, align=center, font=\footnotesize},
  period/.style={draw},
  period event line/.style={/chronos/lines},
  period event/.style={/chronos/events},
  event line/.style={/chronos/lines},
  event/.style={/chronos/events},
  event years on line/.is if=chronos@eventyearsonline,
  event year on line/.style={/chronos/timeline@years, /chronos/timeline year on line},
  special date/.store in=\chronos@specialdate,
  timeline@line/.style={draw},
  timeline line/.chronos too=timeline@line,
  timeline year off line/.style={fill=chronos@background, text opacity=1, fill opacity=.75},
  timeline mark off line/.style={draw, {Triangle[width=0pt 3,reversed,length=0pt 1.5]}-, thin, shorten >=-2pt},
  timeline year on line/.style={text=chronos@background, inner sep=1pt},
  timeline mark on line/.style={draw=chronos@background, shorten >=1.5pt},
  timeline mark too/.code={%
    \tikzset{%
      /chronos/.cd,
      timeline mark on line/.append style={#1},
      timeline mark off line/.append style={#1},
    }%
  },
  timeline year too/.code={%
    \tikzset{%
      /chronos/.cd,
      timeline year on line/.append style={#1},
      timeline year off line/.append style={#1},
    }%
  },
  timeline mark/.forward to=/chronos/timeline mark too,
  timeline year/.forward to=/chronos/timeline year too,
  start date=1001-10-01,
  end date=1003-06-14,
  timeline width=100mm,
  timeline height=1pt,
  timeline border height=0pt,
  chronos date=1850-01-01,
  chronos period date=1851-01-01,
  step years=1,
  timeline years=above,
  background=white,
  timeline border inner colour=black,
  timeline border outer colour=chronos@background,
  step from year=none,
  special date=none,
}
\NewDocumentCommand \chronosevent { O {} m O {} +m D () { -10pt } }
{%
  \tikzset{%
    chronos date/.expanded={#2},
  }5
  \pgfmathsetmacro\chronos@offset{(#5 < 0pt) ? (#5-.5*\[email protected]*\chronos@borderheight) : (#5+.5*\chronos@height+.5*\chronos@borderheight)}%
  \pgfmathsetmacro\chronos@anchor{(#5 < 0pt) ? "north" : "south"}%
  \scoped[on background layer]{\path [postaction={/chronos/event line, #1}] ({(\thechronos@thingdate-\thechronos@startdate)*\chronos@unit pt},0) -- +(0,\chronos@offset pt) node [anchor=\chronos@anchor, /chronos/event, #3] {\chronos@showdate{thing}\\#4};}
  \ifchronos@eventyearsonline
    \edef\tempa{none}%
    \edef\tempb{\chronos@specialdate}%
    \ifx\tempa\tempb\else\let\chronos@thingyear\chronos@specialdate\tikzset{/chronos/special date=none}\fi
    \node [/chronos/.cd, event year on line] at ({(\thechronos@thingdate-\thechronos@startdate)*\chronos@unit pt},0) {\chronos@thingyear};
  \fi
}
\NewDocumentCommand \chronosspecialdate { m }
{%
  \tikzset{%
    /chronos/special date=#1,
  }%
}
\NewDocumentCommand \chronosperiod { O {} m O {} m O {} +m D () { -10pt } }
{%
  \tikzset{%
    chronos date/.expanded={#2}, chronos period date/.expanded={#4}
  }%
  \pgfmathsetmacro\chronos@offset{(#7 < 0pt) ? (#7-.5*\[email protected]*\chronos@borderheight) : (#7+.5*\chronos@height+.5*\chronos@borderheight)}%
  \pgfmathsetmacro\chronos@anchor{(#7 < 0pt) ? "north" : "south"}%
  \path [postaction={line width=\chronos@height, /chronos/period, #1}] ({(\thechronos@thingdate-\thechronos@startdate)*\chronos@unit pt},0) -- ({(\thechronos@otherthingdate-\thechronos@startdate)*\chronos@unit pt},0);
  \scoped[on background layer]{\path [postaction={/chronos/period event line, #3}] ({(.5*\thechronos@otherthingdate+.5*\thechronos@thingdate-\thechronos@startdate)*\chronos@unit pt},0) -- +(0,\chronos@offset pt) node [anchor=\chronos@anchor, /chronos/period event, #5] {\chronos@showdate{thing}--\chronos@showdate{otherthing}\\#6};}
}
\makeatother
\begin{document}
\begin{tikzpicture}
  [
    chronos={%
      timeline width=120mm,
      timeline height=3pt,
      start date={-3000}-01-01,
      end date={-2000}-01-01,
      events/.append style={font=\scriptsize},
      timeline year={font=\tiny},
      timeline line={blue!40, shorten >=-20mm, -{Triangle Cap[length=20mm]}},
      only years,
      step years=100,
      timeline years=below,
      timeline marks,
    }
  ]
  \chronosevent {-2080}{IM15 (C)}(60pt)
  \chronosevent {-2115}{IM13 (C)}(-80pt)
  \chronosevent {-2115}{IM26 (B)}(20pt)
  \chronosevent {-2170}{IM20 (B)}(100pt)
  \chronosevent {-2190}{IIIM76 (E)}(-120pt)
  \chronosevent {-2200}{IIIM353 (C)}(70pt)
  \chronosevent {-2245}{IIM69 (C)}(30pt)
  \chronosevent {-2250}{IIM281 (C)}(-70pt)
  \chronosevent {-2145}{IM10 (B)}(-50pt)
  \chronosevent {-2240}{IIM163 (C)}(-30pt)
  \chronosevent {-2475}{IM90 (C)}(-70pt)
  \chronosevent {-2480}{IM90 (B)}(20pt)
  \chronosevent {-2500}{IIM63 (C)}(-20pt)
  \chronosevent {-2550}{IM21 (A)}(70pt)
  \chronosevent {-2570}{IM163 (B)}(-50pt)
  \chronosevent {-2620}{IIM13 (C)}(30pt)
  \chronosevent {-2690}{IM5 (B)}(-40pt)
  \chronosevent {-2760}{IM130 (B)}(40pt)
  \chronosevent {-2770}{IM65 (C)}(-15pt)
  \chronosevent {-2935}{IM157 (R)}
\end{tikzpicture}
\end{document}

相关内容