![使用“moderncv”包,\cvitemwithcomment 命令出现错误](https://linux22.com/image/315135/%E4%BD%BF%E7%94%A8%E2%80%9Cmoderncv%E2%80%9D%E5%8C%85%EF%BC%8C%5Ccvitemwithcomment%20%E5%91%BD%E4%BB%A4%E5%87%BA%E7%8E%B0%E9%94%99%E8%AF%AF.png)
我正在尝试使用包创建我的个人简历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
不要使用浮动环境,例如table
或figure
,moderncv
因为在 CV 中拥有浮动对象是没有意义的,它们不是由类实现的:还要注意,长度\tabcolsep
不是由类设置的,所以它具有0pt
as 值;你需要使用类似
\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}