什么原因导致缺少$插入错误?

什么原因导致缺少$插入错误?

我使用 latex-tables.com 创建了一个表格,然后使用 overleaf 快速进行细微调整,直到表格看起来完全符合我的要求。在 overleaf 上,所有内容都可以无错误地编译。但是,我的本地编译器似乎无法编译代码,我就是搞不清楚。它只是停在! Missing $ inserted。我搞不清楚错误来自哪里。下面是在 Overleaf 中编译的表格的图片,后面是出现问题的 MWE。

在此处输入图片描述

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{multirow}
\usepackage{colortbl}
\usepackage{arydshln}
\usepackage{graphics}

\begin{document}

\begin{table}
    \centering
    \resizebox{200}{!}{
        \refstepcounter{table}
        \label{tab:my-table}
        \arrayrulecolor[rgb]{0.271,0.271,0.275}
        \ADLnullwidehline
        \begin{tabular}{!{\color{black}\vrule}lr!{\color{black}\vrule}rl}
            \multicolumn{1}{!{\color{black}\vrule}c}{push} & \multicolumn{1}{c!{\color{black}\vrule}}{pop} & \multicolumn{2}{l}{Function} \\ 
            \cdashline{1-2}
            \multicolumn{1}{!{\color{black}\vrule}c}{\downarrow} & \multicolumn{1}{c!{\color{black}\vrule}}{\uparrow} & \multicolumn{2}{l}{ call no.} \\ 
            \arrayrulecolor[rgb]{0.753,0.753,0.753}\cline{1-2}
            x = & \textbf{0} & \multirow{2}{*}{\huge\}} & \multirow{2}{*}{5} \\ 
        \arrayrulecolor[rgb]{0.271,0.271,0.275}\cdashline{1-2}
        return & \textbf{1} &  &  \\ 
        \cline{1-2}
        x = & \textbf{1} & \multirow{2}{*}{\huge\}} & \multirow{2}{*}{4} \\ 
        \cdashline{1-2}
        return & \textbf{1} &  &  \\ 
        \cline{1-2}
        x = & \textbf{1} & \multirow{2}{*}{\huge\}} & \multirow{2}{*}{3} \\ 
        \cdashline{1-2}
        return & \textbf{2} &  &  \\ 
        \cline{1-2}
        x = & \textbf{3} & \multirow{2}{*}{\huge\}} & \multirow{2}{*}{2} \\ 
        \cdashline{1-2}
        return & \textbf{6} &  &  \\ 
        \cline{1-2}
        x = & \textbf{4} & \multirow{2}{*}{\huge\}} & \multirow{2}{*}{1} \\ 
        \cdashline{1-2}
        return & \textbf{24} &  &  \\
        \arrayrulecolor{black}\cline{1-2}
        \end{tabular}
        }
\end{table}

\end{document}

以防万一,以下是我安装的 pdflatex 的版本信息:

pdfTeX 3.14159265-2.6-1.40.21 (TeX Live 2020)
kpathsea version 6.3.2
Copyright 2020 Han The Thanh (pdfTeX) et al.
There is NO warranty.  Redistribution of this software is
covered by the terms of both the pdfTeX copyright and
the Lesser GNU General Public License.
For more information about these matters, see the file
named COPYING and the pdfTeX source.
Primary author of pdfTeX: Han The Thanh (pdfTeX) et al.
Compiled with libpng 1.6.37; using libpng 1.6.37
Compiled with zlib 1.2.11; using zlib 1.2.11

答案1

这不是答案。只是对以上评论的汇总,以关闭此问题。请不要投票。

此代码可以正常工作:

% !TeX TS-program = pdflatex

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{multirow}
\usepackage{colortbl}
\usepackage{arydshln}
\usepackage{graphics}

\begin{document}

