7

I'm writing the use case documentation for my Software Engineering project. I'm using longtable to get a template that spans over multiple pages.

\documentclass{article}
\usepackage{array}
\usepackage{lipsum} % Used to produce long text
\usepackage{longtable}
\newcolumntype{L}{>{\raggedleft}p{0.2\textwidth}}
\newcolumntype{R}{p{0.74\textwidth}}
\newcommand\VRule{\vrule width 0.5pt}

\begin{document}
    \begin{longtable}{L!{\VRule}R}
        \hline
        \textbf{ID}                & \texttt{UC\_01\_01}            \\
        \textbf{Name}              & Password recovery              \\
        \textbf{\textit{Macro}-UC} & Registration (\texttt{UC\_01}) \\
        \textbf{Actors}            & \texttt{ACTOR\_02}             \\ \hline
        \textbf{Preconditions}     & \lipsum[2-4]                   \\ \hline
        \textbf{Main flow}         & Some itemize list here!        \\ \hline
        \textbf{Postconditions}    & \lipsum[5-7]                   \\ \hline
    \end{longtable}
\end{document}

The problem is that the table doesn't break within the row. I would need a breakable content to put into a row to have a homogeneous filling on each page.

I tried to wrap this row in a box using the framed package but it doesn't work. I noticed that I can achieve a break page within a box with the mdframed package but I can't use it since I'm working on ScribTeX and I've no version of LaTeX installed on my computer.

I've also tried the usecase package but it doesn't support page breaking.

Could you please suggest me a trick or an alternative to achieve this result? I've been stucking on this matter for two days.

2 Answers 2

8

I don't think that's possible with longtable, or any other tabular environment for that matter, because the material inside the tabular cells are TeX boxes, which by definition cannot be broken.

I suggest you use parcolumns instead, which has been designed to typeset several columns next to each other for multilingual texts. Here's an example:

\documentclass{article}
\usepackage{lipsum} % Used to produce long text
\usepackage{parcolumns}

\parindent=0pt

\begin{document}
\begin{parcolumns}[colwidths={2=0.74\textwidth},rulebetween,sloppy]{2}
    \colchunk[1]{\textbf{ID}}
    \colchunk[2]{\texttt{UC\_01\_01}}
    \colplacechunks

    \colchunk[1]{\textbf{Name}}
    \colchunk[2]{Password recovery}
    \colplacechunks

    \colchunk[1]{\textbf{\textit{Macro}-UC}}
    \colchunk[2]{Registration (\texttt{UC\_01})}
    \colplacechunks

    \colchunk[1]{\textbf{Actors}}
    \colchunk[2]{\texttt{ACTOR\_02}}
    \colplacechunks

    \colchunk[1]{\textbf{Preconditions}}
    \colchunk[2]{\lipsum[2-4]}
    \colplacechunks

    \colchunk[1]{\textbf{Main flow}}
    \colchunk[2]{Some itemize list here!}
    \colplacechunks

    \colchunk[1]{\textbf{Postconditions}}
    \colchunk[2]{\lipsum[5-9]}
    \colplacechunks
\end{parcolumns}
\end{document}
2
  • 1
    Thanks @alexraasch! Your example helps me a lot! Just a couple of questions: 1. How can I add a blank line before and after the main flow chunk to make it more readable? 2. Is there an option that allows me to reduce (or remove) the indentation inside the two columns?
    – Driu
    Dec 29, 2012 at 18:34
  • 1
    1. \colchunk[1]{~\\\textbf{Main flow}\\} and \colchunk[2]{~\\Some itemize list here!\\}. Can't think of something more elegant right now. :) 2. Put the distance=... option in the square brackets. Default is 2em.
    – alexkelbo
    Dec 29, 2012 at 21:12
2

Just to record parallel package:

\documentclass{article}
\usepackage{lipsum} % Used to produce long text
\usepackage{parallel}
\parindent=0pt

\begin{document}
\begin{Parallel}[v]{0.4\textwidth}{0.55\textwidth}
    \ParallelLText{\textbf{ID}}
    \ParallelRText{\texttt{UC\_01\_01}}
    \ParallelPar

    \ParallelLText{\textbf{Name}}
    \ParallelRText{Password recovery}
    \ParallelPar

    \ParallelLText{\textbf{\textit{Macro}-UC}}
    \ParallelRText{Registration (\texttt{UC\_01})}
    \ParallelPar

    \ParallelLText{\textbf{Actors}}
    \ParallelRText{\texttt{ACTOR\_02}}
    \ParallelPar

    \ParallelLText{\textbf{Preconditions}}
    \ParallelRText{\lipsum[2-4]}
    \ParallelPar

    \ParallelLText{\textbf{Main flow}}
    \ParallelRText{Some itemize list here!}
    \ParallelPar

    \ParallelLText{\textbf{Postconditions}}
    \ParallelRText{\lipsum[5-9]}
\end{Parallel}
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .