latex - 如何在表格环境中垂直居中文本?
问题描述
我有一个包含 3 列的表格,其中前 2 列是图片,第三列是我对这些图片的评论,但评论“淹没”,它位于单元格的底部。
我试过用m{2cm}
而不是c
:
\begin{tabularx}{\textwidth}{c c m{2cm}}
但没有变化。
\begin{table}
\caption{Caption if needed}
\label{tab:lastcheck}
\begin{tabularx}{\textwidth}{c c c}
\textbf{O-Na} & \textbf{Na-Y} & \textbf{Comments} \\
\includegraphics[width=0.3\linewidth]{pic1.png} &
\includegraphics[width=0.3\linewidth]{pic2.png} &
My comments. \\
\end{tabularx}
\end{table}
我的文字在单元格的底部。
解决方案
提供了垂直居中图像的graphbox
方便选项:align=c
\documentclass{article}
\usepackage{tabularx}
\usepackage{array}
\usepackage{graphicx}
\usepackage{graphbox}
\usepackage{makecell}
\renewcommand\theadfont{\bfseries}
\begin{document}
\begin{table}
\caption{Caption if needed}
\label{tab:lastcheck}
\begin{tabularx}{\textwidth}{XXX}
\thead{O-Na} & \thead{Na-Y} & \thead{Comments} \\
\includegraphics[width=\linewidth,align=c]{example-image-duck} &
\includegraphics[width=\linewidth,align=c]{example-image-duck} &
My comments. \\
\end{tabularx}
\end{table}
\end{document}
推荐阅读
- javascript - mongodb从数组中提取对象不使用猫鼬
- python - 如何在 pyspark 中处理 Glue 数据目录中的空表
- amazon-web-services - EC2 专用实例是否共享 RAM 带宽?
- c# - 如果禁用/启用对撞机,动画师将不再工作
- sql-server - 我可以将 SSRS 2008 R2 与 SQL Server 2008 数据库一起使用吗?
- html - 样式输入类型编号更多加号按钮在侧面
- search - vim 让搜索和替换为增量
- css - 如何更改轮播中图标的颜色?
- r - 什么正则表达式可以让我在单词之前或之后找到最接近单词的数字
- php - 如何使用 ODBC 在 PHP 中调用 MSSQL 存储过程并检索输出参数