3

My code

\documentclass{article}

%\usepackage{enumitem}
%\setlist{nosep}

\begin{document}
\begin{tabular}{|p{5cm}|}
\hline
text top
\begin{itemize}
\item item text
\end{itemize}\\
\hline
\end{tabular}

\begin{tabular}{|p{5cm}|}
\hline
text top
\begin{itemize}
\item item text
\end{itemize}
text bottom\\
\hline
\end{tabular}
\end{document}

produces an empty line in the first tabular under the itemize (also unter an enumerate).

Even using

\usepackage{enumitem}
\setlist{nosep}

doesn't help.

user1
  • 2,196
  • 1
    Try as a 'rescue': \end{itemize}\[-\normalbaselineskip]in the firstitemize` list –  May 06 '17 at 22:09
  • See, if https://tex.stackexchange.com/questions/347253/items-list-inside-table-cell-are-not-well-aligned can help you. – Zarko May 06 '17 at 22:14
  • @ChristianHupfer I get several errors – user1 May 06 '17 at 22:15
  • perhaps it is just because you simplified the example (a good thing) but a one-column tabular doesn't do anything very useful, you could just use a \parbox. – David Carlisle May 06 '17 at 22:16
  • 2
    I think Christian inadvertently left off a backtick in his comment and, as a result, a backslash isn't showing. Try \end{itemize}\\[-\normalbaselineskip]. – Mico May 06 '17 at 22:17
  • @DavidCarlisle The problem of course showes up in larger tables – user1 May 06 '17 at 22:17
  • @Mico thanks. It works. (But I actually don't like rescues...) Maybe someone else can help – user1 May 06 '17 at 22:19

2 Answers2

4

May be this setup of itemize can help:

\documentclass{article}

\usepackage{enumitem}
\setlist[itemize]{nosep,     
                 topsep     = 0pt       ,
                 partopsep  = 0pt       ,
                 leftmargin = *         ,
                 after      = \vspace{-\baselineskip}
                 }
\begin{document}

\begin{tabular}{|p{5cm}|}
  \hline
  text top
  \begin{itemize}
    \item item text
  \end{itemize}\\
  \hline
\end{tabular}

\begin{tabular}{|p{5cm}|}
  \hline
  text top
  \begin{itemize}
    \item item text
  \end{itemize}\\   % <======
  text bottom\\
  \hline
\end{tabular}

\end{document}

enter image description here

This will affect all occurrences of itemize in your document, so if you need this behavior for tabulars only, define a new tabitemize style like this:

\setlist[tabitemize]{nosep,     
                     topsep     = 0pt       ,
                     partopsep  = 0pt       ,
                     leftmargin = *         ,
                     after      = \vspace{-\baselineskip}
                     }

and in your tables use \begin{tabitemize} ... \end{tabitemize}.

AboAmmar
  • 46,352
  • 4
  • 58
  • 127
  • I like your attempt, but 1) I would remove '[itemize]' since my question concerns itemize and enumerate 2) I would remove 'topsep = 0pt, partopsep = 0pt, leftmargin = *,' because I see no use 3) The added arrow '% <======' is very important and this makes me not happy with the solution: Add a second column which is higher than the one with itemize. Now it's not possible to continue with the text directly under the itemize. (This problem occurs if you have multiple tabulars in one document or one row ending with an itemize and an other, which doesn't) – user1 May 06 '17 at 22:35
4

Let me convert my comment to answer with customization of answer here to this question:

\documentclass[a4paper]{article}
\usepackage{enumitem}           % for nice list
\newlist{tablist}{itemize}{1}% <-- defined new list
\setlist[tablist]{nosep,     % <-- new list setup
                 topsep     = 0pt       ,
                 partopsep  = 0pt       ,
                 leftmargin = *         ,
                 label      = $\bullet$ ,
                 after      = \vspace{-\baselineskip}
                 }
\begin{document}

\begin{tabular}{|p{5cm}|}
    \hline
text top
    \begin{tablist}
\item item text
    \end{tablist}\\
    \hline
\end{tabular}

\medskip
\begin{tabular}{|p{5cm}|}
    \hline
text top
    \begin{tablist}
\item item text
    \end{tablist}\\ 
text bottom\\
    \hline
\end{tabular}

\end{document}

enter image description here

Zarko
  • 296,517
  • Point (1,2,) 3 of my comment to AboAmmar's solution applies to your solution as well. I would fix it, by defining rowEndList instead of tablist and only use it, if the List really ends the row. But this is still a very inflexible solution. Maybe something like after=if end of row then \vspace{-\baselineskip} else {} is possible, but I don't really know if this is a good solution. I guess for a nice solution it needs a complete different approach. – user1 May 06 '17 at 23:22
  • then don't use list environments but just simple \textbulet\ ... \par or wait to someone who will be able to do magic which you like to have :) – Zarko May 06 '17 at 23:33
  • Actually I didn't know \textbullet, but the indentation is missing. So right now since there is no (easy) solution which handles all eventualities, I guess writing \vspace{-\baselineskip} exactly where it is needed, is the easiest solution – user1 May 06 '17 at 23:46
  • @Ben, shorter is write \\ ˙after \end{tabitem} :) , but dont give up. Consider to ask new question based on one of above answer with request that after=\vspace{-\baseline} is in use, when after list is no text in cell. I'm pretty sure that someone know how to test what follow to list. – Zarko May 06 '17 at 23:57
  • Yes, but "Add a second column which is higher than the one with itemize. Now it's not possible to continue with the text directly under the itemize." – user1 May 07 '17 at 00:18