首页 > 解决方案 > 如何将表格向左移动或不超过右边距?

问题描述

我在课堂上使用 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://imgur.com/ZrWFNSS 我已经尝试过使用\begin{table}环境和\begin{figure}环境,但即使在使用限定符之后,[h]或者[ht]表格在文本中的位置也发生了变化,并且对齐仍然关闭。如何更正它以使其适合页面?

标签: latextexoverleaf

解决方案


cl并且r列不包装它们的内容。您必须为您的 使用固定宽度的p{<len>}tabular,或考虑使用tabularx.

这是一个带有paragraph 样式列规范的选项:

在此处输入图像描述

\documentclass{article}

\usepackage{booktabs}

\begin{document}

\begin{center}
  \begin{tabular}{ l p{.45\linewidth} p{.45\linewidth} }
    \toprule
         & \multicolumn{1}{c}{Crystalline Solids} & 
          \multicolumn{1}{c}{Non-Crystalline Solids} \\
    \midrule
    i.   & Atoms and molecules are periodic in space & 
      Atoms and molecules are not periodic in space \\
    ii.  & Some crystalline solids are anisotopic \textit{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 \\
    \bottomrule 
  \end{tabular}
\end{center}

\end{document}

这是一个类似的选项,使用tabularx

在此处输入图像描述

\documentclass{article}

\usepackage{tabularx,booktabs}

\begin{document}

\noindent
\begin{tabularx}{\linewidth}{ l X X }
  \toprule
       & \multicolumn{1}{c}{Crystalline Solids} & 
        \multicolumn{1}{c}{Non-Crystalline Solids} \\
  \midrule
  i.   & Atoms and molecules are periodic in space & 
    Atoms and molecules are not periodic in space \\
  ii.  & Some crystalline solids are anisotopic \textit{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 \\
  \bottomrule 
\end{tabularx}

\end{document}

推荐阅读