latex 三线表 与调整表格与上下文的间距

最近遇到要用Latex画三线表,时间紧不能去细细了解每句功能,记录一下后面参考别人画的表格,以后可以直接移植。三线表只是实现最普通的功能,想要的风格是两边没有竖线,而且中间的表格需要占两行,由于用到了\multirow行合并指令,我添加了两个宏包\usepackage{multirow},\usepackage{booktabs}。
在这里插入图片描述
这个表由于不对称看起来有点别扭,不过作为以后别的表格改进的基础版也是可以的。(3,8)和(4,5,9,10)之间的竖线调了挺久,因为不是贯穿到底的直线,注意\vline指令的使用。下面粘出具体的代码。

\renewcommand{\multirowsetup}{\centering}
\begin{center}
\begin{tabular}{ll|llll}
\cline{2-3}
\multirow{2}{2cm}{}
       & \multirow{2}{5cm}{1}
       & \multirow{2}{6cm}{2} \\&\\
\hline
\multirow{2}{2cm}{3}
        & \vline \multirow{2}{5cm}{4 \\5}
        & \multirow{2}{6cm}{6 \\ 7}
        & \\ &\vline\\
\hline
\multirow{2}{2cm}{8}
        & \vline \multirow{2}{5cm}{9 \\ 10}
        & \multirow{2}{6cm}{11 \\ 12}
        & \\ & \vline \\
\hline
\end{tabular}
\end{center}

后面还是用回了最普通的形式,很多论文都是采用的这样的表格,简单大方:在这里插入图片描述

\renewcommand{\multirowsetup}{\centering}
\begin{center}
\begin{tabular}{l|l|llll}
\hline
\multirow{2}{2cm}{}
       & \multirow{2}{5cm}{1}
       & \multirow{2}{6cm}{2} \\&\\
\hline
\multirow{2}{2cm}{3}
        &  \multirow{2}{5cm}{4 \\5}
        & \multirow{2}{6cm}{6 \\ 7}
        & \\ &\\
\hline
\multirow{2}{2cm}{8}
        &  \multirow{2}{5cm}{9 \\ 10}
        & \multirow{2}{6cm}{11 \\ 12}
        & \\ & \\
\hline
\end{tabular}
\end{center}

表格完成后发现与上下文间距太大了,用\setlength{\abovecaptionskip}{-0.15cm}、\setlength{\belowcaptionskip}{-1cm}这两个指令的效果不太好,调整表格标题与上文间距还行,但是与下文的间距就完全不起作用了。后面发现用\vspace{-0.8cm}这个指令效果很好,要调整与下文间距就再用一次就可以了。下面粘出最终的成果。
在这里插入图片描述

This is a demo.

\renewcommand{\multirowsetup}{\centering}
\vspace{-0.8cm}
\begin{table}
\caption{The caption.}
\begin{center}
\begin{tabular}{l|l|llll}
\toprule
\multirow{2}{2cm}{}
       & \multirow{2}{5cm}{1}
       & \multirow{2}{6cm}{2} \\&\\
\midrule
\multirow{2}{2cm}{3}
        &  \multirow{2}{5cm}{4 \\5}
        & \multirow{2}{6cm}{6 \\ 7}
        & \\ &\\
\hline
\multirow{2}{2cm}{8}
        &  \multirow{2}{5cm}{9 \\ 10}
        & \multirow{2}{6cm}{11 \\ 12}
        & \\ & \\
\bottomrule
\end{tabular}
\end{center}
\end{table}
\vspace{-0.8cm}
This is a demo.
  • 7
    点赞
  • 30
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值