表格换行后缩进

表格换行后缩进

我有一张如下所示的表格:

如您所见,两个条目很长,占了好几行。我该如何缩进它们?

这是源代码:

\begin{tabularx}{.91\textwidth}{l X}
  \toprule
  $\gamma_1$ & \tabitem Unix timestamp\\
             & \tabitem New state $\zeta'$\\
             & \tabitem $\alpha$'s signature $\sigma_\alpha(H(\zeta'))$ of the hash of $\zeta'$\\
  \hline
  $\gamma_2$ & \tabitem $\sigma_i(H(\zeta'))$\\
  \hline
             & \tabitem $A \coloneqq (\sigma_1(H(\zeta')), ..., \sigma_k(H(\zeta')))$\\
  $\gamma_3$ & \tabitem List $C$ of Commitment Transactions. $\forall c_i \in C :$ [$c_i$ sends $\zeta_i$ to a Revocable Sequence Maturity Contract for $m_i$ and $\zeta_j$ to $m_j$ for all $j \not = i, j \in [1..k]$.]\\
  \hline
  $\gamma_{4;i}$ & \tabitem $(\sigma_i(c_1), ..., \sigma_i(c_{i-1}), \text{null}, \sigma_i(c_{i+1}), ..., \sigma_i(c_k))$ [The sequence contains a dummy element because members must not share their signatures for their own respective $c_i$. Defining the sequence this way rather than merely skipping $\sigma_i(c_i)$ has the advantage of there not being a shift by -1 in the indices after $i$.]\\
             & \tabitem Breach Remedy Transaction (Revocation Transaction) $\text{BR}_i$ signed by $m_i$\\
  \hline
  $\gamma_5$ & \tabitem ($\gamma_{4;1},...,\gamma_{4;k}$)\\
  \hline
  $\gamma_{6;i}$ & \tabitem $(\sigma_i(\text{BR}_1), ..., \sigma_i(\text{BR}_k))$\\
  \hline
  $\gamma_7$ & \tabitem ($\gamma_{6;1},...,\gamma_{6;k}$)\\
  \bottomrule
\end{tabularx}

附言:如果您知道更好的方式来呈现此信息,请在评论中告诉我。

答案1

我建议您mylist使用包的机制定义一个自定义列表(如下所示)enumitem。我还建议您利用文本块的整个宽度,不要在环境的左边缘和右边缘使用任何空白填充tabularx。要排版排版省略号,请写入\dots(不是...)。

在此处输入图片描述

\documentclass{article}
\usepackage{tabularx,booktabs,mathtools}
\usepackage{enumitem}
\newlist{mylist}{itemize}{1}
\setlist[mylist]{label=\textbullet,
                 nosep, wide, leftmargin=*,
                 before=\vspace{-0.57\baselineskip},
                 after =\vspace{-0.85\baselineskip}}
\begin{document}

\noindent
\begin{tabularx}{1\textwidth}{@{}l X@{}} % "@{}": no whitespace padding
\toprule
$\gamma_1$ & 
  \begin{mylist}
  \item Unix timestamp
  \item New state $\zeta'$
  \item $\alpha$'s signature $\sigma_\alpha(H(\zeta'))$ of the hash of $\zeta'$
  \end{mylist}\\
