我一直在和乳胶桌摔跤太久了。我需要一个具有居中标题的表格,以及包含可能环绕的文本的正文单元格。由于环绕要求,我使用p {xxx}而不是l来指定单元格宽度。这导致的问题是单元格内容没有左对齐,所以看起来像是间隔开的垃圾。为了解决这个问题,我正在为每个单元格使用\ flushleft。这确实留下了合理的内容,但在单元格内容的上方和下方放入了大量的空白区域。有没有办法停止\ flushleft(或\ center),以阻止添加大量的真实空白?
感谢
\begin{landscape}
\centering
% using p{xxx} here to wrap long text instead of overflowing it
\begin{longtable}{ | p{4cm} || p{3cm} | p{3cm} | p{3cm} | p{3cm} | p{3cm} |}
\hline
&
% these are table headings. the \center is causing a ton of whitespace as well
\begin{center} \textbf{HTC HD2} \end{center} &
\begin{center} \textbf{Motorola Milestone} \end{center} &
\begin{center} \textbf{Nokia N900} \end{center} &
\begin{center} \textbf{RIM Blackberry Bold 9700} \end{center} &
\begin{center} \textbf{Apple iPhone 3GS} \end{center} \\
\hline
\hline
% using flushleft here to left-justify, but again it is causing a ton of white space above and below cell contents.
\begin{flushleft}OS / Platform \end{flushleft}&
\begin{flushleft}Windows Mobile 6.5 \end{flushleft}&
\begin{flushleft}Google Android 2.1 \end{flushleft}&
\begin{flushleft}Maemo \end{flushleft}&
\begin{flushleft}Blackberry OS 5.0 \end{flushleft}&
\begin{flushleft}iPhone OS 3.1 \end{flushleft} \\
\hline
编辑:
感谢目前为止的答案。我以为我找到了一个有效的解决方案,但这些问题仍然存在:
使用\ raggedright仅在以空白行结束时才有效。这会导致每个单元格底部都有一个完全空白的行。这是我首先要避免的。
{Display} &
{\raggedright 4.3 inch, 800 x 400 resolution} &
{\raggedright 3.7 inch, 854 x 480 resolution} &
{\raggedright 3.5 inch, 800 x 480 resolution} &
{\raggedright 2.44 inch, 320 x 480 resolution} &
{\raggedright 3.5 inch, 480 x 320 resolution} \\
\hline
答案 0 :(得分:3)
你应该可以指定身体细胞的形成方式
仅将标题更改为以multicolumn
为中心。那样你就没有
不得不像现在这样捣乱过多的细胞。
\documentclass{article}
\begin{document}
\begin{table}
\centering
\begin{tabular}{l|p{2cm}|p{2cm}}
\multicolumn{1}{c}{A} &
\multicolumn{1}{c}{B} &
\multicolumn{1}{c}{C} \\
1 & {Some longer text} & {Some other text}\\
2 & {Some longer text} & {Some other text}\\
3 & {Some longer text} & {Some other text}\\
4 & {Some longer text} & {Some other text}
\end{tabular}
\end{table}
\end{document}
答案 1 :(得分:1)
不是最优雅的解决方案,但\centering
和\raggedright
命令对应于center
和flushleft
环境,并且没有增加的边距。
如果我遇到一个更好的解决方案,我会发布它,但这个可以工作我认为。
答案 2 :(得分:1)
建立@ honk的例子,我想你想要这个:
\ {的DocumentClass文章}
\begin{document}
\begin{table}
\centering
\begin{tabular}{>{\raggedright}l|>{\raggedright}p{2cm}|>{\raggedright}p{2cm}|}
\multicolumn{1}{c}{A} &
\multicolumn{1}{c}{B} &
\multicolumn{1}{c}{C} \\
1 & Some longer text & Some other text\\
2 & Some longer text & Some other text\\
3 & Some longer text & Some other text\\
4 & Some longer text & Some other text \\
\end{tabular}
\end{table}
\end{document}
单词仍然不会被连字符,但这应该可以解决您遇到的空行问题。
答案 3 :(得分:0)
不要在列对齐规范中使用p选项,而是使用l代替。然后在每个标题中使用\hfill Somephone \hfill
,并在每个正文单元格中使用\vbox to 3cm {About text}
。这样做可以最大限度地减少多余的填充。