m 列类型和 makecell 不兼容吗?

m 列类型和 makecell 不兼容吗?

在准备回答问题我很惊讶这个 MWE

\documentclass{article}
\usepackage{array,makecell}
\renewcommand\theadfont{\bfseries\normalsize}

\begin{document}
    \begin{table}
    \setcellgapes{5pt}% <-- troublemaker
    \makegapedcells   % <-- troublemaker
\caption{Pronombres personales.}
\label{tab:personales}
    \centering
\begin{tabular}{|>{\centering\arraybackslash}m{2cm}}% <--
    \hline
\thead{Inglés}  \\  \hline
 \hline
\end{tabular}
    \end{table}
\end{document}

给出错误:

! Missing $ inserted. <insert text> $ \thead{Inglés} \\ \hline

如果我用 替换m,它就会按预期工作。如果我删除宏和 ,p它也会起作用。我遗漏了什么吗?\setcellgapes{5pt}\makegapedcells

答案1

您可以尝试这个补丁(我将数学美元移到了 \mcell@agape 里面),但我没有彻底测试它:

\documentclass{article}
\usepackage{makecell}
\makeatletter
\renewcommand\mcell@classz{\@classx
   \@tempcnta \count@
   \prepnext@tok
   \@addtopreamble{%\mcell@mstyle
      \ifcase\@chnum
         \hfil
         \mcell@agape{\d@llarbegin\insert@column\d@llarend}\hfil \or
         \hskip1sp
         \mcell@agape{\d@llarbegin\insert@column\d@llarend}\hfil \or
         \hfil\hskip1sp
         \mcell@agape{\d@llarbegin \insert@column\d@llarend}\or
         \mcell@agape{$\vcenter
         \@startpbox{\@nextchar}\insert@column\@endpbox$}\or
         \mcell@agape{\vtop
         \@startpbox{\@nextchar}\insert@column\@endpbox}\or
         \mcell@agape{\vbox
         \@startpbox{\@nextchar}\insert@column\@endpbox}%
      \fi
      \global\let\mcell@left\relax\global\let\mcell@right\relax
    }\prepnext@tok}

    \makeatletter

\begin{document}

    \setcellgapes{5pt}% <-- troublemaker
    \makegapedcells   % <-- troublemaker

\begin{tabular}{|m{2cm}}% <--
    blub  
\end{tabular}

\end{document}

相关内容