代码

代码

我正在准备一本包含多门课程的教学大纲。对于每门课程,我都有一份课程目标清单。然后,我在课程下有针对这些目标的单元/模块。我想使这个引用过程自动化。到目前为止,我已经创建了以下内容:

  1. 每个课程都有一个唯一的代码:\def\ccode{H11}
  2. enumerate课程目标列表:
\newlist{obj}{enumerate}{1}
\setlist[obj,1]{itemsep=0pt,
    label=\fbox{\ccode-CO\arabic*},
    align=left, 
    labelindent=0pt,
    ref=\ccode-CO\arabic*
}
  1. 目的计数器\label
\newcounter{ocount}
\newcommand\objectno{\refstepcounter{ocount}\arabic{ocount}}
\preto\enumerate{\setcounter{ocount}{0}}
  1. 最后,我label在下表中将 s 作为参数调用:
\newcommand{\usummary}[4]{%
    \begingroup%
    \def\arraystretch{1.3}%
    \begin{longtable}{|P @{\hspace{0.005\linewidth}} |Q|}%
        \hline%
        \textbf{Unit:} #1   &   \textbf{\small Objectives mapped:} \ref{#3}\\
        \hline
        \textbf{Credits:} #2    &   \textbf{\small RBT levels achieved:} #4\\
        \hline%
    \end{longtable}%
    \endgroup%
}

但是,最终产品无法编译,并显示以下消息:Missing \endcsname inserted. \item \label{\ccode\objectno}。请帮忙。以下是完整的 MWE:

\documentclass[a5paper, twoside]{article}
\usepackage{enumitem}
\usepackage{hyperref}
%
\usepackage{longtable, array, etoolbox}
%
\newcolumntype{P}{%
    >{%
        \raggedright
        \let\newline\\%
        \arraybackslash\hspace{0pt}%
    }%
    p{0.16\linewidth}%
}
\newcolumntype{Q}{%
    >{%
        \raggedright
        \let\newline\\%
        \arraybackslash\hspace{0pt}%
    }%
    p{0.78\linewidth}%
}
%
\newcommand{\usummary}[4]{%
    \begingroup%
    \def\arraystretch{1.3}%
    \begin{longtable}{|P @{\hspace{0.005\linewidth}} |Q|}%
        \hline%
        \textbf{Unit:} #1   &   \textbf{\small Objectives mapped:} \ref{#3}\\
        \hline
        \textbf{Credits:} #2    &   \textbf{\small RBT levels achieved:} #4\\
        \hline%
    \end{longtable}%
    \endgroup%
}
%
\def\ccode{H11}

%
\newlist{obj}{enumerate}{1}
\setlist[obj,1]{itemsep=0pt,
    label=\fbox{\ccode-CO\arabic*},
    align=left, 
    labelindent=0pt,
    ref=\ccode-CO\arabic*
}
%
\newcounter{ocount}
\newcommand\objectno{\refstepcounter{ocount}\arabic{ocount}}
\preto\enumerate{\setcounter{ocount}{0}}
%

%
%
\begin{document}
%
\subsubsection{Objectives}
%
    The students will be able to
    \begin{obj}
        \item \label{\ccode\objectno}
        Remember the important inequalities.
        \item \label{\ccode\objectno}
        Apply the appropriate inequality for specific problems.
        \item \label{\ccode\objectno}
                Understand the fundamental properties of polynomials, including their degree, leading coefficient, and the relationship between roots and coefficients.
        \item \label{\ccode\objectno}
                Apply transformation techniques to manipulate equations, including the ability to shift and reflect graphs of polynomial functions.
        \item \label{\ccode\objectno}
                Solve cubic and biquadratic equations using appropriate methods, such as Cardan’s method and Ferrari’s method.
        \item \label{\ccode\objectno}
                Analyse and solve reciprocal and binomial equations, demonstrating proficiency in identifying and manipulating these specific equation types.
        \item \label{\ccode\objectno}
                Utilise knowledge of symmetric functions of roots to determine relationships and patterns among the roots of polynomial equations.
        \item \label{\ccode\objectno}
                Apply strategies to determine the location of roots, including the use of intermediate value theorem, Descartes' rule of signs, graphical methods and Strum's function.
        \item \label{\ccode\objectno}
                Understand basic structure of Argand plane and perform algebra thereat.
        \item \label{\ccode\objectno}
                Develop a solid understanding of geometric principles and terminology, laying the groundwork for further exploration in advanced mathematics and related fields.
        \item \label{\ccode\objectno}
                Examine essential geometric objects, including pairs of straight lines, circles, and conic sections. They will learn to analyse and manipulate these objects, investigating their properties, equations, and relationships.
        \item \label{\ccode\objectno}
                Analyse geometric objects, employ coordinate systems, derive equations, and apply geometric concepts to solve problems.
    \end{obj}
%
\subsubsection{Content}
%
    \usummary{1}{1}{\ref{\ccode1,\ccode2}}{Remembering, Understanding, Applying}
\end{document}

