# Systems Engineering Wiki (http://seweb.se.wtb.tue.nl)

## Latex

latex:lottime:pstricks

# Lot-time diagrams in LaTeX

With the package lottimediagram it is possible to create lot-time diagrams in LaTeX. Lot-time diagrams are used to visualize the manufacturing process of lots in a deterministic system. On the horizontal axis time is presented, while on the vertical axis the individual lots are indicated with a lot number, starting from zero.

## Requirements

In the main document, the package lottimediadram has to be invoked. This package uses the additional packages pstricks, multido and calc. The file lottimediagram.sty can be in your path, or else put it in your working directory.

## Usage and Syntax

The lottimediagram environment can best be used inside a figure environment. In this way, a caption and a label can be attached to the diagram and it can be referred to.

### Instantiation

The lottimediagram environment is instantiated as follows:

\begin{lottimediagram}{number of lots}{width of time axis}
… \end{lottimediagram}

The number of lots is a non-zero natural number. The lots are numbered from zero to number of lots - 1. The width of the time axis also has to be a nonzero natural number.

### Axis labels and tick intervals

The axis labels are entered as follows:

\timeaxislabel{text} \lotaxislabel{text}

Placement of time ticks along the axis can go in user-defined intervals:

\timetickinterval{interval} \lottickinterval{firstlotnumber}{interval}

Placement of lot numbers along the axis can also be done in user-defined intervals where firstlotnumber is the number of the first lot and interval is the interval between lot numbers which are shown. If the \lotticktinterval command is omitted, the first lot number is 0.

### Lots and batches

For individual lots, activities are placed in the diagram using the command:

\lot(lot number)(start time, end time){text}

Lots can be highlighted by using the command \activelot:

\activelot(lot number)(start time, end time)(fillcolor)(fillstyle){text}

in which fillcolor can be black, darkgray, gray, lightgray, white, red, green, blue, cyan, magenta or yellow. The argument fillstyle can be solid, hlines, vlines or crosshatch.

(Note that the options hlines and vlines in fact draw diagonal lines, contrary to one’s expectation.)

Batch processes (activities with more than one lot involved) can be placed with the command:

\batch(first lot number of batch, last lot number of batch)(start time, end time){text}

The text can be rotated 90 degrees counterclockwise by using the command \rotatebatch with the same arguments.

Batches can be highlighted by using the command \activebatch:

\activebatch(first lot number of batch, last lot number of batch)(start time, end time)(fillcolor)(fillstyle){text}

with the same fillcolor and fillstyle options as before.

An activebatch can be used with 90 degrees counterclockwise rotated text using the command \activerotatebatch with the same arguments.

### Defining blocks for multiplication

If a collection of activities on (multiple) lots or batches is repetitive, a block can be defined, which can be copied elsewhere in the diagram. Around the repetitive activities, place the command:

\defineblock{
(collection of
\lot
\activelot
\batch
\activebatch
\rotatebatch
\activerotatebatch
commands)
}

The defined block can be repeated using the command:

\repeatblock{vertical shift}{horizontal shift}

The argument vertical shift is a positive natural number, while horizontal shift is a real number. Blocks can not be nested.

### Annotations

Placing an annotation near a combination of lots can be done using the command \lotcomb:

\lotcomb(start lot number, end lot number)(annotation time){text}

With this command, an arrow is drawn a little right of the indicated time and the text is placed next to it, 90 degrees rotated counterclockwise.

## Example

In Figure 1, an example of a lot-time diagram is given. The diagram was constructed using the following commands:

\begin{lottimediagram}{9}{22}
\timeaxislabel{time [h]}
\timetickinterval{2}
\lotaxislabel{lot nr.}
\lottickinterval{0}{1}
\defineblock{
\lot(0)(0,2){M}
\lot(0)(2,6){q}
\lot(1)(2,4){M}
\lot(1)(4,6){q}
\lot(2)(4,6){M}
}
\batch(0,2)(6,10){Oven}
\lotcomb(0,2)(10){b1}
\repeatblock{3}{6}
\rotatebatch(3,5)(12,16){Oven}
\lotcomb(3,5)(16){b2}
\activelot(6)(12,14)(yellow)(solid){M}
\activelot(6)(14,18)(red)(vlines){q}
\activelot(7)(14,16)(magenta)(hlines){M}
\activelot(7)(16,18)(green)(crosshatch){q}
\activelot(8)(16,18)(cyan)(solid){M}
\activerotatebatch(6,8)(18,22)(lightgray)(solid){F b3}
\end{lottimediagram}

## Stand-alone EPS-file of a lot-time diagram

It might be useful to create a stand-alone EPS-file of the lot-time diagram. The EPS-file can then be included in a LaTeX document or it may appear in a presentation, slides, poster etc. To create a stand-alone EPS-file, a separate .tex-file has to be created, which uses the package pst-eps. The LaTeX document for a simple lot-time diagram could then look like:

\documentclass[a4paper,10pt]{article}
\usepackage{lottimediagram}
\usepackage{times}
\usepackage{amsmath}
\usepackage{pst-eps}
\begin{document}
\begin{TeXtoEPS}
\begin{lottimediagram}{9}{22}
\timeaxislabel{time [h]}
\timetickinterval{2}
\lotaxislabel{lot nr.}
\lottickinterval{0}{1}
\defineblock{
\lot(0)(0,2){M1}
\lot(0)(2,6){q}
\lot(1)(2,4){M1}
\lot(1)(4,6){q}
\lot(2)(4,6){M1}
\batch(0,2)(6,10){batch}
}
\repeatblock{3}{6}
\repeatblock{6}{12}
\end{lottimediagram}
\end{TeXtoEPS}
\end{document}

The document is compiled using the standard LaTeX compiler:

latex filename.tex

To process the resulting .dvi-file to an EPS file we use dvips with the -E option:

dvips filename.dvi -E -o filename.ps

The resulting PostScript file eventually is an Encapsulated PostScript file. So it has to be renamed to eps:

mv filename.ps filename.eps

The resulting EPS-file can be included in a LaTeX document using the includegraphics command. If necessary, the diagram can be scaled using for example the width= argument. This is very useful for large diagrams that have to fit within the margins of a page (see Figure 2 for a not so useful example):

\begin{figure}
\begin{center}
\includegraphics[width=0.8\linewidth]{filename}
\caption{Lot-time diagram in EPS-format can be scaled.}\label{example2}
\end{center}
\end{figure}

Another advantage of using stand-alone EPS-file is the possibility to use PDFLaTeX with lot-time diagrams.

latex/lottime/pstricks.txt · Last modified: Wednesday, 24 November 2010 : 14:22:50 by hat