在 Moderncv 中添加表格

在 Moderncv 中添加表格

我尝试在模板的“体验”部分添加一个表格moderncv,但收到以下错误消息:

“您使用了 LaTeX 未预期的 \ 或 \newline 命令。请确保仅在文本块后使用换行符,并在列表和其他环境中小心使用换行符。”

我曾使用过不同的策略来使其工作,但最终总是出现比以前更多的错误。有人有意见吗?

    \documentclass[11pt,a4paper,sans]{moderncv}

    \moderncvstyle{casual} % casual head2, body1, foot1  oldstyle head4 body4                    
    \moderncvcolor{grey}   

    \usepackage[utf8]{inputenc}
    \usepackage{tabularx}
    \usepackage[scale=0.85]{geometry}
    %\setlength{\hintscolumnwidth}{3cm}                %  dates


    \name{name}{name}
    \title{CV}                              
    \address{Hej}{hej}{hej}
    \phone[mobile]{+467000000000}                   
    \email{[email protected]}                               % 
    %\extrainfo{additional information}      
    \photo[160pt][0pt]{example-image}   

    \quote{Hejsan} 

    \setlength{\footskip}{39pt} 
    \moderncvbody{4} % Body of oldfancy style    


    \begin{document}

    \makecvtitle

    \section{Education}
    \cventry{year--year}{Degree}{Institution--3}{City--4}{\textit{Grade}--5}{Description--6}  % arguments 3 to 6 can be left empty
    \cventry{year--year}{Degree}{Institution}{City}{\textit{Grade}}{Description}


    \section{Experience}
    \subsection{Vocational}
    \cventry{year--year}{Job title}{Employer}{City}{}{General description \newline{}%
    Detailed achievements:%
    \begin{itemize}%
    \item Achievement 1;
    \cvitemwithcomment{%
    \begin{tabular}{\textwidth-\hintscolumnwidth-\separatorcolumnwidth}{p{300pt}p{80pt}p{35pt}}
    \textbf{Område}                                             &         \textbf{Utfall (snitt)} & \textbf{Skala} \\ \hline
    Ledarskap                                          & 4,6            & 1-6   \\ 
    Arbetsmiljö (fysiska faktorer)                     & 4,1            & 1-6   \\
    Arbetsmiljö (sociala och organisatoriska faktorer) & 4.8            & 1-6  \\
    Mångfald                   & 4,9            & 1-6   \\
    Organisation och mål & 4.4            & 1-6  \\
    Kompetensutveckling                                          & 4,4            & 1-6   \\
    Löner och förmåner                                          & 4,2            & 1-6   \\
    Attraktiv arbetsgivare                     & 3,3            & 1-4  
    \end{tabular}
    }
    \newline
    \newline
    \item Achievement 2, with sub-achievements:
      \begin{itemize}%
      \item Sub-achievement (a);
      \item Sub-achievement (b), with sub-sub-achievements (don't do this!);
        \begin{itemize}
        \item Sub-sub-achievement i;
        \item Sub-sub-achievement ii;
        \item Sub-sub-achievement iii;
        \end{itemize}
      \item Sub-achievement (c);
      \end{itemize}

    \section{Languages}
    \cvitemwithcomment{Language 1}{Skill level}{Comment}
    \cvitemwithcomment{\textbf{Language} 2}{\textbf{Skill} level}{Comment}
    \cvitemwithcomment{Language 3}{Skill level}{Comment}

    \section{Computer skills}
    \cvdoubleitem{category 1}{XXX, YYY, ZZZ}{category 4}{XXX, YYY, ZZZ}
    \cvdoubleitem{category 2}{XXX, YYY, ZZZ}{category 5}{XXX, YYY, ZZZ}
    \cvdoubleitem{category 3}{XXX, YYY, ZZZ}{category 6}{XXX, YYY, ZZZ}

    \section{Interests}
    \cvitem{hobby 1}{Description}
    \cvitem{hobby 2}{Description}
    \cvitem{hobby 3}{Description}

    \section{Extra 1}
    \cvlistitem{Item 1}
    \cvlistitem{Item 2}
    \cvlistitem{Item 3}


    \section{References}
    \begin{cvcolumns}
      \cvcolumn{Category 1}{\begin{itemize}\item Person 1\item Person 2\item Person 3\end{itemize}}
      \cvcolumn{Category 2}{Amongst others:\begin{itemize}\item Person 1, and\item Person 2\end{itemize}(more upon request)}
      \cvcolumn[0.5]{All the rest \& some more}{\textit{That} person, and \textbf{those} also (all available upon request).}
    \end{cvcolumns}

    \end{document}

答案1

嗯,您不能\cvitemwithcomment像在所显示的代码中那样嵌套多个命令。

请查看此更正后的代码:

\section{Experience}
\subsection{Vocational}
\cventry{year--year}{Job title}{Employer}{City}{}{General description \newline{}%
    Detailed achievements:\\%
    \begin{tabular}{p{300pt}p{80pt}p{35pt}}
    \textbf{Område}                                    & \textbf{Utfall (snitt)} & \textbf{Skala} \\ \hline
    Ledarskap                                          & 4,6                     & 1-6   \\ 
    Arbetsmiljö (fysiska faktorer)                     & 4,1                     & 1-6   \\
    Arbetsmiljö (sociala och organisatoriska faktorer) & 4.8                     & 1-6  \\
    Mångfald                                           & 4,9                     & 1-6   \\
    Organisation och mål                               & 4.4                     & 1-6  \\
    Kompetensutveckling                                & 4,4                     & 1-6   \\
    Löner och förmåner                                 & 4,2                     & 1-6   \\
    Attraktiv arbetsgivare                             & 3,3                     & 1-4  
    \end{tabular}
}

我添加了您的表格,而不是使用环境itemize。请注意,我删除了您的长度{\textwidth-\hintscolumnwidth-\separatorcolumnwidth}。也许最好使用lll您使用过的p{300pt}p{80pt}p{35pt}

因此,有了以下 MWE

\documentclass[11pt,a4paper,sans]{moderncv}

\moderncvstyle{casual} % casual head2, body1, foot1  oldstyle head4 body4                    
\moderncvcolor{grey}   

\usepackage[utf8]{inputenc}
\usepackage{tabularx}
\usepackage[scale=0.85]{geometry}
%\setlength{\hintscolumnwidth}{3cm}                %  dates


    \name{name}{name}
    \title{CV}                              
    \address{Hej}{hej}{hej}
    \phone[mobile]{+467000000000}                   
    \email{[email protected]}                               % 
    %\extrainfo{additional information}      
    \photo[160pt][0pt]{example-image}   

    \quote{Hejsan} 

    \setlength{\footskip}{39pt} 
    \moderncvbody{4} % Body of oldfancy style    


    \begin{document}

    \makecvtitle

    \section{Education}
    \cventry{year--year}{Degree}{Institution--3}{City--4}{\textit{Grade}--5}{Description--6}  % arguments 3 to 6 can be left empty
    \cventry{year--year}{Degree}{Institution}{City}{\textit{Grade}}{Description}


\section{Experience}
\subsection{Vocational}
\cventry{year--year}{Job title}{Employer}{City}{}{General description \newline{}%
    Detailed achievements:\\%
    \begin{tabular}{p{300pt}p{80pt}p{35pt}}
    \textbf{Område}                                    & \textbf{Utfall (snitt)} & \textbf{Skala} \\ \hline
    Ledarskap                                          & 4,6                     & 1-6   \\ 
    Arbetsmiljö (fysiska faktorer)                     & 4,1                     & 1-6   \\
    Arbetsmiljö (sociala och organisatoriska faktorer) & 4.8                     & 1-6  \\
    Mångfald                                           & 4,9                     & 1-6   \\
    Organisation och mål                               & 4.4                     & 1-6  \\
    Kompetensutveckling                                & 4,4                     & 1-6   \\
    Löner och förmåner                                 & 4,2                     & 1-6   \\
    Attraktiv arbetsgivare                             & 3,3                     & 1-4  
    \end{tabular}
}

    \section{Languages}
    \cvitemwithcomment{Language 1}{Skill level}{Comment}
    \cvitemwithcomment{\textbf{Language} 2}{\textbf{Skill} level}{Comment}
    \cvitemwithcomment{Language 3}{Skill level}{Comment}

    \section{Computer skills}
    \cvdoubleitem{category 1}{XXX, YYY, ZZZ}{category 4}{XXX, YYY, ZZZ}
    \cvdoubleitem{category 2}{XXX, YYY, ZZZ}{category 5}{XXX, YYY, ZZZ}
    \cvdoubleitem{category 3}{XXX, YYY, ZZZ}{category 6}{XXX, YYY, ZZZ}

    \section{Interests}
    \cvitem{hobby 1}{Description}
    \cvitem{hobby 2}{Description}
    \cvitem{hobby 3}{Description}

    \section{Extra 1}
    \cvlistitem{Item 1}
    \cvlistitem{Item 2}
    \cvlistitem{Item 3}


    \section{References}
    \begin{cvcolumns}
      \cvcolumn{Category 1}{\begin{itemize}\item Person 1\item Person 2\item Person 3\end{itemize}}
      \cvcolumn{Category 2}{Amongst others:\begin{itemize}\item Person 1, and\item Person 2\end{itemize}(more upon request)}
      \cvcolumn[0.5]{All the rest \& some more}{\textit{That} person, and \textbf{those} also (all available upon request).}
    \end{cvcolumns}

\end{document}

您可以无错误地编译以下pdf:

在此处输入图片描述

相关内容