Latex 让表格宽度与文本宽度相同

这篇博客介绍了如何使用 LaTeX 的 tabular* 环境来创建表格,并展示了单栏和双栏表格的示例。内容包括调整列宽以填充文本宽度,以及通过llllll指定左对齐。示例中给出了参数值的表格,列出了不同参数及其数值。此外,还解释了如何通过改变llllll为c来实现居中对齐。
摘要由CSDN通过智能技术生成

1、方法

使用 tabular*, \hzise 或 \textwidth, 然后加上一些奇怪的符号。

2、单栏

\begin{table}[!ht]
\caption{Parameter values}\label{tab:parametervalues}
\begin{tabular*}{\hsize}{@{}@{\extracolsep{\fill}}lllllllllllll@{}}
\toprule
$p_{t}$  &21  &22  &20  &15  &10  &8   &5   &10  &18  &10  &14  &18\\
\midrule
$c_{t}$  &5   &13  &10  &10  &10  &10  &10  &10  &10  &10  &10  &10\\
$h_{t}$  &10  &5   &5   &5   &5   &5   &5   &5   &5   &5   &5   &5 \\
$s_{t}$  &100 &100 &100 &100 &100 &100 &100 &100 &100 &100 &100 &100\\
$d_{t}$  &30  &45  &50  &55  &45  &55  &90  &80  &90  &65  &80  &70 \\
\bottomrule
\end{tabular*}
\end{table}

该例子中的 llllll 表示左对齐,可以改为 c 居中,r 右对齐。显示效果:
在这里插入图片描述

3、双栏

  • 与单栏不同的是将table改为table*
    在这里插入图片描述
  • 7
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
可以使用`\resizebox`命令将文本框缩放到与表格宽度相同的大小。具体操作步骤如下: 1. 在导言区添加`\usepackage{graphicx}`,调用该包。 2. 在文本框前后分别添加`\resizebox{\linewidth}{!}{...}`命令,其中`\linewidth`表示文本宽度为行,`!`表示高度按比例自适应。 例如,以下代码将文本宽度设置为表格宽度,并使文本框内容居中对齐: ```latex \documentclass{article} \usepackage{graphicx} \begin{document} \begin{tabular}{|c|c|} \hline Title 1 & Title 2 \\ \hline \resizebox{\linewidth}{!}{% \centering Some text here. Some text here. Some text here. Some text here. Some text here. Some text here. Some text here. Some text here. Some text here. Some text here. Some text here. Some text here. Some text here. Some text here. Some text here. Some text here. Some text here. Some text here. Some text here. Some text here. Some text here. Some text here. Some text here. Some text here. Some text here. Some text here. Some text here. Some text here. Some text here. Some text here. Some text here. Some text here. Some text here. Some text here. Some text here. Some text here. Some text here. Some text here. Some text here. Some text here. Some text here. Some text here. Some text here. Some text here. Some text here. Some text here. Some text here. Some text here. Some text here. Some text here. Some text here. Some text here. Some text here. Some text here. Some text here.% } \\ \hline \end{tabular} \end{document} ``` 注意,`\resizebox`命令会按比例缩放文本框的内容,因此可能会影响排版效果。如果需要保持原来的字号和行距,请考虑其他方法,例如自定义表格列格式或使用`\parbox`命令。
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值