Latex三线表格编辑
1.原始表格如图:
实现代码如下:
\begin{table}[htbp]
\centering #表格居中
\begin{tabular}{lccc} # 'l'表示该列靠左,'c'表示该列居中
\hline & NN & CC & AA \\ #hline就是三线表中的线
\hline MM & 0.5808 & 0.4700 & 0.1437 \\ #'\\'表示换行, 列用&隔开
KK & 0.5990 & 0.5333 & 0.0977 \\
DD & 0.6439 & 0.6300 & 0.1677 \\
RR & $ \mathbf{0.6845} $ & $ \mathbf{0.7333} $ & $ \mathbf{0.2700} $ \\
\hline #\mathbf 表示加粗
\end{tabular}
\caption{Caption.} #标题
\end{table}
增大或者缩小行间距
加入\renewcommand\arraystretch{1.3},花括号中的数字可以根据情况调整,效果图如下:
代码如下:
\begin{table}[htbp]
\renewcommand\arraystretch{1.3}
\centering
\begin{tabular}{lccc}
\hline & NN & CC & AA \\
\hline MM & 0.5808 & 0.4700 & 0.1437 \\
KK & 0.5990 & 0.5333 & 0.0977 \\
DD & 0.6439 & 0.6300 & 0.1677 \\
RR & $ \mathbf{0.6845} $ & $ \mathbf{0.7333} $ & $ \mathbf{0.2700} $ \\
\hline
\end{tabular}
\caption{Caption.}
\end{table}
调整表格宽度
若表格过窄,加入代码\setlength{\tabcolsep}{7mm}{tabular},tabular为\begin{tabular}\end{tabular}内容。数字可以根据情况调整,效果图如下:
代码如下:
\begin{table}[htbp]
\renewcommand\arraystretch{1.3}
\centering
\setlength{\tabcolsep}{4mm}{
\begin{tabular}{lccc}
\hline & NN & CC & AA \\
\hline MM & 0.5808 & 0.4700 & 0.1437 \\
KK & 0.5990 & 0.5333 & 0.0977 \\
DD & 0.6439 & 0.6300 & 0.1677 \\
RR & $ \mathbf{0.6845} $ & $ \mathbf{0.7333} $ & $ \mathbf{0.2700} $ \\
\hline
\end{tabular}}
\caption{Caption.}
\end{table}