Discussion:
enumerate items in multicolumn table
(too old to reply)
r***@gmail.com
2008-08-18 19:20:01 UTC
Permalink
please help me with the following:
I am trying to enumerate items in multicolumn tables. Earlier, I got
help and the following code works fine except that I want the item
numbers instead of bullets, and secondly I need the text to be "left
justified" as there is awkward spacing between words if I leave it
"center". I tried to change itemize with enumerate but it doesn't
work..
Best Regards,
Reez

\documentclass{article}


\usepackage{enumitem}


\begin{document}


\setitemize{topsep=-2ex,itemsep=-
\baselineskip,partopsep=-2ex,leftmargin=*}


\def\newitem#1{%
\begin{itemize}
\item #1
\end{itemize}%



}%


\begin{tabular}{|p{0.4\linewidth}|p{0.4\linewidth}|}
\newitem{this is very neat and it may change next time} &
\newitem{this is very neat and it may change next time. this is
really a matter of safety and should not
be taken lightly.} \\[-1em]
\newitem{rae} & \newitem{rae} \\[-1em]
\newitem{me} & \newitem{me} \\[-1em]
\newitem{fa} & \newitem{fa} \\[-1em]
\newitem{so} & \newitem{here is another long line that should be
formatted as a regular paragraph} \\[-1em]
\newitem{and the left and right columns both along one another
per
item} & \newitem{la} \\[-1em]
\newitem{tee} & \newitem{tee} \\[-1em]
\newitem{\ldots} & \newitem{\ldots}
\end{tabular}

\end{document}
Peter Flynn
2008-08-18 20:50:09 UTC
Permalink
Post by r***@gmail.com
I am trying to enumerate items in multicolumn tables.
From the look of it, what you actually want to do is align the items of
two parallel lists. The fact that they are in a table isn't really relevant.
Post by r***@gmail.com
Earlier, I got help and the following code works fine except that I
want the item numbers instead of bullets,
But you're not using a list environment for the whole list: you are
restarting it afresh every time, so there is no counter to do this.
Post by r***@gmail.com
I tried to change itemize with enumerate but it doesn't work..
You need to use a list environment inside each cell to get the
enumeration right, and only then look at the alignment. As a general
rule, try to let LaTeX do the work for you, and only intervene when
really necessary (a tip Barbara Beeton once gave me, which has proved
invaluable).
Post by r***@gmail.com
and secondly I need the text to be "left justified" as there is
awkward spacing between words if I leave it "center".
The array package lets you prefix a column specification with a preamble
to specify formatting. I have kludged it using \pbs -- I know there's a
way to do this more neatly but I forget it and I'm out of time for
looking it up right now.

///Peter

\documentclass{article}
\usepackage{array,calc}
% kludge to allow \raggedright etc in a column preamble
\newcommand{\pbs}[1]{\let\tmp\\#1\let\\\tmp}
% \drop is a correction for the positioning of a \vrule depth
\newlength{\drop}
% gap is the amount of space to leave
\newlength{\gap}
% this macro forces space between items using a vrule
% the argument is in lines (=\baselineskips)
\newcommand{\dl}[1]{\setbox0=\hbox{xy}%
\setlength{\drop}{\dp0}%
\setlength{\gap}{#1\baselineskip+\itemsep+\drop}%
\vrule depth\gap height0pt width0pt}
\begin{document}
% calculate two even columns to close to max width
\begin{tabular}{|*2{>{\pbs{\raggedright}}p{\columnwidth/2 -3\tabcolsep}|}}
\begin{enumerate}
\item this is very neat and it may change next time\dl2
\item rae
\item me
\item fa
\item so\dl2
\item and the left and right columns both along one another per
item
\item tee
\item \dots
\end{enumerate}
&
\begin{enumerate}
\item this is very neat and it may change next time. this is
really a matter of safety and should not be taken lightly.
\item rae
\item me
\item fa
\item here is another long line that should be formatted as a
regular paragraph
\item la\dl2
\item tee
\item \dots
\end{enumerate}
\end{tabular}
\end{document}

Loading...