1

I'm trying to do something similar to How can I mix itemize and tabular environments?.

However, I'm trying to use an enumerate environment, I want the items lined up like in a tabular environment, and I would like to reference the items in the enumerate environment using labels so that the references appear as the numbers in the enumerate environment.

Conceptually, the idea is like that of a bibliography style environment, but each item is a line in an enumerate environment. Conceptually, the layout would look something like this, but with the header and the lines in the body lining up, of course.

\documentclass{article}
\begin{document}
\newcommand{\corr}[4]{%
\begin{tabular}{llll}
%Date & From & To\\
#1 & #2 & #3 & #4
\end{tabular}
}

\section{List of Correspondence}

\begin{tabular}{llll}
\textbf{Date} & \textbf{From} & \textbf{To} & \textbf{Summary}\\
\end{tabular}
\begin{enumerate}
\item\label{c1} \corr{September 26th 2011}{Sender1}{Recepient1}{Some stuff}
\item\label{c2} \corr{September 23rd 2013}{Sender2}{Recepient2}{Some other stuff}
\end{enumerate}

Here is \ref{c1} and \ref{c2}.

\end{document}

ADDENDUM: The multienum package does something close to what I want, except that I don't see how to include the headers.

ADDENDUM2: If there was some way to directly reference the itemize counter without the overhead of placing labels, that would be helpful.

4

Here is a solution, if I've well understood your requirements:

\documentclass[11pt, a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern} 
\usepackage{array}
\newcommand{\colhead}[1]{\multicolumn{1}{>{\bfseries}l}{#1}}
\newcounter{tabenum}\setcounter{tabenum}{0}
\newcommand{\nextnum}{\refstepcounter{tabenum}\thetabenum.}

\begin{document}
\section{Examples}
Here is an example:

\begin{center}
   \begin{tabular}{>{\nextnum}l@{\hspace{\labelsep}}*{3}{l@{\quad\quad}}l}
      \colhead{} &  \colhead{Date} &  \colhead{From}  & \colhead{To}  & \colhead  {Summary} \\
   \hline
      \label{sep11} &  September 26\textsuperscript{th} 2011 & Sender 1 &Recipient 1  \\
      \label{sep13} & September 23\textsuperscript{rd} 2013 & Sender 2 & Recipient 2
   \end{tabular}
\end{center}

According to case \ref{sep13}, Sender 2 sent a letter to Recipient 2.

\end{document}

Result:

  • Thanks for the solution. I'm not clear how you got \label{sep11} to show up as the integer 1. – Faheem Mitha Dec 23 '13 at 21:11
  • It's the use of \refstepcounter, instead of just \stepcounter: it says LaTeX to use this counter for crossreferences. – Bernard Dec 23 '13 at 21:31
  • In your example, the counter automatically increments on every line, even if the line does not contain a new entry - for example to accomodate multirows. Is there some way of suppressing the counter increment for a particular line? – Faheem Mitha Dec 28 '13 at 16:57
  • It looks like one can call \nextnum explicitly as necessary. Is it reasonable to create a hybrid command like\newcommand{\nextnump}[1]{\refstepcounter{tabenum}\thetabenum.\label{#1}} and then call that? – Faheem Mitha Dec 28 '13 at 17:41
  • I forgot about the case of multirow. I'll think about it. Maybe just defining a new command based on multirow and taking \nextnum into account would do the trick? – Bernard Dec 31 '13 at 8:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.