latex 表格 调整单元格文本垂直居中

在撰写论文时,常常使用table制作表格,不过存在一个问题:单元格内文本顶着上格线,不好看。解决方案有两种思路。

其一:利用multicolumn命令

制作四行四列表格的代码如下:

\begin{center}

\begin{tabular}{ | l | l | l | p{5cm} |}

\hline

Day & Min Temp & Max Temp & Summary \\

\hline

Monday & 11C & 22C & A clear day with lots of sunshine. However, the strong breeze will bring down the temperatures. \\

\hline

Tuesday & 9C & 19C & Cloudy with rain, across many northern regions. Clear spells across most of Scotland and Northern Ireland, but rain reaching the far northwest. \\

\hline

Wednesday & 10C & 21C & Rain will still linger for the morning. Conditions will improve by early afternoon and continue throughout the evening. \\

\hline

\end{tabular}

\end{center}

生成的表格如下:

能看到单元格文字靠近上格线。这里我们需要修改一下命令

主要添加了multicolumn命令,其中

m{5cm}:居中

p{5cm}:顶部

b{5cm}:底部

************************************

\begin{center}

\begin{tabular}{|l|l|l|l|}

\hline

Day & Min Temp & Max Temp & Summary \\

\hline

Monday & 11C & 22C & \multicolumn{1}{|p{5cm}|}{A clear day with lots of sunshine. However, the strong breeze will bring down the temperatures.} \\

\hline

Tuesday & 9C & 19C & \multicolumn{1}{|m{5cm}|}{Cloudy with rain, across many northern regions. Clear spells across most of Scotland and Northern Ireland, but rain reaching the far northwest.} \

\hline

Wednesday & 10C & 21C & \multicolumn{1}{|b{5cm}|}{Rain will still linger for the morning. Conditions will improve by early afternoon and continue throughout the evening.} \\

\hline

\end{tabular}

\end{center}

生成的表格如下:

这种思路设计起来挺麻烦,如果心细,可以做一做。

其二:单元格内容纵向靠上对齐,表线距单元格内容太近。调整表线和单元格内容之间的距离,可以通过重定义 \arraystretch 来解决。

\renewcommand{\arrarstretch}{<number>} % default is 1.0

 感觉这个比较好用,但是这个也是针对每个单元格是单行文本时,才好用。如果单元格是多行文本,则需要使用方法一比较好点。

 参考:https://www.zhihu.com/question/288695777/answer/462924502

  • 12
    点赞
  • 39
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值