【发布时间】:2010-05-29 15:33:16
【问题描述】:
我与乳胶桌搏斗太久了。我需要一个具有居中标题的表格,以及包含可能环绕的文本的正文单元格。由于环绕要求,我使用 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 可防止长词被连字。当一个单元格包含一堆只有一个单词的行时,这看起来很糟糕。
-
仅当您以空行结束时,使用 \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
【问题讨论】: