2

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.

  • 1
    Try as a 'rescue': \end{itemize}\[-\normalbaselineskip]` in the first itemize list – user31729 May 6 '17 at 22:09
  • See, if tex.stackexchange.com/questions/347253/… can help you. – Zarko May 6 '17 at 22:14
  • @ChristianHupfer I get several errors – Ben May 6 '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 6 '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 6 '17 at 22:17
3

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}.

  • 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) – Ben May 6 '17 at 22:35
3

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

  • 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. – Ben May 6 '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 6 '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 – Ben May 6 '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 6 '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." – Ben May 7 '17 at 0:18

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.