我想在报告中制作一个正式的表格。我使用了以下代码;但是,我仍然需要删除单元格内容和数据之间的间隙以节省空间。另外,我想将单元格垂直居中,尤其是第一列
\documentclass[letterpaper,oneside,12pt]{book}
\usepackage[letterpaper, inner=2.5 cm, outer=2.5cm, bottom=2.5cm, dvips]{geometry}
\usepackage{tabularx,booktabs,makecell,multirow}
\usepackage{enumitem} % to control Itemization spacing
\newcolumntype{L}{>{\raggedright\arraybackslash}X}
\renewcommand\theadfont{\bfseries}
\begin{document}
\begin{table}[htb]
\centering
\vspace{0.5cm}
\caption{\small{Comparison between GPS and INS characteristics}}
\vspace{0.5cm}
\begin{tabularx}{\textwidth}{l L L}
\toprule
& \thead{GPS} & \thead{INS} \\
\midrule
\multirow{4}{*}{\textbf{Advantages}}
&
\begin{itemize}[noitemsep,topsep=0pt]
\item Errors are bounded
\item Long term accuracy
\item Relatively low cost
\end{itemize}
&
\begin{itemize}[noitemsep,topsep=0pt]
\item High data rate
\item Self-contained and independent of jamming
\item Gives attitude information
\item Short term accuracy
\end{itemize} \\
\midrule %\cmidrule{2-3}
\multirow{4}{*}{\textbf{Disadvantages}}
&
\begin{itemize}[noitemsep,topsep=0pt]
\item Low data rate
\item Susceptible to jamming and interference
\item Fails if no sufficient coverage
\item No attitude information for standard receivers
\end{itemize}
&
\begin{itemize}[noitemsep,topsep=0pt]
\item Errors grow with time
\item Higher cost for higher quality
\end{itemize} \\
\bottomrule
\end{tabularx}
\label{tab:GPS_INS_comparison}
\end{table}
\end{document}
这是我的输出
答案1
如果您希望减少空间,那么您选择了错误的表格环境(booktabs
在空间方面很慷慨)。因此,我建议执行以下操作(只有在没有其他选择时才应这样做;这些不是好的做法):
- 摆脱
booktabs
- 更重要的是,通过转置来重塑你的表格。转置背后的原因是单词缺点比全球定位系统。
- 设置
\arraystretch
为 0 - 安全地设置
\tabcolsep
为非常小/负的值 - 选择
\small
整个桌子不会有害 - 照顾周围的
itemize
环境
最后可以得到这样的结果:
以下是 MWE:
\documentclass[letterpaper,oneside,12pt]{book}
\usepackage[letterpaper, inner=2.5 cm, outer=2.5cm, bottom=2.5cm, dvips]{geometry}
\usepackage{tabularx,booktabs,makecell,multirow,array}
\usepackage{enumitem} % to control Itemization spacing
\renewcommand{\tabularxcolumn}[1]{>{\raggedright\arraybackslash}m{#1}}
\newcolumntype{L}{>{\arraybackslash}X}
\renewcommand\theadfont{\bfseries}
\begin{document}
\begin{table}[htb]
\small
\caption{Comparison between GPS and INS characteristics}
\renewcommand{\arraystretch}{0}
\setlength{\tabcolsep}{-1pt}
\centering
\begin{tabularx}{\textwidth}{lLL}
\hline
& \thead{Advantages} & \thead{Disadvantages} \\
\hline
\textbf{GPS}
&
\begin{itemize}[noitemsep,topsep=0pt]
\item Errors are bounded
\item Long term accuracy
\item Relatively low cost
\end{itemize}
&
\begin{itemize}[noitemsep,topsep=0pt]
\item Low data rate
\item Susceptible to jamming and interference
\item Fails if no sufficient coverage
\item No attitude info. for standard receivers
\end{itemize}\\[-.35cm]
\hline %\cmidrule{2-3}
\textbf{INS}
&
\begin{itemize}[noitemsep,topsep=0pt]
\item High data rate
\item Self-contained and jamming independent
\item Gives attitude information
\item Short term accuracy
\end{itemize}
&
\begin{itemize}[noitemsep,topsep=0pt]
\item Errors grow with time
\item Higher cost for higher quality
\end{itemize}\\[-.35cm]
\hline
\end{tabularx}
\label{tab:GPS_INS_comparison}
\end{table}
\end{document}
答案2
那是你要的吗?
\documentclass[letterpaper,oneside,12pt]{book}
\usepackage[letterpaper, inner=2.5 cm, outer=2.5cm, bottom=2.5cm, dvips]{geometry}
\usepackage{tabularx,booktabs,makecell,multirow, caption}
\usepackage{enumitem} % to control Itemization spacing
\renewcommand{\tabularxcolumn}[1]{>{\raggedright\arraybackslash}m{#1}}
\newcolumntype{L}{>{\arraybackslash}X}
\renewcommand\theadfont{\bfseries}
\begin{document}
\begin{table}[htb]
\centering\setlist[itemize, 1]{noitemsep,topsep=0pt, wide=0pt, leftmargin =\dimexpr \labelwidth+ 2\labelsep\relax, after=\vspace*{\dimexpr-4\partopsep}}
\caption{\small{Comparison between GPS and INS characteristics}}
\begin{tabularx}{\textwidth}{lLL}
\toprule
& \thead{GPS} & \thead{INS} \\
\midrule
\textbf{Advantages}
&
\begin{itemize}
\item Errors are bounded
\item Long term accuracy
\item Relatively low cost
\end{itemize}
&
\begin{itemize}
\item High data rate
\item Self-contained and independent of jamming
\item Gives attitude information
\item Short term accuracy
\end{itemize} \\
\midrule %\cmidrule{2-3}
\textbf{Disadvantages}
&
\begin{itemize}
\item Low data rate
\item Susceptible to jamming and interference
\item Fails if no sufficient coverage
\item No attitude information for standard receivers
\end{itemize}
&
\begin{itemize}
\item Errors grow with time
\item Higher cost for higher quality
\end{itemize} \\
\bottomrule
\end{tabularx}
\label{tab:GPS_INS_comparison}
\end{table}
\end{document}