# LaTeX template for use cases

Currently I am trying to create a template in LaTeX for my team members in order to create a set of use cases. I thought of using tabular to create something like the picture below 2 (without colors). No problem so far.

However, I hoped there is a nice way to structure the document a way, only commands have to be used, for instance \actor{1}{System user}, where 1 is use case #1.

I don't know how to approach this for sure, especially when more then one line of text is included, for instance Main path (M) (at the picture).

Has anyone an idea what would be a good way to structure such a template or could point me out the right documentation to look up this topic?

You should try and keep you author's interface as simple as possible. I would create an environment to simplify this and add complexity and presentational aspects on the setup.

\newenvironment{usecase}
\end{usecase}


Here is a minimal example to implement this:

\documentclass{article}
\usepackage{booktabs}

\hline
}

&\begin{minipage}[t][][t]{8cm}
\begin{enumerate} #2   \end{enumerate}
\end{minipage}\\ }

{\hline\end{tabular}}
\begin{document}
\begin{usecase}
\addrow{Precondition}{The system, shows, in the form part of an object type, the number   indication.}
\addrow{Postcondition}{A disconnected number indicating the type of other constructed object'.}
\addmulrow{Main path (M)}{\item User selects \ldots
\item System demands \ldots}
\end{usecase}

\end{document}


You can add counters to automatically increment numbering, if you want. I couldn't understand your numbering scheme and hence left that out of the example.

To summarize, keep the author's commands simple (they only need to deal with the semantics) and place your presentational aspects in separate commands.

• This answer helped me a lot. I created a package and template based on it. I'm just posting this for people who are having the same problem. – Tom Desair Apr 3 '12 at 18:11
• @Vulcanor: This seems interesting. It would be very helpful if you posted an example here along with the output. Also, if you posted the original question you should associate your accounts. – Peter Grill Apr 3 '12 at 21:35
• @Vulcanor Great it worked for you. Nice blog, I bookmarked it. Drop in chat and ask one of the mods to associate your accounts as per Peter's suggestion. – Yiannis Lazarides Apr 4 '12 at 6:46
• Tom's link no longer works but the package source and the template can still be found on GitHub. – Casimir Jun 3 '17 at 11:30

Had change Yiannis example a little bit. Add counter, table capture, change style of table to be relevant to ESKD standard, and remove rudiment definitions.

Now definition is:

\begin{usecase}{System user}
\addrow{Precondition}{The system, shows, in the form part of an object type, the number indication.}

\addrow{Postcondition}{A disconnected number indicating the type of other constructed object'.}

\item User selects \ldots
\item System demands \ldots}
\end{usecase}


And it's looks like:

And the source is:

\newcommand\tabularhead[1]{
\begin{table}[h]
\caption{Action <<#1>>}
\begin{tabular}{|p{0.4\linewidth}|p{0.55\linewidth}|}
\hline
\textbf{Action} & \textbf{#1} \\
\hline}

&\begin{minipage}[t][][t]{8cm}
\begin{enumerate} #2   \end{enumerate}
\end{minipage}\\ }

{\hline\end{tabular}\end{table}}


I have further developed on Yiannis Lazarides' command and refined it. Here you go:

\newenvironment{usecaseenv}{
\def\arraystretch{2}
\begin{tabular}{lp{11cm}}\hline
}{
\hline\end{tabular}
\def\arraystretch{1}
}

\multicolumn{2}{c}{\textbf{\textit{#1}}}\\ \hline
}
&\begin{minipage}[t][][t]{11cm}
#2
\end{minipage}\\
}

% The actual command definition
\let\oldFigureName\figurename %save the old definition of the caption's figure name
\newcommand{\usecase}[6]{
\vspace*{0.5cm} % adds a bit of padding to make it look nicer11
\renewcommand{\figurename}{Use case} %call figure name "Use case" instead
\begin{figure}[htbp]
\begin{center}
\begin{usecaseenv}
\end{usecaseenv}
\end{center}
\caption{#6}
\label{#2}
\end{figure}
\renewcommand{\figurename}{\oldFigureName} %reset caption figure name
}


Result:

Now this has been perfect for my coauthors and I. This abstracts away the environment, so you can simply use the command as follows:

\usecase{TITLE}{uc:LABEL}{USE CASE}{OBJECTS}{FUNCTIONS}{CAPTION}


In my version it is possible to use \ref{uc:LABEL} to reference the use case later.

Hope you find it useful.