How to wrap text in LaTeX tables?
I am creating a report in LaTeX which involves a few tables. I'm stuck on that as my cell data in the table is exceeding the width of the page. Can I somehow wrap the text so that it falls into the next line in the same cell of the table?
Is it somehow related to the table's width? But as it's overshooting the page's width, it won't make a difference, will it?
使用p {width}代替你的列说明符而不是l / r / c。
begin{tabular}{|p{1cm}|p{3cm}|}
This text will be wrapped & Some more text
end{tabular}
With the regular tabular
environment, you want to use the p{width}
column type, as marcog indicates. But that forces you to give explicit widths.
Another solution is the tabularx
environment:
usepackage{tabularx}
...
begin{tabularx}{linewidth}{ r X }
right-aligned foo & long long line of blah blah that will wrap when the table fills the column width
end{tabularx}
All X columns get the same width. You can influence this by setting hsize
in the format declaration:
>{setlengthhsize{.5hsize}} X >{setlengthhsize{1.5hsize}} X
but then all the factors have to sum up to 1, I suppose (I took this from the LaTeX companion). There is also the package tabulary
which will adjust column widths to balance row heights. For the details, you can get the documentation for each package with texdoc tabulary
(in TeXlive).
另一种选择是在需要文本换行的每个单元中插入一个小型文件,例如:
begin{table}[H]
begin{tabular}{l}
begin{minipage}[t]{0.8columnwidth}%
a very long line a very long line a very long line a very long line
a very long line a very long line a very long line a very long line
a very long line a very long line a very long line %
end{minipage}tabularnewline
end{tabular}
end{table}
链接地址: http://www.djcxy.com/p/33406.html
上一篇: 如何更改LaTeX中的文档字体?
下一篇: 如何在LaTeX表格中包装文字?