Text Formattingvertically align list in parbox table row

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
jukka
Posts: 3
Joined: Tue Feb 17, 2009 7:18 pm

vertically align list in parbox table row

Post by jukka »

Hello,

I'd like to vertically align the contents of a table row where all columns are formatted as parboxes. All but one cells of a given row contain regular text paragraphs and thus align fine. But one cell contains an itemize list, and the first item of that list does not align with the first lines of the other cells of the same row. Here's an example to show what I'm trying to explain:

Code: Select all

\documentclass[draft]{report}
\usepackage{paralist}

\begin{document}

\newlength{\cw}
\setlength{\cw}{.2\linewidth}

\begin{tabular}{*{3}{p{\cw}}}\hline
A regular table column containing some text.&
\begin{itemize}
\item A list which is not 
\item vertically aligned.
\end{itemize}&
\begin{compactitem}
\item A compact list which is
\item also not vertically aligned.
\end{compactitem}
\end{tabular}

\end{document}
A compactitem list aligns better compared to the regular itemize list, but there's still some space preceding it. I already tried to get rid of it by setting \topsep, \parskip and \partopsep (and their counterparts \pltopsep, \psparsep and \plpartopsep) to zero, but this seems not to produce the results I'd like to see.

What am I missing? Help is appreciated!

TIA, Jukka

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

vertically align list in parbox table row

Post by gmedina »

Hi,

you could use \vspace* to control the vertical placement of the list inside the tabular environment; of course it's not the optimal solution since you'll have to adjust the argument of \vspace* manually. The following code illustrates this approach (I used the enumitem package to reduce all possible vertical spaces inside the list):

Code: Select all

\documentclass{report}
\usepackage{enumitem}

\begin{document}

\newlength{\cw}
\setlength{\cw}{.2\linewidth}

\begin{tabular}{*{2}{p{\cw}}}\hline
  A regular table column containing some text.& \vspace*{-.7em} 
  \begin{itemize}[topsep=-0pt,partopsep=0pt,parsep=0pt,itemsep=0pt]
    \item A list which is 
    \item now vertically aligned.
  \end{itemize}
\end{tabular}

\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
jukka
Posts: 3
Joined: Tue Feb 17, 2009 7:18 pm

Re: vertically align list in parbox table row

Post by jukka »

Thanks for the hint, gmedina! Of course this works fine. And until I find the ``optimal solution'' I'll use this workaround.

Thanks again & regards,
Jukka
mas
Posts: 226
Joined: Thu Dec 04, 2008 4:39 am

Re: vertically align list in parbox table row

Post by mas »

To reduce the vertical spaces in a list, I find the package parlist to be convenient. The compactitem and compactenum are nice.

Regards.

OS: Debian/GNU Linux; LaTeX System : TeXLive; Editor : Vim
jukka
Posts: 3
Joined: Tue Feb 17, 2009 7:18 pm

Re: vertically align list in parbox table row

Post by jukka »

Yes, compactitem does use less space than itemize, but it still uses some space; see the third column in my original example.

Regards, Jukka
celafon
Posts: 3
Joined: Tue Jan 06, 2009 4:37 am

vertically align list in parbox table row

Post by celafon »

I have come up with the same workaround for this problem. However in my tabular I am not able to get rid of the vertical space *after* the list. So adding another row to the example above, there would be additional space between list and the new row. Any ideas how to solve this?

Code: Select all

\documentclass{report}
\usepackage{enumitem}

\begin{document}

\newlength{\cw}
\setlength{\cw}{.2\linewidth}

\begin{tabular}{*{2}{p{\cw}}}\hline
  A regular table column containing some text.& \vspace*{-.7em} 
  \begin{itemize}[topsep=-0pt,partopsep=0pt,parsep=0pt,itemsep=0pt]
    \item A list which is 
    \item now vertically aligned.
  \end{itemize} \\
  % the space shows up here (about 1em)
  A new row & with new things in it \\
\end{tabular}

\end{document}
Post Reply