我正在使用 Overleaf 做课堂笔记,但在尝试创建表格列时遇到了麻烦。我的代码如下:
\begin{center}
\begin{tabular}{|c|c|}
\hline
Crystalline Solids & Non-Crsytalline Solids \\
\hline
i. Atoms and molecules are periodic in space & i. Atoms and molecules are not periodic in space \\
\hline
ii. Some crystalline solids are anisotopic \\
i.e the magnitudes of the physical properties like \\
refractive index, electrical conductivity are \\
different along difference directions \\ & ii. Physical properties are isotropic \\
\hline
iii. Have sharp melting points & iii. Do not have sharp boiling points - a range is present \\
\hline
iv. Breaks are observed in the cooling curve & iv. No breaks in cooling curve \\
\hline
v. Breaks along sharp edges i.e breaks \\
along specific "crystallographic planes" & v. Broken surfaces are irregular because there are no crystal planes \\
\hline
\end{tabular}
\end{center}
问题是现在我的表格看起来像这样。https://i.stack.imgur.com/IUeXx.jpg
我尝试使用\begin{table}
环境和\begin{figure}
环境,但即使使用限定符(如[h]
或),[ht]
表格在文本中的位置也会发生变化,并且对齐仍然不正确。我该如何纠正这个问题以使其适合页面?
答案1
- 请始终提供可重现您问题的 MWE。由于前导码(与您的表格相关)未知,我们无法知道您的表格可以有多宽。
- 您的表格似乎太宽,无法放入文档文本区域
- 对于您的表格,我将使用并在列中使用
tabularx
左换行符,并使用包中定义的在单元格内容上方/下方插入小的垂直空间:X
makegapedcells
makecell
\documentclass{article}
\usepackage{ragged2e}
\usepackage{makecell, tabularx}
\newcolumntype{L}{>{\RaggedRight}X}
\begin{document}
\begin{table}[htb]
\setcellgapes{3pt}
\makegapedcells
\begin{tabularx}{\linewidth}{|c|X|X|}
\hline
& Crystalline Solids & Non-Crsytalline Solids \\
\hline
i. & Atoms and molecules are periodic in space
& Atoms and molecules are not periodic in space \\
\hline
ii. & Some crystalline solids are anisotopic
i.e the magnitudes of the physical properties like
refractive index, electrical conductivity are
different along difference directions
& Physical properties are isotropic \\
\hline
iii. & Have sharp melting points
& Do not have sharp boiling points - a range is present \\
\hline
iv. & Breaks are observed in the cooling curve
& No breaks in cooling curve \\
\hline
v. & Breaks along sharp edges i.e breaks
along specific "crystallographic planes"
& Broken surfaces are irregular because there are no crystal planes \\
\hline
\end{tabularx}
\end{table}
\end{document}
附註(1):
例如,当使用页面布局geometry
包(使用默认设置)和表格tabularray
包时:
\documentclass{article}
\usepackage{geometry}
\usepackage{tabularray}
\begin{document}
\begin{table}[htb]
\begin{tblr}{hlines, vlines,
colspec = {c X[1,l] X[1] }
}
& Crystalline Solids
& Non-Crystalline Solids \\
i. & Atoms and molecules are periodic in space
& Atoms and molecules are not periodic in space \\
ii. & Some crystalline solids are anisotropic
i.e the magnitudes of the physical properties like
refractive index, electrical conductivity are
different along difference directions
& Physical properties are isotropic \\
iii. & Have sharp melting points
& Do not have sharp boiling points - a range is present \\
iv. & Breaks are observed in the cooling curve
& No breaks in cooling curve \\
v. & Breaks along sharp edges i.e breaks
along specific "crystallographic planes"
& Broken surfaces are irregular because there are no crystal planes \\
\end{tblr}
\end{table}
\end{document}
附註(2):
使用tabularray
软件包版本 2021M(2021-08-01),您可以简单地将表格写得更花哨一些:
\documentclass{article}
\usepackage{geometry}
\usepackage{xcolor}
\usepackage{tabularray}
\begin{document}
\begin{table}[htb]
\begin{tblr}{hline{1,Z} = {1pt},
hline{2} = {0.6pt},
hline{3-Y} = {solid, gray},
vlines,
colspec = {c X[1,l] X[1] }
}
% table body and tail are the same as before
其生产成果为: