[Tex/LaTex] How to use chronology package to draw this timeline

chronology

I want to use the chronology package to draw a timeline from 2011 until 2016 where each year should be a major tick and between each major tick, there should be 3 minor ticks.

I tried to implement this like this:

\documentclass{article}
\usepackage{chronology}
\begin{document}
\begin{chronology}[3]{2011}{2016}{3ex}{\textwidth}

\end{chronology}
\end{document}

However, this ends up in a timeline like this:

output

How can I achieve the timeline I want?

Best Answer

The original chronology environment doesn't allow this. Below I defined a markschronology environment which behaves in a similar fashion to chronology (it has the same arguments and it was defined following the original definition) and allows you to specify a number of intermediate ticks; the number of intermediate ticks is controlled by \Marks with default value 0 (i.e., no intermediate ticks):

\documentclass{article}
\usepackage{chronology}

\def\Marks{0}

\makeatletter
\def\@marks{}
\newenvironment{markschronology}
  {%
    \@ifstar{\chronology@startrue\markschronology@i*}  {\chronology@starfalse\markschronology@i*}%
  }
  {%
    \end{tikzpicture}%
    \end{lrbox}%
    \raisebox{2ex}{%
      \resizebox{\timelinewidth}{!}{\usebox{\timelinebox}}%
    }%
  }

\def\markschronology@i*{%
    \@ifnextchar[{\markschronology@ii*}{\markschronology@ii*[{5}]}%
}

\def\markschronology@ii*[#1]#2#3#4{%
    \@ifnextchar[{\markschronology@iii*[{#1}]{#2}{#3}{#4}}{\markschronology@iii*[{#1}]{#2}{#3}{#4}[{#4}]}%
}

\def\markschronology@iii*[#1]#2#3#4[#5]{%
  \newif\ifflipped%
  \ifchronology@star%
    \flippedtrue%
  \else%
    \flippedfalse%
  \fi%
  \setcounter{step}{#1}%
  \setcounter{yearstart}{#2}\setcounter{yearstop}{#3}%
  \setcounter{deltayears}{\theyearstop-\theyearstart}%
  \setlength{\unit}{#5/\thedeltayears}%
  \setlength{\timelinewidth}{#4}%
  \pgfmathsetcounter{stepstart}{\theyearstart+\thestep-mod(\theyearstart,\thestep)}%
  \pgfmathsetcounter{stepstop}{\theyearstop-mod(\theyearstop,\thestep)}%
  \addtocounter{step}{\thestepstart}%
  \begin{lrbox}{\timelinebox}%
  \begin{tikzpicture}[baseline={(current bounding box.north)}]%
    \draw [|->] (0,0) -- (\thedeltayears*\unit+\unit, 0);%
    \foreach \x in {1,...,\thedeltayears}
    {
      \draw[xshift=\x*\unit] (0,-0.1\unit) -- (0,0.1\unit);%
    }
    \pgfmathsetmacro{\@marks}{1+(1/(\Marks+1))}
    \foreach \x in {1,\@marks,...,\thedeltayears}
    {
      \draw[xshift=\x*\unit] (0,-0.05\unit) -- (0,0.05\unit);%
    }
    \addtocounter{deltayears}{1}%
    \foreach \x in {\thestepstart,\thestep,...,\thestepstop}
    {%
      \pgfmathsetlength\xstop{(\x-\theyearstart)*\unit}%
      \ifflipped%
        \node at (\xstop,0) [above=.2\unit] {\x};%
      \else%
        \node at (\xstop,0) [below=.2\unit] {\x};%
      \fi%
    }%
}
\makeatother

\begin{document}

\noindent\begin{markschronology}[1]{2010}{2016}{\textwidth}
\end{markschronology}\par\bigskip

\def\Marks{3}
\noindent\begin{markschronology}[1]{2010}{2016}{\textwidth}
\end{markschronology}\par\bigskip

\def\Marks{5}
\noindent\begin{markschronology}[1]{2010}{2016}{\textwidth}
\end{markschronology}

\end{document}

enter image description here