latex表格内容上下居中_latex怎么让表格里的字上下垂直居中?

试了一下,LaTeX表格中的单元格在单行的情况下在竖直方向上应该是垂直居中的,所以我猜测您的问题应该是在限定了列宽之后由于自动换行导致的其他列无法做到在竖直上居中,解决方法是使用multicolumn命令,以下为简单说明:(Example chosen from WikiBook: LaTeX/Tables)

最开始的代码:

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

输出结果见下图

修改后的代码:

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

输出结果:

Note.关于multicolumn的具体用法应该比较容易了解,上面WikiBook关于table的介绍中也有具体说明,pmb为对齐格式,较为详细的说明参考 p,m and b columns in tables;

multicolumn的第三个参数必须是产生多列的paragraph;

关于表格的基本内容请参考Section 3.6 表格, lshort-zh-c, version 5.05 (个人LaTeX学习的主要参考,比较推荐)

可能对解决这个问题有帮助的几个类似的问题:Vertical alignment in tabular cells with variable height​tex.stackexchange.comHorizontal and vertical alignment int tabular cell​stackoverflow.com

ps: 个人之前并没有遇到您这样的问题,但是受人之邀,却之不恭,所以查了一些资料,结合自己的理解有了上面的回答,有任何问题欢迎批评指正,也希望能借此机会抛砖引玉,有大佬给出更靠谱的解答;

pps: 个人之见,这种问题三言两语很难说清楚,因为无法判断究竟问题出在哪,所以如果我理解有误,请您再详细说明,最好有代码,我们可以再讨论。

以上

供参考

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值