Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Created documentation and updated README #10

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,17 @@ LaTeX time­line pack­age that al­lows la­belling of events with per-day gran

Version 1.1
Uploaded to GitHub on Mar 12., 2013
Uploaded to CTAN on Apr 4., 2013
Uploaded to CTAN on Apr 4., 2013



Version 1.2 Dominik Wujastyk 2023-08-08

Added a file documentation.dtx that produces rudimentary user documentation and pretty-prints the macro code.

The command-line instructions
```
xelatex chronology.dtx
makeindex -s gind.ist chronology
```
produce the `chronology.pdf` documentation file.
32 changes: 32 additions & 0 deletions chronology.dtx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
% !TeX TS-program = xelatex
%<*driver>
% incremental translation style documentation driver file
% compile this with XeLaTeX
\documentclass[12pt]{article}
\usepackage{doc,
hyperref,
polyglossia,
chronology
}
%
\CodelineIndex
%\PageIndex
%\RecordChanges
%
\setlength\hfuzz{15pt}
\hbadness = 7000

\author{Ben Armacost \and Levi Wiseman \and documentation updated by
Dominik Wujastyk}
\title{\LaTeX\ style file for drawing horizontal timelines}
\date{\today }

\begin{document}
\sloppypar
\maketitle
\tableofcontents
\newpage
\DocInput {chronology.sty}
\end{document}
% say “makeindex -s gind.ist <filename>” to get the index right
%</driver>
Binary file added chronology.pdf
Binary file not shown.
275 changes: 201 additions & 74 deletions chronology.sty
Original file line number Diff line number Diff line change
@@ -1,100 +1,227 @@
% \section{User documentation}
%This package defines the new environment \verb|chronology|. This
% environment contains \verb|\event| commands.
%
% \subsection{Example 1}
% This output:\\
% \begin{figure}[h]
% \centering
%\begin{chronology}[5]{1983}{2010}{10cm}[7cm]
%\event{1984}{\color{blue}{one}}
%\event[1985]{1986}{\small{two}}
%\event{\decimaldate{25}{12}{2001}}{\huge{three}}
%\end{chronology}
%\end{figure}
%
% is produced by this input:
%\begin{verbatim}
% \begin{chronology}[5]{1983}{2010}{10cm}[7cm]
% \event{1984}{\color{blue}{one}}
% \event[1985]{1986}{\small{two}}
% \event{\decimaldate{25}{12}{2001}}{\huge{three}}
% \end{chronology}
% \end{verbatim}
%
% \subsection{Example 2}
%Similarly, this output:\\
%\begin{figure}[h]
% \centering
% \begin{chronology}*[5]{1983}{2010}{10cm}
% \event{1984}{\color{blue}{one}}
% \event[1985]{1986}{\small{two}}
% \event{\decimaldate{25}{12}{2001}}{\huge{three}}
% \end{chronology}
% \end{figure}
%
% Is produced by this input:\\
%
% \begin{verbatim}
% \begin{chronology}*[5]{1983}{2010}{10cm}
% \event{1984}{\color{blue}{one}}
% \event[1985]{1986}{\small{two}}
% \event{\decimaldate{25}{12}{2001}}{\huge{three}}
% \end{chronology}
% \end{verbatim}
%
% \subsection{Example 3}
%And finally, this output:\\
%\begin{figure}[h]
% \centering
% \begin{chronology}[5]{1983}{2010}{10cm}[13cm]
% \event{1984}{\color{blue}{one}}
% \event[1985]{1986}{\small{two}}
% \event{\decimaldate{25}{12}{2001}}{\huge{three}}
%\end{chronology}
%\end{figure}
%
% is produced by this input:
%
%\begin{verbatim}
% \begin{chronology}[5]{1983}{2010}{10cm}[13cm]
% \event{1984}{\color{blue}{one}}
% \event[1985]{1986}{\small{two}}
% \event{\decimaldate{25}{12}{2001}}{\huge{three}}
% \end{chronology}
%\end{verbatim}
%
% \newpage
% \section{Package macros}
% \subsection{Standard package loading}
% \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}%
\ProvidesPackage{chronology}[2015/03/27 v1.1.1 Horizontal timeline]%
\RequirePackage{calc}%
\RequirePackage{tikz}%
\RequirePackage{xparse}%
% Defining counters and lengths
% \end{macrocode}
%
% \subsection{Defining counters and lengths}
% \begin{macrocode}
\newcounter{step}\newcounter{stepstart}\newcounter{stepstop}%
\newcounter{yearstart}\newcounter{yearstop}\newcounter{deltayears}%
\newlength{\xstart}\newlength{\xstop}%
\newlength{\unit}\newlength{\timelinewidth}%
\newlength{\distanceunit}\newlength{\timelinewidth}%
\newsavebox{\timelinebox}%
% Defining TikZ styles for labels and events
% \end{macrocode}
% \subsection{Defining TikZ styles for labels and events}
% \begin{macrocode}
\tikzset{%
,chronevent/.style={fill=black,draw=none,opacity=0.5}
,chronlabel/.style={opacity=1}
,chrontickslabel/.style={chronlabel}
,chroneventlabel/.style={chronlabel}
,eventlabel/.style={chroneventlabel,anchor=south west,yshift=.2\unit,rotate=45}
,flippedeventlabel/.style={chroneventlabel,anchor=north west,yshift=-.2\unit,rotate=-45}
}
% For compatibity with babel. Handling of active characters in TikZ.
,chronevent/.style={fill=black,draw=none,opacity=0.5}
,chronlabel/.style={opacity=1}
,chrontickslabel/.style={chronlabel}
,chroneventlabel/.style={chronlabel}
,eventlabel/.style={chroneventlabel,anchor=south
west,yshift=.2\distanceunit,rotate=45}
,flippedeventlabel/.style={chroneventlabel,anchor=north
west,yshift=-.2\distanceunit,rotate=-45}
}
% \end{macrocode}
% \subsubsection{For compatibity with babel. Handling of active characters in
%TikZ}
% \begin{macrocode}
\tikzset{
handle active characters in code,
handle active characters in nodes
handle active characters in code,
handle active characters in nodes
}
\makeatletter%
% \end{macrocode}
%
% \subsection{The chronology environment macros}
% \begin{environment}{chronology}
% \begin{macrocode}
\newif\ifchronology@star%
\newenvironment{chronology}{%
\@ifstar{\chronology@startrue\chronology@i*}{\chronology@starfalse\chronology@i*}%
\@ifstar{\chronology@startrue\chronology@i*}{\chronology@starfalse\chronology@i*}%
}{%
\end{tikzpicture}%
\end{lrbox}%
\raisebox{2ex}{\resizebox{\timelinewidth}{!}{\usebox{\timelinebox}}}%
\end{tikzpicture}%
\end{lrbox}%
\raisebox{2ex}{\resizebox{\timelinewidth}{!}{\usebox{\timelinebox}}}%
}%
% \end{macrocode}
% \end{environment}
%
% \subsubsection{Starred and unstarred forms and arguments}
%
% \begin{macro}{\chronology@i}
% \begin{macrocode}
\def\chronology@i*{%
\@ifnextchar[{\chronology@ii*}{\chronology@ii*[{5}]}%
\@ifnextchar[{\chronology@ii*}{\chronology@ii*[{5}]}%
}%
% \end{macrocode}
% \end{macro}
% \begin{macro}{\chronology@ii}
% \begin{macrocode}
\def\chronology@ii*[#1]#2#3#4{%
\@ifnextchar[{\chronology@iii*[{#1}]{#2}{#3}{#4}}{\chronology@iii*[{#1}]{#2}{#3}{#4}[{#4}]}%
\@ifnextchar[{\chronology@iii*[{#1}]{#2}{#3}{#4}}
{\chronology@iii*[{#1}]{#2}{#3}{#4}[{#4}]}%
}%
% \end{macrocode}
% \end{macro}
% \begin{macro}{\chronology@iii}
% \begin{macrocode}
\def\chronology@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,-.1\unit) -- (0,.1\unit);%
\addtocounter{deltayears}{1}%
\foreach \x in {\thestepstart,\thestep,...,\thestepstop}{%
\pgfmathsetlength\xstop{(\x-\theyearstart)*\unit}%
\draw[xshift=\xstop] (0,-.3\unit) -- (0,.3\unit);%
\ifflipped%
\node[chrontickslabel] at (\xstop,0) [above=.2\unit] {\x};%
\else%
\node[chrontickslabel] at (\xstop,0) [below=.2\unit] {\x};%
\fi%
}%
\newif\ifflipped%
\ifchronology@star%
\flippedtrue%
\else%
\flippedfalse%
\fi%
%
\setcounter{step}{#1}%
\setcounter{yearstart}{#2}\setcounter{yearstop}{#3}%
\setcounter{deltayears}{\theyearstop-\theyearstart}%
\setlength{\distanceunit}{#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*\distanceunit+\distanceunit, 0);%
%
\foreach \x in {1,...,\thedeltayears}%
\draw[xshift=\x*\distanceunit] (0,-.1\distanceunit) --
(0,.1\distanceunit);%
\addtocounter{deltayears}{1}%
%
\foreach \x in {\thestepstart,\thestep,...,\thestepstop}{%
\pgfmathsetlength\xstop{(\x-\theyearstart)*\distanceunit}%
\draw[xshift=\xstop] (0,-.3\distanceunit) -- (0,.3\distanceunit);%
\ifflipped%
\node[chrontickslabel] at (\xstop,0) [above=.2\distanceunit] {\x};%
\else%
\node[chrontickslabel] at (\xstop,0) [below=.2\distanceunit] {\x};%
\fi%
}%
}%
\makeatother%
\DeclareDocumentCommand \event {o m m}{%
\pgfmathsetlength\xstop{(#2-\theyearstart)*\unit}%
\IfNoValueTF {#1} {%
\ifflipped%
\draw[chronevent]%
(\xstop, 0) circle (.2\unit)%
node[flippedeventlabel] {#3};%
\else%
\draw[chronevent]%
(\xstop, 0) circle (.2\unit)%
node[eventlabel] {#3};%
\fi%
}{%
\pgfmathsetlength\xstart{(#1-\theyearstart)*\unit}%
\ifflipped%
\draw[chronevent,rounded corners=.2\unit]%
(\xstart,-.2\unit) rectangle%
node[flippedeventlabel] {#3} (\xstop,.2\unit);%
\else%
\draw[chronevent,rounded corners=.2\unit]%
(\xstart,-.2\unit) rectangle%
node[eventlabel] {#3} (\xstop,.2\unit);%
\fi%
}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\event}
% \begin{macrocode}
\DeclareDocumentCommand \event {o m m}{%
\pgfmathsetlength\xstop{(#2-\theyearstart)*\distanceunit}%
\IfNoValueTF {#1} {%
\ifflipped%
\draw[chronevent]%
(\xstop, 0) circle (.2\distanceunit)%
node[flippedeventlabel] {#3};%
\else%
\draw[chronevent]%
(\xstop, 0) circle (.2\distanceunit)%
node[eventlabel] {#3};%
\fi%
}{%
\pgfmathsetlength\xstart{(#1-\theyearstart)*\distanceunit}%
\ifflipped%
\draw[chronevent,rounded corners=.2\distanceunit]%
(\xstart,-.2\distanceunit) rectangle%
node[flippedeventlabel] {#3} (\xstop,.2\distanceunit);%
\else%
\draw[chronevent,rounded corners=.2\distanceunit]%
(\xstart,-.2\distanceunit) rectangle%
node[eventlabel] {#3} (\xstop,.2\distanceunit);%
\fi%
}%
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\decimaldate}
% \begin{macrocode}
\newcommand{\decimaldate}[3]{(#1-1)/31/12+(#2-1)/12+#3}%
% \end{macrocode}
% \end{macro}
%
%\section{Changelog}
%\begin{description}
% \item [2023-08-08] Dominik forked the lwiseman/chronology
% GitHub repo and set up this documentation;
% \item [2023-08-08] Dominik merged the changes of Alexander Klemd of
% 2022-12-19 that “Rename variable 'unit' to 'distanceunit' (for compatibility
%with package: siunitx)” into the wujastyk branch
%\end{description}
% \newpage
% \PrintIndex
\endinput%