如何对具有多行单元格的表格进行编码
我正在尝试用 LaTeX 写一篇短论文,需要添加一个包含 3 列的表格。
+-------------+-----------------+--------------------------------------+
| AAAAAAAAAA | BBBBBBBBBBBBBBB | Betty Botter Bought a Bit of Butter |
| | | but the Butter's Bitter |
+-------------+-----------------+--------------------------------------+
| CCCCCCCC | DDDD | Betty Botter Thought: |
| | | If I Put This Bitter Butter in My |
| | | Batter it Will Make My Batter Bitter |
+-------------+-----------------+--------------------------------------+
不幸的是我似乎找不到正确的习惯用法。
我尝试过:
\begin{tabular}{lll}
AAAAAAAAAA & BBBBBBBBBBBBBBB & Betty Botter Bought a Bit of Butter but
the Butter's Bitter \\
CCCCCCCC & DDDD & Betty Botter Thought: \newline If I Put This Bitter Butter in My Batter it Will Make My Batter Bitter
\end{tabular}
但是 LaTeX 不会在单元格内进行任何换行或格式化。我想我需要告诉它这样做......但是怎么做呢?
I am trying to write a short paper with LaTeX and need to add a table with 3 columns.
+-------------+-----------------+--------------------------------------+
| AAAAAAAAAA | BBBBBBBBBBBBBBB | Betty Botter Bought a Bit of Butter |
| | | but the Butter's Bitter |
+-------------+-----------------+--------------------------------------+
| CCCCCCCC | DDDD | Betty Botter Thought: |
| | | If I Put This Bitter Butter in My |
| | | Batter it Will Make My Batter Bitter |
+-------------+-----------------+--------------------------------------+
Unfortunately I can't seem to find the correct idiom to do it.
I tried:
\begin{tabular}{lll}
AAAAAAAAAA & BBBBBBBBBBBBBBB & Betty Botter Bought a Bit of Butter but
the Butter's Bitter \\
CCCCCCCC & DDDD & Betty Botter Thought: \newline If I Put This Bitter Butter in My Batter it Will Make My Batter Bitter
\end{tabular}
But LaTeX doesn't do any linebreaks or formatting within the cell. I assume I need to tell it to do so.. But how?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
使用
p
列描述符:更改
为
要显式插入换行符:
Use the
p
column descriptor:Change
to
To explicitly insert line-breaks:
这是我到目前为止找到的满足我需求的答案: 链接在这里。
它创建一个新命令,以更正确的方式在表格中创建表格:
因此,如果想在单元格内进行强制换行,如下所示:
您最终将使用如下代码:
可以控制水平对齐在新命令的声明中,将 c@ 更改为 l@ 或 r@
所有功劳均归 egreg 来自 Tex 论坛。为他的回答点赞吧!
This is the answer I found so far for my needs: Link here.
It creates a new command that will make a table inside a table in a more proper way:
So, if want to do a forced line break inside a cell like here:
You will end up using a code like this:
Horizontal alignment can be controlled in the declaration of the new command by changing c@ to l@ or r@
All credit goes to egreg from the Tex forum. Do upvote his answer !
正如 @aioobe 在他的回答中所写,在这种情况下,可以从左对齐切换
到段落对齐,至少在必须手动插入自定义换行符的第三列中:
在此编辑后,一个可以使用命令
\par
(而不是\newline
)来实现单元格内的换行。此代码:
产生请求的输出:
As @aioobe wrote in his answer, in this case one can switch from the left alignment
to the paragraph alignment, at least in the third column where the custom linebreak must be inserted manually:
After this edit, one can use the command
\par
(instead of\newline
) to implement the linebreak within the cell.This code:
produces the output requested:
这是一个没有花哨编码的答案。将各行写在单独的行中。省略除最后一行(行)之外的所有内容的 \hline 它又快又脏,但是,嘿,它确实有效,并且为我提供了我想要的东西,无论如何,对于简单的表格。我正在制作汽车挡风玻璃上的广告。我在每个单元格中有 3 个居中行,
我希望在表格中重复这样做。我只是省略了前两行的 \hline 。多个 \hlines 和 '|'是为了更轻松地剪切打印输出。
我希望这会有所帮助。
Here is an answer with no fancy coding. Write your rows in separate lines. Omit the \hline for all but the last row(line) Its quick and dirty but, hey, it works and gives me exactly what I want, for simple tables anyway. I was making advertising to go on automobile windscreens. I have 3 centered rows in each cell
I wanted this repetitively in my table. I just left out the \hline for the first two rows. The multiple \hlines and '|' are to make cutting up the printout easier.
I hope that this helps.