# Desired Behavior

This Latex:

\documentclass{scrreprt}
\usepackage{usecases}
\setlength{\parindent}{0em}
\setlength{\parskip}{1em}

\begin{document}
\subsubsection{Example Use Case}

\begin{usecase}
\name{Some Use Case Name}
\actor{User}
\description{This is some very complex use case}
\precondition{X has to be true}
\scenario{
\item System show something
\item User do this
\item System do that
}
\result{Something happens}
\extension{
\item[3a] If something do something
}
\exceptions{
\item[2.1] System message: "Nope"
}
\end{usecase}

\end{document}


would produce this:

Note: the table should span the entire width of writable area of the document.

# What I currently have

Currently I am creating a usecases.sty package and I got this:

\usepackage{tabularx}

% template %

\begin{enumerate}
\forcsvlist{\item}{#2}
\end{enumerate}
\\}

% making stuff convenient %

\newcolumntype{b}{X}
\newcolumntype{s}{>{\hsize=.5\hsize}X}

\newenvironment{usecase}{\tabularx{\textwidth}{|s|b|}\hline}{\endtabularx}


# My questions (the issues)

How to render enumarted list properly when getting them as a parameter? (referring to my additemizedrow command which does not work as intended)

How to make the table width to span the entire writable area of the document? (The left column would have fixed size)

How to add some inner margin in the table's cell (see the image above)?

• Regarding the overall width of the table: take a look at the tabularx package. – leandriis Oct 18 at 7:00
• Regarding "inner margins" : I guess you refer to the vertical white space between an hline and the text. For this, take a look at the cellspace package. – leandriis Oct 18 at 7:00
• @leandriis I am trying out tabularx package by changing the newenvironment line to: \newenvironment{usecase}{\begin{tabularx}{\textwidth}{|X|X|}\hline}{\end{tabularx}} but I am getting fatal error – Programer Beginner Oct 18 at 14:32
• You can not use \begin{tabularx} and \end{tabularx} inside of the definition of a new environment. Instead, you could use the following code \newenvironment{usecase}{\tabularx{\textwidth}{|l|X|}\hline}{\endtabularx}. – leandriis Oct 18 at 17:09
• Regarding your recent update: The l type column does not accept a width argument. Either use l as it is and accept that the column is automatically as wide as its widest entry or use wl{2cm}. – leandriis Oct 18 at 18:00

Probably the following is closer to the desired output:

In comparison to your original code, I used the enumitem package to define a customized enumerate-like environment for which I changed the spacing above and below as well as the left margin/indentation. In order to make the table as wide as the textwidt, I used the tabularx package. To fix the width of the first column I used wl from the array package, which in turn is already loaded by tabularx. (This solution does not allow for linebreaks inside the first column. If you want thatn, replace wl{2cm} with p{2cm}.) To increase the spacing between the text inside the cells and the \hlines , I used the cellspace package. You can of course customize this space according to your needs. If you expect your table to exceed one page, you can use the xltabular package instead of tabularx. (With this approach, keep in mind that page breaks can only occur between subsequent table rows, not within a table row.)

\documentclass{scrreprt}

\usepackage{enumitem}
\newlist{tabenum}{enumerate}{1}
\setlist[tabenum]{label*=\arabic*.,
labelwidth=2em,
leftmargin=2em,
nosep,
before=\begin{minipage}[t]{\hsize},
after=\end{minipage}}

\usepackage{tabularx}

\usepackage[column=0]{cellspace}
\setlength{\cellspacetoplimit}{\tabcolsep}
\setlength{\cellspacebottomlimit}{\cellspacetoplimit}

% template %

\begin{tabenum}
#2
\end{tabenum}
\\ \hline}

% making stuff convenient %

\newenvironment{usecase}{\tabularx{\textwidth}{|0{wl{3cm}}|0{X}|}\hline}{\endtabularx}
\setlength{\parindent}{0em}
\setlength{\parskip}{1em}

\begin{document}
\subsubsection{Example Use Case}

\begin{usecase}
\name{Some Use Case Name}
\actor{User}
\udescription{This is some very complex use case}
\precondition{X has to be true}
\scenario{
\item System show something
\item User do this
\item System do that
}
\result{Something happens}
\extensions{
\item[3a] If something do something
}
\exceptions{
\item[2.1] System message: "Nope"