! LaTeX 错误:出现错误 - 可能缺少 \item。- 添加 \textbf 时

! LaTeX 错误:出现错误 - 可能缺少 \item。- 添加 \textbf 时

我下载了一个 C 模板,并用它来写我的简历。在“工作经验”部分,我决定添加一行粗体字,用于\textbf将经验归类为所获得的相关可转移技能。在rSubsection我的第一份简历(参见项目管理)中,它起作用了。在第二份简历(rSubsection如下所示)(技术技能)中,第一\textbf行出现错误。第二份简历(团队合作)工作正常!

\begin{rSection}{Working Experience} 
\begin{rSubsection}{University of city}{November 2021 - Present}{Postdoctoral Researcher}{city, country} 
\textbf{Project Management} 
\item Leading a research project 
\item Delivered project milestones on time. 
\end{rSubsection}

\begin{rSubsection}{University of city}{October 2016 - October 2019}{Imaging Scientist}{City, Country}

\textbf{Technical Skills} %the moment I use this line I get an error on the line below
\item Lab Maintenance: microscope setup, restocking of basic consumables.

\textbf{Teamwork}
\item Sharing expertise with undergraduate and postgraduate students

\end{rSubsection}

错误信息:

! LaTeX Error: Something's wrong--perhaps a missing \item.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.73 \item M
            aintenance: microscope setup, restocking of basic consumables.

这也是模板部分:

%   SECTION FORMATTING
%----------------------------------------------------------------------------------------

% Defines the rSection environment for the large sections within the CV
\newenvironment{rSection}[1]{ % 1 input argument - section name
  \sectionskip
  \MakeUppercase{\bf #1} % Section title
  \sectionlineskip
  \hrule % Horizontal line
  \begin{list}{}{ % List for each individual item in the section
    \setlength{\leftmargin}{1.5em} % Margin within the section
  }
  \item[]
}{
  \end{list}
}

%----------------------------------------------------------------------------------------
%   WORK EXPERIENCE FORMATTING
%----------------------------------------------------------------------------------------

\newenvironment{rSubsection}[4]{ % 4 input arguments - company name, year(s) employed, job title and location
 {\bf #1} \hfill {#2} % Bold company name and date on the right
 \ifthenelse{\equal{#3}{}}{}{ % If the third argument is not specified, don't print the job title and location line
  \\
  {\em #3} \hfill {\em #4} % Italic job title and location
  }\smallskip
  \begin{list}{$\cdot$}{\leftmargin=0em} % \cdot used for bullets, no indentation
   \itemsep -0.5em \vspace{-0.5em} % Compress items in list together for aesthetics
  }{
  \end{list}
  \vspace{0.5em} % Some space after the list of bullet points
}

% The below commands define the whitespace after certain things in the document - they can be \smallskip, \medskip or \bigskip
\def\namesize{\huge} % Size of the name at the top of the document
\def\addressskip{\smallskip} % The space between the two address (or phone/email) lines
\def\sectionlineskip{\medskip} % The space above the horizontal line for each section 
\def\nameskip{\bigskip} % The space after your name at the top
\def\sectionskip{\medskip} % The space after the heading section

没有\item缺失,所以我添加的内容肯定存在一些问题\textbf,但我有时不明白它是如何工作的,有时则不然!

答案1

rSectionOP 代码是来自代码由 Steven B. Segletes 提供回答如何禁用 rSubsection 中的列表?

在链接的代码中,您可以在rSubsection环境中插入文本或表格。不仅仅是\item

但环境中的第一件事rSubsection需要是一个\item

您可以使用 隐藏列表项中的项目符号\item[]

为了防止所有内容都以粗体显示,我\normalfont在环境代码中添加了rSection

我还删除了OP 代码中未使用的\namesize\addressskip和的定义。\nameskip

OP 漏掉了\usepackage{ifthen}所以我添加了它(需要\ifthenelse)。

\documentclass[11pt]{article}
\usepackage{ifthen}
%   SECTION FORMATTING
%----------------------------------------------------------------------------------------

% Defines the rSection environment for the large sections within the CV
\newenvironment{rSection}[1]{ % 1 input argument - section name
  \sectionskip
  \MakeUppercase{\bf #1} % Section title
  \sectionlineskip
  \hrule % Horizontal line
  \begin{list}{}{ % List for each individual item in the section
    \setlength{\leftmargin}{1.5em} % Margin within the section
  }
  \normalfont\item[]
}{
  \end{list}
}

%----------------------------------------------------------------------------------------
%   WORK EXPERIENCE FORMATTING
%----------------------------------------------------------------------------------------

\newenvironment{rSubsection}[4]{ % 4 input arguments - company name, year(s) employed, job title and location
 {\bf #1} \hfill {#2} % Bold company name and date on the right
 \ifthenelse{\equal{#3}{}}{}{ % If the third argument is not specified, don't print the job title and location line
  \\
  {\em #3} \hfill {\em #4} % Italic job title and location
  }\smallskip
  \begin{list}{$\cdot$}{\leftmargin=0em} % \cdot used for bullets, no indentation
   \itemsep -0.5em \vspace{-0.5em} % Compress items in list together for aesthetics
  }{
  \end{list}
  \vspace{0.5em} % Some space after the list of bullet points
}

% The below commands define the whitespace after certain things in the document - they can be \smallskip, \medskip or \bigskip
\def\sectionlineskip{\medskip} % The space above the horizontal line for each section 
\def\sectionskip{\medskip} % The space after the heading section

\begin{document}

\begin{rSection}{Working Experience} 
\begin{rSubsection}{University of city}{November 2021 - Present}{Postdoctoral Researcher}{city, country} 
\item[] \textbf{Project Management} % added a \item[] because we need here an \item, but the bullet is hidden with the blank option []
\item Leading a research project 
\item Delivered project milestones on time. 
\end{rSubsection}

\begin{rSubsection}{University of city}{October 2016 - October 2019}{Imaging Scientist}{City, Country}

\item[] \textbf{Technical Skills} % added a \item[] because we need here an \item, but the bullet is hidden with the blank option []
\item Lab Maintenance: microscope setup, restocking of basic consumables.

\textbf{Teamwork} % \item[] not needed here. Moreover, without the `\item[]` here, a slight vertical space (welcomed) is added.
\item Sharing expertise with undergraduate and postgraduate students

\end{rSubsection}
\end{rSection} % <-- added (missing in the OP code)

\end{document}

在此处输入图片描述

笔记:Steven B. Segletes 的代码用于本教程来自 Drshika Asher,以便用 LaTeX 制作简历。这可以给出以下布局:

在此处输入图片描述

(与 OP 提供的代码无关,但在 Drshika Asher 的教程中,最后一个代码示例缺失了\item[]\textbf{Coursework:}此外,在提供的包含完整代码的 Overleaf 项目中,\item[]缺少一些代码:第 100、128、133、142 行)。

相关内容