-
2021-03-12 17:43:25
Latex 表格文字居中(垂直和水平居中)
可能由于设置latex表格列宽过小导致的文字不居中(垂直和水平居中)
解决办法:采用如下改动:m代表middle,|为表格竖线,2.5cm代表列宽,<{centering}为居中.
\begin{tabular}{m{1cm}<{\centering}|m{1cm}<{\centering}|m{1cm}<{\centering}|m{1cm}<{\centering}}
需要导入array包: \usepackage{array}
参考这 https://www.freesion.com/article/6635554950/
若仍然不行:内容缩写吧!abbr.更多相关内容 -
latex表格水平垂直居中
2021-02-10 10:33:40m表示垂直居中,2cm表示该单元格水平宽度2厘米。 那水平居中怎么办呢? 在后面加<{\centering} 注意有多少列,就要加多少个参数,每一列的参数可以不同。 用如下代码,注意\begin{tabular}后面的参数部分: %注意...网上的方法杂七杂八,有些用multicolumn的,很麻烦,后来参考了很多地方,总结除了自己的经验。
首先最前面加入包:
\usepackage{array}
然后在\begin{tabular}后面加参数m{2cm}
m表示垂直居中,2cm表示该单元格水平宽度2厘米。那水平居中怎么办呢?
在后面加<{\centering}注意有多少列,就要加多少个参数,每一列的参数可以不同。
用如下代码,注意\begin{tabular}后面的参数部分:
%注意最前面加包\usepackage{array} \begin{table}[H] \caption{\centering\textbf{Data of five kinds of fungi}}%标题 \label{tab:0003} \centering%把表居中 <{\centering}p{1cm}<{\centering}p{2cm}<{\centering}p{2cm}<{\centering} \begin{tabular}{m{2cm}<{\centering}m{1cm}<{\centering}m{1cm}<{\centering}m{1cm}<{\centering}m{1cm}<{\centering}m{1cm}<{\centering}m{2cm}<{\centering}m{2cm}<{\centering}} \toprule[1.5pt]%第一道横线 Populations name & $k$ & $p$ & $s$ & $b$ & $m$ & Enzymatic activity in $22^\circ$C & Max extension rate in $22^\circ$C\\ \midrule[1pt]%第二道横线 AG-C6D & $19.77$ & $27.19$ & $13.67$ & $0.45$ & $0.29$ & $17.1161$ & $0.34$ \\ \midrule[0.5pt] HC-B7B & $15.53$ & $19.1$& $8.019$& $0.55$& $0.074$& $13.6261$& $1.77$ \\ \midrule[0.5pt] AG-A5A & $29.82$ & $44.9$& $22.93$& $0.52$& $-0.13$& $10.9989$& $0.32$ \\ \midrule[0.5pt] XS-A11A & $9.232$ & $19.75$& $8.106$& $0.55$& $-0.36$& $8.5474$& $1.04$ \\ \midrule[0.5pt] TC-B10F & $32.19$ & $25.77$& $11.77$& $0.55$& $0.79$& $29.0512$& $5.67$ \\ \bottomrule[1.5pt]%第三道横线 \end{tabular} \label{table:data} \end{table}
效果图:
-
Latex-表格内容垂直居中
2018-12-29 14:35:18Latex表格内容垂直居中 Latex内容的编写经常会涉及到Excel表格的编写,但是直接按照正常的方式编写那么就会使得文字不能居中显示,所以下述给出Excel文字垂直居中的方法。 首先记得导入array包。\usepackage{array} ...Latex表格内容垂直居中
Latex内容的编写经常会涉及到Excel表格的编写,但是直接按照正常的方式编写那么就会使得文字不能居中显示,所以下述给出Excel文字垂直居中的方法。
首先记得导入array包。\usepackage{array}
这样才能使用m{7cm}的指令,是使得Excel中的内容垂直居中显示。
我的代码如下,数字请忽略。\begin{table*} \centering \caption{A segment of the "Wide-angle eye" dataset with direction strategy labels} \begin{tabular}{|c|| m{7cm} |c|} \hline \bfseries Index & \bfseries 5$\times$5 "Wide-angle Eye" Data & \bfseries Direcion Strategy Label\\ \hline \hline \bfseries 1 & \begin{equation} \left( \begin{array}{ccccc} 116.81 & 21.14 & 109.43 & 72.00 & 1.90\nonumber\\ 115.83 & 18.83 & 109.67 & 71.30 & 1.86\nonumber\\ 115.51 & 18.27 & 109.91 & 69.68 & 1.87\nonumber\\ 115.83 & 21.76 & 109.46 & 70.83 & 1.90\nonumber\\ 115.83 & 21.30 & 110.87 & 72.22 & 1.90\nonumber\\ \end{array} \right) \end{equation} & \bfseries-1\\ \hline \bfseries 2 & \begin{equation} \left( \begin{array}{ccccc} 115.83 & 18.83 & 109.67 & 71.30 & 1.86\nonumber\\ 115.51 & 18.27 & 109.91 & 69.68 & 1.87\nonumber\\ 115.83 & 21.76 & 109.46 & 70.83 & 1.90\nonumber\\ 115.83 & 21.30 & 110.87 & 72.22 & 1.90\nonumber\\ 115.83 & 21.14 & 111.57 & 72.00 & 1.89\nonumber\\ \end{array} \right) \end{equation} & \bfseries-1\\ \hline \bfseries 3 & \begin{equation} \left( \begin{array}{ccccc} 130.42 & 42.75 & 119.93 & 84.26 & 2.07\nonumber\\ 128.47 & 40.27 & 120.63 & 84.50 & 2.07\nonumber\\ 122.64 & 38.89 & 120.41 & 82.18 & 2.07\nonumber\\ 122.00 & 38.89 & 120.43 & 81.71 & 2.07\nonumber\\ 121.67 & 38.89 & 120.67 & 81.25 & 2.06\nonumber\\ \end{array} \right) \end{equation} & -1\\ \hline \bfseries 4 & \begin{equation} \left( \begin{array}{ccccc} 92.50 & 48.61 & 113.57 & 67.36 & 1.95\nonumber\\ 92.50 & 45.52 & 113.81 & 67.89 & 1.94\nonumber\\ 92.50 & 44.44 & 114.06 & 67.59 & 1.92\nonumber\\ 92.82 & 43.20 & 114.07 & 67.82 & 1.95\nonumber\\ 95.42 & 45.37 & 114.09 & 67.82 & 1.91\nonumber\\ \end{array} \right) \end{equation} & \bfseries 0\\ \hline \bfseries 5 & \begin{equation} \left( \begin{array}{ccccc} 92.50 & 45.52 & 113.81 & 67.89 & 1.94\nonumber\\ 92.50 & 44.44 & 114.06 & 67.59 & 1.92\nonumber\\ 92.82 & 43.20 & 114.07 & 67.82 & 1.95\nonumber\\ 95.42 & 45.37 & 114.09 & 67.82 & 1.91\nonumber\\ 95.42 & 45.99 & 113.87 & 68.98 & 1.95\nonumber\\ \end{array} \right) \end{equation} & \bfseries 0\\ \hline \bfseries 6 & \begin{equation} \left( \begin{array}{ccccc} 137.67 & 42.57 & 109.90 & 65.11 & 1.98\nonumber\\ 137.67 & 44.09 & 108.84 & 65.36 & 2.00\nonumber\\ 149.97 & 37.95 & 109.09 & 65.36 & 2.00\nonumber\\ 135.50 & 48.77 & 108.84 & 65.61 & 1.97\nonumber\\ 122.12 & 48.78 & 109.09 & 65.61 & 1.96\nonumber\\ \end{array} \right) \end{equation} & \bfseries +1\\ \hline \end{tabular} \label{tbl:table4} \end{table*}
最后latex编译得到的图片如图所示。
这样就可以编辑出一个很棒的Excel表格了。
谢谢大家。
如果还有什么关于Latex编辑的问题可以互相讨论。 -
latex怎么让表格里的字上下垂直居中?
2020-12-24 04:58:27试了一下,LaTeX表格中的单元格在单行的情况下在竖直方向上应该是垂直居中的,所以我猜测您的问题应该是在限定了列宽之后由于自动换行导致的其他列无法做到在竖直上居中,解决方法是使用multicolumn命令,以下为简单...试了一下,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 heighttex.stackexchange.com
Horizontal and vertical alignment int tabular cellstackoverflow.com
ps: 个人之前并没有遇到您这样的问题,但是受人之邀,却之不恭,所以查了一些资料,结合自己的理解有了上面的回答,有任何问题欢迎批评指正,也希望能借此机会抛砖引玉,有大佬给出更靠谱的解答;
pps: 个人之见,这种问题三言两语很难说清楚,因为无法判断究竟问题出在哪,所以如果我理解有误,请您再详细说明,最好有代码,我们可以再讨论。
以上
供参考
-
Latex 设置表格字体垂直居中且水平居中,字体放在表格最中央之简单好用的方法
2020-04-10 12:53:28我相信许多人在使用Latex制作表格的时候,都遇到过表格中的文字不能垂直居中的问题。 本例子是在表格中插入图片作为例子的: \begin{figure} \centering \begin{tabular}{cccc} % 表格中的PXX代表图片 \... -
Latex表格换行垂直居中对齐
2019-06-01 09:42:53最近在用Latex绘制表格,遇到了两个问题,记录一下。 1、一个是某一单元格内容过长,换行的问题 关键代码:\begin{tabular}{|l|p{7.3cm}|} 网上查找说可以用p{}来控制列的宽度,如p{7.3cm}表示控制表格的最大宽度... -
latex 表格 调整单元格文本垂直居中
2019-02-25 23:05:06在撰写论文时,常常使用table制作表格,不过存在一个问题:单元格内文本顶着上格线,不好看。解决方案有两种思路。 其一:利用multicolumn命令 制作四行四列表格的代码如下: \begin{center} \begin{tabular}{ | ... -
latex表格中的字上下垂直居中
2019-03-26 19:36:16单元格内容纵向靠上对齐,而是表线距单元格内容太近。调整表线和单元格内容之间的距离,可以通过重定义 \arraystretch 来解决。 \renewcommand{\arrarstretch}{<number>} % default is 1.0 后续讨论tabular... -
Latex 表格内容自动换行居中
2020-07-24 11:46:011、在导言区添加宏包:\usepackage{makecell} ...*[c]水平 + 垂直居中,*[l]垂直居中 + 水平左居中,*[r]垂直居中 + 水平右居中。 注意:makecell里文本内容想换行,就用 \\ 分隔即可;该方法适用于指定换行的地方 ... -
LaTex表格内单元格内容换行
2020-12-24 04:58:32如何同时让表格同一行一个单元格的文字能垂直居中?比如说文字超长超出页面范围需要分行显示。 ~~~newcommand{tabincell}[2]{begin{tabular}{@{}#1@{}}#2end{tabular}}%放在导言区%然后使用 tabincell{c}{} 就可以在... -
Latex: 表格中 自动换行居中
2021-01-05 10:17:261、在导言区添加宏包: \usepackage{makecell} 2、环境:tabular 命令: \makecell[居中情况]{第1行内容 \\ 第2行内容 \\ 第3行...[c]水平 + 垂直居中,[l]垂直居中 + 水平左居中,*[r]垂直居中 + 水平右居中。 ... -
latex设置表格每一列的宽度、表格内容居中
2020-09-20 12:21:37并且希望表格中的内容 上下左右 居中 方法 开头加入 \usepackage{array} \newcolumntype{C}[1]{>{\centering}p{#1}} \setlength{\parindent}{15pt} \begin{center} \begin{tabular}{|m{4cm}<{\centering}|m{... -
利用Latex在线表格绘制表格以及多行合并垂直居中
2020-05-07 00:10:31利用Latex在线表格绘制表格以及多行合并垂直居中 之前用latex绘制表格时都是直接写程序,但是对于复杂的表格,自己设计程序以及书写程序时非常麻烦,在用latex写论文时表格的绘制就花费了非常多的时间,要是绘制的... -
latex表格行高、文本居中
2013-04-25 10:36:51latex表格行高、文本居中 m{7cm}垂直居中 加array宏包 -
latex实现横竖均居中
2021-01-16 00:05:28首先导入必须的包 \usepackage{array} \begin{tabular}{|m{3.5cm}<{\centering}|m{2cm}<...其实3.5cm表示每一列的列宽度,m表示垂直居中,可选项为b(置底),p(置顶)。主要在于表头设置,以及必... -
Excel表格转latex以及转换后的表格边框截断解决、加粗和内容水平垂直居中
2022-03-16 18:27:33Excel 转 latex代码 第一步:下载 excel2latex CTAN: /tex-archive/support/excel2latex 第二步:解压 excel2latex 第三步:打开Excel,在 文件->选项->信任中心->信任中心设置->宏设置... -
求助大佬关于latex表格排版(左右上下居中)问题
2021-02-06 23:30:58该楼层疑似违规已被系统折叠隐藏此楼查看此楼\subsection{Apparatus}\begin{table}[H]\centering\begin{tabular}{|m{3cm}\hline\centeringApparatus & \centering Usages & Actual Photos \\\hline1.... -
LaTeX:表格内字体换行与各种居中完美解决
2020-10-26 16:21:32需求1:有时表格内某个单元内容太多,需要换行! 需求2:有时表格内某个"单元...命令:\makecell[居中情况]{第1行内容 \\ 第2行内容 \\ 第3行内容 ...} 参数说明: [c]是水平居中,[l]水平左居中,[r]水平右居中; *[c -
表格内容垂直居中
2021-02-06 23:31:00下面的例子提供了「强行让单元格内容纵向居中」的方案,仅作为一种技术实现,不推荐实际使用(因为这种效果打破了排版的惯例)。\documentclass[a4paper]{ctexart}\usepackage{amsmath}\usepackage{amssymb}\... -
LaTeX表格紧跟文字 (不影响下方文本对齐)
2020-12-24 04:59:22Latex 表格内文字过长自动换行法一: [plain]view plaincopy \begin{tabular}{m{5cm}} 法二: [plain]view plaincopy \begin{tabular}{p{0.9\ ...Latex 表格内公式换行方法Latex 表格内的公式实现换行的方法 简单的两... -
LaTeX:表格内换行与各种居中完美解决
2020-12-22 22:52:18需求1:有时表格内某个单元内容太多,需要换行!需求2:有时表格内某个"单元需要枚举"!即多次换行;每个每个枚举项内容少但是长度不一,此时需要"左居中 + 手动设置每项缩进"!宏包:\usepackage{makecell}环境:... -
Latex实例[1]:合并单元格并居中
2021-09-17 19:15:01在绘制表格的过程中,常常会遇到需要合并单元格的情况,在本次举例中,我们要达到如下图所示的效果: [0][0]和[0][1]两个单元格合并 [1][0]、[2][0]、[3][0]、[4][0]四个单元格合并 …… 解决办法 这其中主要分成两... -
OverLeaf中写LaTeX将表格的标题居中
2019-05-31 15:01:43如下修改方式: 其中*******为具体的标题。 \caption{\centering *************} -
LATEX关于表格的一些处理
2020-07-05 15:21:18文章目录1、表格初步1.1 导言区11.2 导言区21.3 其他指令2、单元格的合并2.1 按照列合并2.2 按照行合并2.3 多行列合并3 列的设置技巧3.1 固定列宽设置(水平对齐)3.2 固定列宽设置(垂直左中右对齐)3.3 列设置(设置... -
Latex 表格中内容过于贴近表线 解决方案
2021-11-19 12:34:11做表格的时候总是遇到文字贴近边线 明明设置了居中但还是上下飘???? 后来发现是设置了\hline的原因,改成\cline{n-m} 就能完美解决哈哈! 效果如下: (虽然是个小问题,但真的找了好久的原因 我哭。) ... -
LaTex 表格p m b在单元格内部上 中 下
2022-01-04 20:42:29示例 \begin{tabularx}{\textwidth}{p{4 cm} m{4 cm} b{7 cm}} -
latex表格调整单元格宽度
2022-06-21 09:06:54latex表格宽度与居中。