在页面限制内调整表格

在页面限制内调整表格

我想限制一个表格元素(不是表格)以使其适合页面限制。默认情况下,它是缩进的,我希望右侧也有相同的缩进。两列应该等长。

这是我现在所拥有的,但它超出了页面限制。

\paragraph{Un/happiness}
Unhappiness refers to misery, when the mood is in the speaker, or antipathy, when the feeling is directed at you.
\vspace{0.5cm}
\begin{tabular}{ll}
    Surge of behaviour: \textit{whimper, cry, wail, rubbish, abuse, revile} & Surge of behaviour: \textit{quejarse, llorar, gemir, lamentarse, sollozar, berrear} \\
    Disposition: \textit{down, sad, miserable} & Disposition: \textit{triste, deprimido, con la depre}
\end{tabular}

我必须将其包括在内,\vspace{o.5}因为它不会在表格上方留下任何空白,尽管它在下面留下了空白,这是我的表格的另一个问题。

答案1

您可以使用tabularx等宽列来扩展以填充给定的宽度。

您可以通过从当前行宽中减去两倍段落缩进来确定宽度。为了方便起见,请加载calc

最后,如果文本宽度较窄且两端对齐,您可能会发现出现许多不良框和难看的线条。在这种情况下,请考虑使用右侧不齐的列。您可以tabularx通过使用包定义新类型的列来创建右侧不齐的列array。下面,我使用了L

此示例显示了一个具有默认列的示例tabularx X和一个具有L列的示例。

2 个例子

\documentclass{article}
\usepackage{tabularx,calc,array}
\newcolumntype{L}{>{\raggedright\arraybackslash}X}
\begin{document}
\paragraph{Un/happiness}
Unhappiness refers to misery, when the mood is in the speaker, or antipathy, when the feeling is directed at you.
\vspace{0.5cm}

\begin{tabularx}{\linewidth-2\parindent}{XX}
  Surge of behaviour: \textit{whimper, cry, wail, rubbish, abuse, revile} & Surge of behaviour: \textit{quejarse, llorar, gemir, lamentarse, sollozar, berrear} \\
  Disposition: \textit{down, sad, miserable} & Disposition: \textit{triste, deprimido, con la depre}
\end{tabularx}
\bigskip

\begin{tabularx}{\linewidth-2\parindent}{LL}
  Surge of behaviour: \textit{whimper, cry, wail, rubbish, abuse, revile} & Surge of behaviour: \textit{quejarse, llorar, gemir, lamentarse, sollozar, berrear} \\
  Disposition: \textit{down, sad, miserable} & Disposition: \textit{triste, deprimido, con la depre}
\end{tabularx}
\end{document}

答案2

tabularx与此代码一起使用 :

\noindent\begin{tabularx}{\linewidth}{XX}
    Surge of behaviour: \textit{whimper, cry, wail, rubbish, abuse, revile} & Surge of behaviour: \textit{quejarse, llorar, gemir, lamentarse, sollozar, berrear} \\
    Disposition: \textit{down, sad, miserable} & Disposition: \textit{triste, deprimido, con la depre}
\end{tabularx}

答案3

略有不同@cfr答案——不使用包cal

\documentclass{article}
\usepackage{tabularx}
\newcolumntype{L}{>{\raggedright\arraybackslash}X}

\begin{document}
\paragraph{Un/happiness}
Unhappiness refers to misery, when the mood is in the speaker, or antipathy, when the feeling is directed at you.
\vspace{0.5cm}

\begin{tabularx}{\dimexpr\linewidth-2\parindent\relax}{LL}% <--
  Surge of behaviour: \textit{whimper, cry, wail, rubbish, abuse, revile} 
    & Surge of behaviour: \textit{quejarse, llorar, gemir, lamentarse, sollozar, berrear} \\
  Disposition: \textit{down, sad, miserable} 
    & Disposition: \textit{triste, deprimido, con la depre}
\end{tabularx}
\bigskip

\begin{tabularx}{\dimexpr\linewidth-2\parindent\relax}{LL}% <--
  Surge of behaviour: \textit{whimper, cry, wail, rubbish, abuse, revile} 
    & Surge of behaviour: \textit{quejarse, llorar, gemir, lamentarse, sollozar, berrear} \\
  Disposition: \textit{down, sad, miserable} 
    & Disposition: \textit{triste, deprimido, con la depre}
\end{tabularx}
\end{document}

在此处输入图片描述

相关内容