答案1

问题是它\objectno不可扩展。因此,如果你用另一种方式做,你就能得到你想要的东西。

列表enumitem中已经有计数器。因此您可以利用它并使用\the<ListName><level>宏。对于您的情况\theobji。如果您将其放入宏中,假设

\newcommand\alabel{\label{\theobji}}

重新定义时可以有更大的灵活性。由于列表的重新定义,标签用一对额外的括号存储(我不知道为什么)。所以,您也需要用这些额外的括号来引用它。这就是您看到的原因。请注意,标签与列表创建中的引用定义( )\ref{{\ccode-CO1}}相关联。ref={\ccode-CO\arabic*}

代码

\documentclass[a5paper]{article}

\pagestyle{empty}

\usepackage{enumitem}
\usepackage{hyperref}

\usepackage{longtable, array}

\newcolumntype{P}{%
  >{%
    \raggedright
    \let\newline\\%
    \arraybackslash\hspace{0pt}%
  }%
  p{0.16\linewidth}%
}
\newcolumntype{Q}{%
  >{%
    \raggedright
    \let\newline\\%
    \arraybackslash\hspace{0pt}%
  }%
  p{0.78\linewidth}%
}
%
\newcommand{\usummary}[4]{%
  \begingroup%
  \def\arraystretch{1.3}%
  \begin{longtable}{|P @{\hspace{0.005\linewidth}} |Q|}%
    \hline%
    \textbf{Unit:} #1   &   \textbf{\small Objectives mapped:} \ref{#3}\\
    \hline
    \textbf{Credits:} #2    &   \textbf{\small RBT levels achieved:} #4\\
    \hline%
  \end{longtable}%
  \endgroup%
}

\def\ccode{H11}

\newlist{obj}{enumerate}{1}
\setlist[obj,1]{
  itemsep=0pt,
  label=\fbox{\ccode-CO\arabic*},
  align=left, 
  labelindent=0pt,
  ref={\ccode-CO\arabic*},
}

\newcommand\alabel{\label{\theobji}}


\begin{document}
  \section{Objectives}
  
  The students will be able to
  \begin{obj}
    \item \alabel
    Remember the important inequalities.
    \item \alabel
    Apply the appropriate inequality for specific problems.
    \item \alabel
    Understand the fundamental properties of polynomials, including their degree, leading coefficient, and the relationship between roots and coefficients.
  \end{obj}
  
  \section{Content}
  
  \usummary{1}{1}{{\ccode-CO1}}{Remembering, Understanding, Applying}
 
\end{document}

在此处输入图片描述

参考文献列表(补充)

cleveref需要重新定义计数器的名称(我用 将其留空\crefname{obji}{}{}),并且不能与 中的引用扩展一起使用enumitem

在此版本中,您需要使用计数器的数字形式来定义模式\arabic{obji}。这也解决了双括号的问题。请注意,您不需要针对l-\ccode-CO\arabic{obji}列表使用不同的模式 (),但它可能有助于区分示例。

带有示例的代码如下。

\documentclass[a5paper]{article}

\pagestyle{empty}

\usepackage{enumitem}
\usepackage{hyperref}

\usepackage{longtable, array}

\usepackage{cleveref}

\newcolumntype{P}{%
  >{%
    \raggedright
    \let\newline\\%
    \arraybackslash\hspace{0pt}%
  }%
  p{0.16\linewidth}%
}
\newcolumntype{Q}{%
  >{%
    \raggedright
    \let\newline\\%
    \arraybackslash\hspace{0pt}%
  }%
  p{0.78\linewidth}%
}
%
\newcommand{\usummary}[4]{%
  \begingroup%
  \def\arraystretch{1.3}%
  \begin{longtable}{|P @{\hspace{0.005\linewidth}} |Q|}%
    \hline%
    \textbf{Unit:} #1   &   \textbf{\small Objectives mapped:} \cref{#3}\\
    \hline
    \textbf{Credits:} #2    &   \textbf{\small RBT levels achieved:} #4\\
    \hline%
  \end{longtable}%
  \endgroup%
}

\def\ccode{H11}

\newlist{obj}{enumerate}{1}
\setlist[obj,1]{
  itemsep=0pt,
  label=\fbox{\ccode-CO\arabic*},
  align=left, 
  labelindent=0pt,
  ref={\ccode-CO\arabic*},
}
% empty names
\crefname{obji}{}{}

\newcommand\alabel{\label{l-\ccode-CO\arabic{obji}}}


\begin{document}
  \section{Objectives}
  
  The students will be able to
  \begin{obj}
    \item \alabel
    Remember the important inequalities.
    \item \alabel
    Apply the appropriate inequality for specific problems.
    \item \alabel
    Understand the fundamental properties of polynomials, including their degree, leading coefficient, and the relationship between roots and coefficients.
  \end{obj}
  
  \section{Content}
  
  \usummary{1}{1}{l-\ccode-CO1,l-\ccode-CO2}{Remembering, Understanding, Applying}
  
\end{document}

相关内容