表中项目符号

表中项目符号

我想在一个简单的表格中添加项目符号。但是,我在格式化方面遇到了麻烦。文本间距不均匀,并且表格背面的最后一行无法接受

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

有人有建议吗?

答案1

在该包的帮助下,enumitem您可以获得以下结果:

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

在此处输入图片描述

答案2

我使用了 的组合\usepackage{paralist}+{compactitem}

在此处输入图片描述

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

答案3

hhline对垂直线和水平线交叉点进行了一些改进,并且代码更简单:我定义了一种I基于的新列类型,X它会自动进入和离开 itemize 环境:

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

在此处输入图片描述

相关内容