Created
March 21, 2011 06:58
-
-
Save godbyk/879126 to your computer and use it in GitHub Desktop.
Environment for typesetting UML use cases
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% | |
% A simple description-like environment that can be used for writing UML use | |
% cases. | |
% | |
\NeedsTeXFormat{LaTeX2e}[1994/06/01] | |
\ProvidesPackage{usecase}[2011/03/21 v0.1 A usecase environment.] | |
% | |
% Required so we can use inline arithmetic in the usecase environment | |
% defition. Could be removed and the code below could use \addtolength | |
% instead. | |
% | |
\RequirePackage{calc} | |
% | |
% Used in the usecase environment to ensure that the \usecaselabelwidth has | |
% been set. | |
% | |
\RequirePackage{ifthen} | |
% | |
% The style of the labels | |
% | |
\newcommand{\usecaselabelstyle}{% | |
\normalfont\bfseries | |
} | |
% | |
% Used below to set the label width to the width of the longest label | |
% | |
\newlength{\usecaselabelwidth} | |
\setlength{\usecaselabelwidth}{0pt} | |
\newcommand{\maxusecaselabel}[1]{% | |
\settowidth{\usecaselabelwidth}{\usecaselabelstyle #1}% | |
} | |
% | |
% The definition of the usecase environment -- where all the 'magic' happens | |
% | |
\newenvironment{usecase}{% | |
\begin{list}{}{% | |
\ifthenelse{\lengthtest{\usecaselabelwidth=0pt}}{% | |
\PackageError{usecase}{You must call \string\maxusecaselabel}{% | |
You should call \string\maxusecaselabel{LongestUseCaseLabel}, where | |
\MessageBreak | |
LongestUseCaseLabel is the longest label used in your usecase | |
environment. | |
}% | |
}{}% | |
\renewcommand{\makelabel}[1]{% | |
\usecaselabelstyle ##1% | |
\hfil | |
}% | |
\setlength{\labelwidth}{\usecaselabelwidth}% | |
\setlength{\leftmargin}{\labelwidth+\labelsep}% | |
}% | |
}{% | |
\end{list}% | |
} | |
\endinput |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment