Saturday, 17 August 2013

Making a class to generate colored tables with a predefined layout

Making a class to generate colored tables with a predefined layout

This is a follow-up question
in which I asked how to define classes with \newcommands into
\newenvironments, and I had some good answers to this particular issue.
However, the problem that I have does not rely only on the issue described
in the other thread, but it is more general. for instance, I wish to
create a class to generate tables like the following

The plain code that I use to create this table is the following
\documentclass[landscape, 12pt]{report}
\usepackage{graphicx}
\usepackage{enumerate}
\usepackage{enumitem}
\setlist{nolistsep}
\usepackage[top=0.1cm, bottom=0cm, left=0.1cm, right=-0cm]{geometry}
\usepackage[dvipsnames,usenames]{xcolor}
\begin{document}
\noindent
\colorbox{cyan!20}{
\begin{tabular}{|p{12.6cm}|}
\hline
Champions League \\
- Team 1: The Hawks\\
\hline\\
FIRST-STRING PLAYERS:
\begin{enumerate}
\item John
\item Carl
\item Smith
\end{enumerate} \\
RESERVE PLAYERS:
\begin{enumerate}
\item Anthony
\item Luke
\end{enumerate} \\
\hline
COACH: Robert\\\hline
\end{tabular}
}
\end{document}
And I am quite happy with that, but I wish also to create a class such,
referring to the example in the picture:
The "1" after "- Team" in the second line is an incresing number (so I
guess I need a counter inside a \newenviroment definition);
What is written with capital letters (e.g. FIRST-STRING PLAYERS, etc.) is
fixed in the table;
The tournament name (e.g. Champions League is a kind of "global" variable)
As an indicative example, here is a kind of main document I wish to use:
\documentclass{Teams}
\begin{document}
\CUP{Champions League}
\begin{team}
\TeamColor{Cyan!20}
\TeamName{The Hawks}
\FSPlayers{
\begin{enumerate}
\item John
\item Carl
\item Smith
\end{enumerate}
}
\RPlayers{
\begin{enumerate}
\item Anthony
\item Luke
\end{enumerate}
}
\Coach{Robert}
\end{team}
I hope that my problem is clear. Unfortunately, I have never written any
class before, so any help will be greatly appreciated.

No comments:

Post a Comment