如何在 \multirow 命令中使用 \widthof 作为其第二个参数

如何在 \multirow 命令中使用 \widthof 作为其第二个参数

为什么我不能在命令\widthof中将其用作\multirow第二个参数?下面的代码运行错误:

\documentclass{article}
\usepackage{multirow,calc,amsmath}
\begin{document}
\begin{table}\begin{tabular}{rcl}
lemma 1&\multirow{3}{\widthof{$\iff$}}{$\iff$}&theorem 1\\
lemma 2&                                      &theorem 2\\
lemma 3&                                      &theorem 3
\end{tabular}\end{table}
\end{document}

我已经知道方法\newlength\setlength,但是就是有点烦。

编辑我也知道这个*方法,但我需要在命令中写入多行文本\multirow,然后必须为其分配长度。请参阅\multirow 命令不允许在其内部包含多行内容

答案1

我建议使用另一种方法makecell。该makecell命令允许在单元格内换行,我做了一个小补丁来添加对齐方式(垂直和水平)作为可选参数。通常,这个可选参数在序言中设置,但可以在任何地方重新定义。

演示:

\documentclass{article}
\usepackage{multirow,amsmath}
\usepackage{makecell}
\let\oldmakecell\makecell
\renewcommand{\makecell}[2][cc]{{\renewcommand\cellalign{#1}\oldmakecell{#2}}}

\begin{document}

\begin{table}[!h]
  \centering
  \begin{tabular}{r @{$\iff$}l}
    \makecell[r]{lemma 1\\ lemma 2 or 5\\ lemma 3}
      & \makecell[l]{theorem 1 \\ theorem 2 or 6\\ theorem 3 }
  \end{tabular}
\end{table}
\vskip 0.5cm
\begin{table}[!h]
  \centering
  \begin{tabular}{r @{$\iff$}l}
    \makecell[rt]{lemma 1\\ lemma 2 or 5\\ lemma 3}
      & \makecell[lb]{theorem 1 \\ theorem 2 or 6\\ theorem 3 }
  \end{tabular}
\end{table}

\end{document} 

在此处输入图片描述

相关内容