5

I want to add bullet points to a simple table. However, I'm having trouble with formatting. The text is not spaced evenly and the last hline of the table overleaf would not accept

\setlength{\arrayrulewidth}{1mm}
\setlength{\tabcolsep}{20pt}
\renewcommand{\arraystretch}{2}
{
\begin{table}[h]
\begin{tabular}{ |p{3cm}|p{3cm}|p{3cm}|  }
\hline
Pros& Cons &Price Range \\
\hline
\begin{itemize}
  \item Simple, easy to use
  \item Low cost to produce
  \item High versatility
\end{itemize}
& 
\flushleft
\begin{itemize}
    \item Poor durability
    \item Poor gripping strength for soft materials
\end{itemize}
& 
\flushleft
\begin{itemize}
    \item Poor durability
    \item Poor gripping strength for soft materials
\end{itemize}
\hline
\end{tabular}
\caption{ Pros/Cons and Price Range for Category 1}
\label{table:1}
\end{table}
}

Does any one have any advice?

  • 2
    Add a \\ before the last \hline. – Skillmon May 5 '18 at 20:27
  • 1
    Welcome to TeX.SX! Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem. – Skillmon May 5 '18 at 20:27
6

With the help of the enumitem package you can achieve the following result:

\documentclass{article}
\usepackage{enumitem}
\newlist{tabitem}{itemize}{1}
\setlist[tabitem]{wide=0pt, nosep, leftmargin= * ,label=\textbullet,after=\vspace{-\baselineskip},before=\vspace{-0.6\baselineskip}}

\begin{document}

\setlength{\arrayrulewidth}{1mm}
\setlength{\tabcolsep}{20pt}
\renewcommand{\arraystretch}{2}
{
\begin{table}[h]
\begin{tabular}{ |p{3cm}|p{3cm}|p{3cm}|  }
\hline
Pros& Cons &Price Range \\
\hline
\begin{tabitem}
  \item Simple, easy to use
  \item Low cost to produce
  \item High versatility
\end{tabitem}
& 

\begin{tabitem}
    \item Poor durability
    \item Poor gripping strength for soft materials
\end{tabitem}
& 

\begin{tabitem}
    \item Poor durability
    \item Poor gripping strength for soft materials
\end{tabitem}
\tabularnewline
\hline
\end{tabular}
\caption{ Pros/Cons and Price Range for Category 1}
\label{table:1}
\end{table}
}

\end{document}

enter image description here

  • 2
    probably the dot after \textbullet is superfluous :-) – Zarko May 6 '18 at 7:11
  • @Zarko: You're right. Seems as if this was a copy-paste-leftover that I have now removed. – leandriis May 6 '18 at 7:25
5

I have used a combination of \usepackage{paralist}+{compactitem}.

enter image description here

\documentclass{article}
\usepackage{tabularx}
\usepackage{paralist}
\makeatletter
\let\savespace\@minipagetrue
\makeatother
\begin{document}

\setlength{\arrayrulewidth}{.5mm}
\setlength{\tabcolsep}{5pt}
\renewcommand{\arraystretch}{2}
{
\begin{table}[h]
\begin{tabular}{ |p{4cm}|p{4cm}|p{4cm}|  }
\hline
Pros& Cons &Price Range \\
\hline
\begin{compactitem}
  \item Simple, easy to use
  \item Low cost to produce
  \item High versatility
\end{compactitem}
& 

\begin{compactitem}
    \item Poor durability
    \item Poor gripping strength for soft materials
\end{compactitem}
& 

\begin{compactitem}
    \item Poor durability
    \item Poor gripping strength for soft materials
\end{compactitem}
\tabularnewline
\hline
\end{tabular}
\caption{ Pros/Cons and Price Range for Category 1}
\label{table:1}
\end{table}
}

\end{document}
5

Some improvements with hhline for the intersections of vertical and horizontal lines, and a simpler code: I defines a new I column type, based on X, which automatically enters and leaves the itemize environment:

\documentclass{article}
\usepackage[showframe]{geometry}
\usepackage{enumitem}
\usepackage{tabularx, hhline}
\usepackage{ragged2e}
\makeatletter
\newcommand*{\compress}{\@minipagetrue}
\makeatother

\newcolumntype{I}{>{\compress\itemize}X <{\enditemize}}

\begin{document}

\begin{table}[h]\setlength{\arrayrulewidth}{1mm}
\setlength{\tabcolsep}{20pt}
\renewcommand{\arraystretch}{2}
\setlist[itemize]{wide=0pt, nosep, leftmargin= *, after=\vspace{-\baselineskip}}
\begin{tabularx}{\linewidth}{ |*{3}{>{\RaggedRight\arraybackslash}I|}}
\hhline{|---|}
\multicolumn{1}{|l|}{Pros} & \multicolumn{1}{l|}{Cons} & \multicolumn{1}{l|}{Price Range} \\
\hhline{|---|}
  \item Simple, easy to use
  \item Low cost to produce
  \item High versatility
&
    \item Poor durability
    \item Poor gripping strength for soft materials
&
    \item Poor durability
    \item Poor gripping strength for soft materials \\
\hhline{|---|}
\end{tabularx}
\caption{ Pros/Cons and Price Range for Category 1}
\label{table:1}
\end{table}

\end{document} 

enter image description here

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.