So I am trying to create a new package for Latex. Currently I have one function like this:
\def\timeline#1#2#3{%
% draw the timeline
}%
In this function I open the tikz environment with \begin{tikzpicture}. I also have a function which draws a single event into this environment, which can be called multiple times.
Now I am not sure how to close the tikz environment after all events have been added. Can somebody explain this to me?
Currently I have the following code in the sty file:
\newenvironment{cvtimeline}{%
\begin{tikzpicture}%
}{%
\end{tikzpicture}%
}%
% Functions
\def\timeline#1#2#3{%
% draw the timeline
}%
\def\work#1#2#3#4#5{%
% add an work event and draw
}%
\def\school#1#2#3#4#5{%
% add an school event and draw
}%
This can be used in a tex file as follows:
\begin{document}
\begin{cvtimeline}
\timeline{2009}{2017}{\textwidth}
\work{2009}{8}{2013}{8}{Hello}
\work{2013}{10}{2014}{8}{World}
\end{cvtimeline}
\end{document}
\newcommmandinstead of\def. I also often usedef, because I'm a lazy prick. – MaestroGlanz Feb 18 '17 at 10:22\newenvironmentinstead of\def(or\newcommand) to define your timeline:\newenvironment{timeline}[3]{... code to open your environment...}{... code to close you envrionment...}– Paul Gaborit Feb 18 '17 at 10:27\timelineis defined according to LaTeX syntax. It is defined using\defwhich is TeX, but considering that the majority of packages uses this convention I don't see a major problem, as long as you are sure that the command is not earlier defined. But it could also be that @Johannes_B encourage you to use LaTeX\newenvironmentfor your environment. That will make the closing much easier. – StefanH Feb 18 '17 at 10:31\newenvironmentthe I can draw the timeline. But how do I define the command to create a new event? Do I do this withdefor what is the equivalent in LaTeX syntax? Because I found a lot of packages that usedef, so I am sorry if this is wrong. – Pascal Feb 18 '17 at 10:45\timelineis defined as above and\endtimelineis defined to be\end{tikzpicture}and whatever else is needed the use would be\begin{timeline}{a}{b}{c}.... \end{timeline}– David Carlisle Feb 18 '17 at 11:29