2

In preparing answer to question I was surprised that this 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}

gives error:

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

If I replace m with p, than it work as expected. Also it wirks if I remove macros \setcellgapes{5pt} and \makegapedcells. Do I miss something?

Zarko
  • 296,517
  • I would say it is a makecell bug. The m-type uses \vcenter which needs math mode, and makecell doesn't handle this case correctly. – Ulrike Fischer Jul 17 '16 at 10:45
  • There does seem to be an incompatibility – mainly with \makegapedcells. Makecell loads array and modifies its\@classz macro. However, \makegapedcells works withthe p or b column types – Bernard Jul 17 '16 at 10:47
  • Thank you @UlrikeFischer and @Bernard for diagnosis! Knowing, what is the problem is helpful, but some cure (workaround) would be helpful. It seems that makecell is not maintained (or author don't respond on e-mails). I mostly can stick with p{...} column type however. – Zarko Jul 17 '16 at 10:57
  • When I meet this problem (your question seems to be first post on it), generally I use cellspace for the padding, but they're not strictly equivalent. – Bernard Jul 17 '16 at 11:35

1 Answers1

3

You can try this patch (I moved the math dollar inside \mcell@agape), but I didn't test it thoroughly:

\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}
Ulrike Fischer
  • 327,261