Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
    
Do you just need the timeline (I mean, would it be valid to produce the timeline without the chronology package) or are you planning to use other features from the chronology package? –  Gonzalo Medina Feb 19 at 13:42
    
I'm planning to add a couple of events and time ranges. So yes, I need the chronology package. –  RoflcoptrException Feb 19 at 13:43
    
the phrase "where is year should be a major tick": do you mean "where each year should be a major tick"? –  Willie Wong Feb 19 at 14:45
    
Yes, I'm going to change taht. –  RoflcoptrException Feb 19 at 17:35
add comment

1 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

share|improve this answer
1  
Could you write, whether the original package is able to do this or not(and thereby justifying your hard work:o) –  Hans-Peter E. Kristiansen Feb 19 at 15:06
    
@Hans-PeterE.Kristiansen done! :) –  Gonzalo Medina Feb 19 at 15:08
    
Sounds great. When I compile your code I get the following error: ! Undefined control sequence. \reserved@c ->\chronology@starfalse \markschronology@i * l.70 \noindent\begin{markschronology}[ 1]{2010}{2016}{\textwidth} ? –  RoflcoptrException Feb 19 at 17:42
    
@RoflcoptrException Are you using updated versions of the packages? If you compile just my example code exactly as it is, do you still get the same error message? –  Gonzalo Medina Feb 19 at 18:01
    
@GonzaloMedina That's exactly what I did, I copied all your code and compiled it. –  RoflcoptrException Feb 19 at 18:34
show 4 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.