此代码生成的表格总是超出页面宽度。我希望表格适合页面宽度。我尝试\\
在两者之间添加额外的内容,但这只会让情况变得更糟。
\begin{tabular}{|l|l|}
\hline
LocationProvider & Description \\
\hline
network & Uses the mobile network or WI-Fi to determine the best location.Might have a higher precision in closed rooms than GPS. \\
\hline
gps & Use the GPS receiver in the Android device to determine the best location via satellites. Usually better precision than network. \\
\hline
passive & Allows to participate in location of updates of other components to save energy \\
\hline
\end{tabular}
结果:
答案1
“l”表示左对齐,因此单元格中的所有内容都会出现在一行中,如果您有很多材料,最终会超出页面上的可用宽度。
备择方案:
- 在一个或多个列上使用
p{<width>}
,使里面的文本换行指定的<width>
- 或者使用
tabularx
允许您自动确定换行列的列宽的包(请参阅包文档了解如何执行此操作) - 在某些情况下,使用稍小的表格字体可能是一种选择,但一般来说我不推荐这样做。
答案2
它看起来像一个包的工作tabularx
:
\documentclass{article}
\usepackage{tabularx}
\begin{document}
\noindent
\begin{tabularx}{\linewidth}{|l|X|}
\hline
LocationProvider & Description \\
\hline
network & Uses the mobile network or WI-Fi to determine the best
location.Might have a higher precision in closed rooms than GPS. \\
\hline
gps & Use the GPS receiver in the Android device to determine the best
location via satellites. Usually better precision than network. \\
\hline
passive & Allows to participate in location of updates of other components
to save energy \\
\hline
\end{tabularx}
\end{document}