使用“moderncv”包,\cvitemwithcomment 命令出现错误

使用“moderncv”包,\cvitemwithcomment 命令出现错误

我正在尝试使用包创建我的个人简历moderncv,但出现错误:在语言技能部分,我想插入一张表格,使用以下代码恢复我的技能

\section{Languages}
\cvitemwithcomment{Italian}{Mother tongue}{}
\cvitemwithcomment{English}{\begin{table}
        \centering
        \begin{tabular}{|c|c|c|c|c|}
            \hline
            \multicolumn{2}{|c|}{Understanding} & \multicolumn{2}{c|}{Speaking}          & Writing \\ \hline
            Listening         & Reading        & Spoken interaction & Spoken production & -       \\ \hline
            C1                & C1              & C1                 & B2                & B2      \\ \hline
        \end{tabular}
    \end{table}}{}
\cvitemwithcomment{Spanish}{\begin{table}
        \centering
        \begin{tabular}{|c|c|c|c|c|}
            \hline
            \multicolumn{2}{|c|}{Understanding} & \multicolumn{2}{c|}{Speaking}          & Writing \\ \hline
            Listening         & Reading        & Spoken interaction & Spoken production & -       \\ \hline
            B2                & B2              & B1                 & B1                & B1      \\ \hline
        \end{tabular}
    \end{table}}{}

但是,编译时我重复收到这些错误:

Environment table undefined. \end{table}}{} 
\begin{document} ended by \end{table}. \end{table}}{} 
\begin{minipage} on input line 131 ended by \end{table}. \end{table}}{}

并且编译被阻止。有人能给我一些提示来解决这个问题吗?

答案1

不要使用浮动环境,例如tablefiguremoderncv因为在 CV 中拥有浮动对象是没有意义的,它们不是由类实现的:还要注意,长度\tabcolsep不是由类设置的,所以它具有0ptas 值;你需要使用类似

\setlength\tabcolsep{6pt}

否则,表格材料中的列之间将没有分隔。您的代码遵循以下建议:

\documentclass{moderncv}
\moderncvtheme{classic}

\firstname{John}
\lastname{Doe}

\setlength\tabcolsep{6pt}

\begin{document}

\makecvtitle

\section{Languages}
aaaa
\cvitemwithcomment{Italian}{Mother tongue}{}
\cvitemwithcomment{English}{%
        \centering
        \begin{tabular}{|c|c|c|c|c|}
            \hline
            \multicolumn{2}{|c|}{Understanding} & \multicolumn{2}{c|}{Speaking}          & Writing \\ \hline
            Listening         & Reading        & Spoken interaction & Spoken production & -       \\ \hline
            C1                & C1              & C1                 & B2                & B2      \\ \hline
        \end{tabular}%
    }{}
\cvitemwithcomment{Spanish}{%
        \centering
        \begin{tabular}{|c|c|c|c|c|}
            \hline
            \multicolumn{2}{|c|}{Understanding} & \multicolumn{2}{c|}{Speaking}          & Writing \\ \hline
            Listening         & Reading        & Spoken interaction & Spoken production & -       \\ \hline
            B2                & B2              & B1                 & B1                & B1      \\ \hline
        \end{tabular}%
    }{}

\end{document}

附注:您的表格行数太多。在这里,我稍微修改了表格,并使用了包提供的功能booktabs

\documentclass{moderncv}
\moderncvtheme{classic}
\usepackage{booktabs}

\firstname{John}
\lastname{Doe}

\setlength\tabcolsep{6pt}

\begin{document}

\makecvtitle

\section{Languages}
\cvitemwithcomment{Italian}{Mother tongue}{}
\cvitemwithcomment{English}{%
        \centering
        \begin{tabular}{*{5}{c}}
            \toprule
            \multicolumn{2}{c}{Understanding} & \multicolumn{2}{c}{Speaking}          & Writing \\ \midrule
            & & Spoken & Spoken & \\
            Listening         & Reading        &  interaction &  production & -       \\             C1                & C1              & C1                 & B2                & B2      \\ \bottomrule
        \end{tabular}%
    }{}
\cvitemwithcomment{Spanish}{%
        \centering
        \begin{tabular}{*{5}{c}}
            \toprule
            \multicolumn{2}{c}{Understanding} & \multicolumn{2}{c}{Speaking}          & Writing \\ \midrule
            & & Spoken & Spoken & \\
            Listening         & Reading        & interaction & production & -       \\ \hline
            B2                & B2              & B1                 & B1                & B1      \\ \bottomrule
        \end{tabular}%
    }{}

\end{document}

在此处输入图片描述

相关内容