I'm redefining description
to use a table, as part of a CV class. The CV is styled as a big long list, with vertically aligned dates and such, so I thought I could add \begin{tabular}{ l l }
to AtBeginDocument
, and end it at AtEndDocument
. Then just redefine description to be transparent, and item
s within description to be the rows of the table as expected:
\renewenvironment{description}
{
\renewcommand{\item}[1][]{\textsc{##1} & }
} {
}
As inspired by this blog post.
By defining things like section
simlarly, I can add a section to my CV with:
\section{A section}
\begin{description}
\item[2019] An event \\
\item[2021] A later event \\
\end{description}
I've been testing my ideas in smaller files as I go along. So the total MWE, exactly as I compiled it:
\documentclass{article}
\renewenvironment{description}
{
\renewcommand{\item}[1][]{##1 & }
} {
}
\begin{document}
\begin{tabular}{ l l }
\begin{description}
\item[2019] An event \\
\item[2021] A later event \\
\end{description}
\end{tabular}
\end{document}
This compiles, but it's wrong. It looks like this:
To get the whole lot to show up, I have to include the tabular environment in the definition of description
:
\documentclass{article}
\renewenvironment{description}
{
\renewcommand{\item}[1][]{##1 & }
\begin{tabular}{ l l }
} {
\end{tabular}
}
\begin{document}
\begin{description}
\item[2019] An event \\
\item[2021] A later event \\
\end{description}
\end{document}
Which looks as expected, like this:
This happens with more than two items as well. Only the top item ever shows up completely, the others are truncated as in the image.
I know I could just keep the tabular
environment in the description
definition, but that seems untidy, and would be harder to maintain (because I would need a similar declaration in every environement and/or command I redefined, to make everything line up properly. I originally had all this hardcoded in one LaTeX file, and there I used a single table wrapping the whole file, and was much easier than having lots of individual ones).
So, why does this happen, and how can I make the output appear as expected, with only one table, outside of the environment definition?