# [Tex/LaTex] Custom tabular environments

liststables

I'm trying to create the following structure using the best possible "user-interface" in LaTeX:

 ---------------------------------------------
|  Week 1  |  1.  Topic 1                        |
|          |  2.  Topic 2                        |
---------------------------------------------
| Week 2   |  1.  Topic 3                        |
|          |  2.  Topic 4                        |
---------------------------------------------


I can, of course create this using a nested enumerate inside a tabular but it would be ugly to look at and difficult to maintain with all the & and the \\ characters.

What I need is a way to cleanly define this structure so that the code looks pretty. The only requirements is the numbering, the tabular structure and of course, page-spanning outlines. If there's a package available, I'd be happy to modify it. (I found the courseoutline package on CTAN by it doesn't have weekly topic breakdown.)

I build a custom enviroment with nice looking tables. The result will be:

\documentclass{article}

\usepackage{etoolbox}
\usepackage{booktabs}

\newcounter{a}
\newcounter{b}[a]
\newbool{firstline}

\newenvironment{mytabular}{%
\setcounter{a}{0}%
\setcounter{b}{0}%
\booltrue{firstline}%
\begin{tabular}{ll}
\toprule}
{\\ \bottomrule\end{tabular}}

\newcommand{\mitem}[2][]{%
\ifbool{firstline}{}{\ifblank{#1}{\\\cmidrule{2-2}}{\\\midrule}}%
\global\boolfalse{firstline}%
#1 \ifblank{#1}{}{\stepcounter{a}\thea}%
&\theb. #2%
}
\newcommand{\witem}[1]{\mitem[Week]{#1}}

\begin{document}
\begin{mytabular}
\mitem[Week]{Subject}
\mitem{Another subject}
\mitem{And another}
\witem{Usage of witem}
\end{mytabular}
\end{document}


or if you don't like this tabular style, you could use this one:

\documentclass{article}

\usepackage{etoolbox}

\newcounter{a}
\newcounter{b}[a]
\newbool{firstline}

\newenvironment{mytabular}{%
\setcounter{a}{0}%
\setcounter{b}{0}%
\booltrue{firstline}%
\begin{tabular}{|l|l|}
\hline}
{\\ \hline\end{tabular}}

\newcommand{\mitem}[2][]{%
\ifbool{firstline}{}{\ifblank{#1}{\\\cline{2-2}}{\\\hline}}%
\global\boolfalse{firstline}%
#1 \ifblank{#1}{}{\stepcounter{a}\thea}%
&\theb. #2%
}
\newcommand{\witem}[1]{\mitem[Week]{#1}}

\begin{document}
\begin{mytabular}
\mitem[Week]{Subject}
\mitem{Another subject}
\mitem{And another}
\witem{Usage of witem}
\end{mytabular}
\end{document}