\begin{table}
    \centering
        \refstepcounter{table}
        \label{tab:my-table}
        \arrayrulecolor[rgb]{0.271,0.271,0.275}
        \ADLnullwidehline
        \begin{tabular}{!{\color{black}\vrule}lr!{\color{black}\vrule}rl}
            \multicolumn{1}{!{\color{black}\vrule}c}{push} & \multicolumn{1}{c!{\color{black}\vrule}}{pop} & \multicolumn{2}{l}{Function} \\ 
            \cdashline{1-2}
         \multicolumn{1}{!{\color{black}\vrule}c}{\(\downarrow\)} & \multicolumn{1}{c!{\color{black}\vrule}}{\(\uparrow\)} & \multicolumn{2}{l}{ call no.} \\ 
            \arrayrulecolor[rgb]{0.753,0.753,0.753}\cline{1-2}
            x = & \textbf{0} & \multirow{2}{*}{\huge\}} & \multirow{2}{*}{5} \\ 
        \arrayrulecolor[rgb]{0.271,0.271,0.275}\cdashline{1-2}
        return & \textbf{1} &  &  \\ 
        \cline{1-2}
        x = & \textbf{1} & \multirow{2}{*}{\huge\}} & \multirow{2}{*}{4} \\ 
        \cdashline{1-2}
        return & \textbf{1} &  &  \\ 
        \cline{1-2}
        x = & \textbf{1} & \multirow{2}{*}{\huge\}} & \multirow{2}{*}{3} \\ 
        \cdashline{1-2}
        return & \textbf{2} &  &  \\ 
        \cline{1-2}
        x = & \textbf{3} & \multirow{2}{*}{\huge\}} & \multirow{2}{*}{2} \\ 
        \cdashline{1-2}
        return & \textbf{6} &  &  \\ 
        \cline{1-2}
        x = & \textbf{4} & \multirow{2}{*}{\huge\}} & \multirow{2}{*}{1} \\ 
        \cdashline{1-2}
        return & \textbf{24} &  &  \\
        \arrayrulecolor{black}\cline{1-2}
        \end{tabular}    
\end{table}

\end{document}

最终的

答案2

我建议为该表提供一个更简单的代码,使用 bigdelim(附带multirow):

    \documentclass{article}
    \usepackage{multirow, bigdelim, makecell}
    \usepackage{colortbl}
    \usepackage{arydshln}
    \usepackage{graphics}

    \begin{document}

    \begin{table}
        \centering
            \begin{tabular}{!{\color{black}\vrule}l>{\bfseries}r!{\color{black}\vrule}l}
                \multicolumn{1}{!{\color{black}\vrule}c}{push} & \multicolumn{1}{c!{\color{black}\vrule}}{pop} & \multirowcell{2}{Function\\call no} \\
                \cdashline{1-2}
                \multicolumn{1}{!{\color{black}\vrule}c}{$\downarrow $} & \multicolumn{1}{c!{\color{black}\vrule}}{$ \uparrow $} & \\
                \arrayrulecolor[rgb]{0.753,0.753,0.753}\cline{1-2}
                x = & 0 & \rdelim \}{2}{*}[\quad 5] \\
                \arrayrulecolor[rgb]{0.271,0.271,0.275}\cdashline{1-2}
                return & 1 \\
                \cline{1-2}
                x = & 1 & \rdelim \}{2}{*}[\quad 4] \\
                \cdashline{1-2}
                return & 1 \\
                \cline{1-2}
                x = & 1 & \rdelim \}{2}{*}[\quad 3] \\
                \cdashline{1-2}
                return & \textbf{2} \\
                \cline{1-2}
                x = & 3 & \rdelim \}{2}{*}[\quad 2] \\
                \cdashline{1-2}
                return & 6 \\
                \cline{1-2}
                x = & 4 &\rdelim\}{2}{*}[\quad 1] \\
                \cdashline{1-2}
                return & 24 \\
                \arrayrulecolor{black}\cline{1-2}
            \end{tabular}
    \end{table}

    \end{document} 

在此处输入图片描述

相关内容