\addlinespace
  $\gamma_2$ & \textbullet\ $\sigma_i(H(\zeta'))$\\
\addlinespace
$\gamma_3$ & 
  \begin{mylist}
  \item $A \coloneqq (\sigma_1(H(\zeta')), \dots, \sigma_k(H(\zeta')))$
  \item List $C$ of Commitment Transactions. $\forall c_i \in C :$ [$c_i$ sends $\zeta_i$ to a Revocable Sequence Maturity Contract for $m_i$ and $\zeta_j$ to $m_j$ for all $j\ne i$, $j\in [1\dots k]$.]
  \end{mylist}\\
\addlinespace
$\gamma_{4;i}$ & 
  \begin{mylist}
  \item $(\sigma_i(c_1), \dots, \sigma_i(c_{i-1}), \text{null}, \sigma_i(c_{i+1}), \dots, \sigma_i(c_k))$ [The sequence contains a dummy element because members must not share their signatures for their own respective~$c_i$. Defining the sequence this way rather than merely skipping $\sigma_i(c_i)$ has the advantage of there not being a shift by $-1$ in the indices after~$i$.]
  \item Breach Remedy Transaction (Revocation Transaction) $\text{BR}_i$ signed by~$m_i$
  \end{mylist}\\
\addlinespace
$\gamma_5$ & \textbullet\ ($\gamma_{4;1},\dots,\gamma_{4;k}$)\\
\addlinespace
$\gamma_{6;i}$ & \textbullet\ $(\sigma_i(\text{BR}_1), \dots, \sigma_i(\text{BR}_k))$\\
\addlinespace
$\gamma_7$ & \textbullet\ ($\gamma_{6;1},\dots,\gamma_{6;k}$)\\
\bottomrule
\end{tabularx}
\end{document}

答案2

这是一个变体解决方案:第一列自动进入数学模式,第二列中的单元格(基于类型X)进入和离开具有适当参数的 itemize 环境:

\documentclass{article}
\usepackage{tabularx,booktabs,mathtools}
\usepackage{enumitem}

\makeatletter
\newcommand*{\compress}{\@minipagetrue}
\makeatother

\newcolumntype{L}{ >{\arraybackslash\compress\itemize}X<{\enditemize}}

\begin{document}

\noindent
\setlist[itemize]{wide=0pt, leftmargin=*, nosep=0pt, after =\vspace*{-\dimexpr\baselineskip}}
\setlength{\defaultaddspace}{1.5ex}
\begin{tabularx}{\textwidth}{@{}>{$}l<{$}L@{}} % "@{}": no whitespace padding
\toprule
\gamma_1 & \item Unix timestamp
  \item New state $\zeta'$
 \item $\alpha$'s signature $\sigma_\alpha(H(\zeta'))$ of the hash of $\zeta'$ \\
\addlinespace
 \gamma_2 & \item $\sigma_i(H(\zeta'))$ \\%
\addlinespace
\gamma_3 & \item $A \coloneqq (\sigma_1(H(\zeta')), \dots, \sigma_k(H(\zeta')))$
\item List $C$ of Commitment Transactions. $\forall c_i \in C :$ [$c_i$ sends $\zeta_i$ to a Revocable Sequence Maturity Contract for $m_i$ and $\zeta_j$ to $m_j$ for all $j\ne i$, $j\in [1\dots k]$.] \\
\addlinespace
\gamma_{4;i} & \item $(\sigma_i(c_1), \dots, \sigma_i(c_{i-1}), \text{null}, \sigma_i(c_{i+1}), \dots, \sigma_i(c_k))$ [The sequence contains a dummy element because members must not share their signatures for their own respective~$c_i$. Defining the sequence this way rather than merely skipping $\sigma_i(c_i)$ has the advantage of there not being a shift by $-1$ in the indices after~$i$.]
\item Breach Remedy Transaction (Revocation Transaction) $\text{BR}_i$ signed by~$m_i$ \\%
\addlinespace
\gamma_5 & \item ($\gamma_{4;1},\dots,\gamma_{4;k}$) \\%
\addlinespace
\gamma_{6;i} & \item $(\sigma_i(\text{BR}_1), \dots, \sigma_i(\text{BR}_k))$ \\%
\addlinespace
\gamma_7 & \item ($\gamma_{6;1},\dots,\gamma_{6;k}$)\\%
\bottomrule
\end{tabularx}

\end{document} 

在此处输入图片描述

答案3

为什么不对右列中的列表使用列表环境?您可能需要进行一些挖掘才能获得正确的间距,但“X”列基本上是“p”列,这意味着列表环境可以在其中工作。

如果由于某种原因您不能这样做,您可以引入一个包含“\tabitem”的额外列,以确保长文本的缩进,例如:

\begin{tabularx}{.91\textwidth}{l r X}
  \toprule
$\gamma_1$ & \tabitem & Unix timestamp\\
             & \tabitem & New state $\zeta'$\\
             & \tabitem & $\alpha$'s signature $\sigma_\alpha(H(\zeta'))$ of the hash of $\zeta'$\\
\bottomrule
\end{tabularx}

第三种选择是在列定义中使用“@”参数:

\begin{tabularx}{.91\textwidth}{l @{~\tabitem~}X}

用你喜欢的间距命令替换‘~’字符(@ 抑制列间空格)

相关内容