未定义控制序列。\set@color ...\@pdfcolorstack push{\current@color}\aftergroup \reset@color

未定义控制序列。\set@color ...\@pdfcolorstack push{\current@color}\aftergroup \reset@color

我知道,有这个问题但是我对 latex 文件的了解.cls太少了。我尝试按照那里的解决方案去做,但我没有用过,begincmd所以我不知道如何将它应用到我的情况中。

导致问题的错误信息:

(./main.aux)
! Undefined control sequence.
\set@color ...\@pdfcolorstack push{\current@color 
                                                  }\aftergroup \reset@color 
l.41 \begin{document}
                     
? 

.cls以下是文件使用颜色的部分:

\AtBeginDocument
    {
    \hypersetup{
        pdftitle = {\inserttitle},
        pdfauthor = {\insertauthor},
        pdfsubject = {\insertsubject},
        pdfkeywords = {PI4 Template v1.6},
        citebordercolor = {.36 .93 0},
        linkbordercolor = {1 .6 .33},
        menubordercolor = {1 .6 .33},
        urlbordercolor = {.39 .82 1},
        pdfborder = {0 0 .5}
    }

整个.cls文件如下

% Basic class options
\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesClass{pi4-thesis}[2015/12/17 PI4 Thesis Template V1.6]

% Option for language selection.
\let\if@langgerman\iffalse
\DeclareOption{german}{\let\if@langgerman\iftrue}

% Pass otions that are not specified above to the base class.
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{scrbook}}

\ProcessOptions

% Load base class.
\LoadClass[a4paper,
           toc=listof,
           toc=bib,
           11pt,
           DIV=10
           ]{scrbook}

% UTF-8 should be supported by all major editors. If this causes problem change it to another
% encoding (e.g., 'latin1').
\RequirePackage[utf8]{inputenc}
% ---------------------------------

% Title page details
\newcommand{\piivsubject}[1]{\newcommand{\insertsubject}{#1}}
\newcommand{\piivtitle}[1]{\newcommand{\inserttitle}{#1}}
\newcommand{\piivauthor}[1]{\newcommand{\insertauthor}{#1}}
\newcommand{\piivsupervisor}[1]{\newcommand{\insertsupervisor}{#1}}
% ---------------------------------

% Language selection
\if@langgerman
    \RequirePackage[main=ngerman,english]{babel}
    \babeltags{lang-main = ngerman}

    \newcommand{\insertcitydate}[2]{#1, den #2}

    \bibliographystyle{dinat}
\else
    \RequirePackage[main=english,ngerman]{babel}
    \babeltags{lang-main = english}

    \newcommand{\abstractchap}{\addchap{Abstract}}
    \newcommand{\declarationofhonorchap}{\chapter{Declaration of Honour}}
    \newcommand{\insertsupervisordetails}{Supervisor: \insertsupervisor}
    \newcommand{\insertinstitution}{institution}
    \newcommand{\insertauthordetails}{\vspace{0.2cm}
    \insertauthor}

    \newcommand{\insertcitydate}[2]{#1, #2}

    \bibliographystyle{abbrvnat}
\fi

\babeltags{lang-de = ngerman}
\babeltags{lang-en = english}
% ---------------------------------

% Package includes
%
% The following list of packages should provide you a more or less complete basis for your thesis.
% However, it might be required that you change some package options or include new ones. For each
% of the used package a very brief description is given. If you like to know more on a specific
% package I recommend that you read the package documentation at http://www.ctan.org/pkg/ (just
% search for the package name). Of course you also can include more packages if you need them.
%
% Nicer fonts for your document.
\RequirePackage[T1]{fontenc}
\RequirePackage{libertine}
% http://www.khirevich.com/latex/microtype/
\RequirePackage[activate={true,nocompatibility},
                final,
                tracking=true,
                kerning=true,
                spacing=true,
                factor=1100,
                stretch=10,
                shrink=10]{microtype}
\RequirePackage{ellipsis}
% Responsible for the style of bibliography and citations.
\RequirePackage[round,
                sort&compress]{natbib}
% Brings color to your document.
\RequirePackage[usenames,
                dvipsnames,
                table]{xcolor}
% Better formatting of URLs in the text.
\RequirePackage[hyphens]{url}
% Provides functions for better hyphenation of words.
\RequirePackage{hyphenat}
% Produces clickable links within the PDF file.
\RequirePackage[pdftex,
            unicode=true,
            bookmarks=true,
            hyperfootnotes=false
            ]{hyperref}
% Provides support for including images in your document.
\RequirePackage{graphicx}
% Support for multiple images in one figure environment.
\RequirePackage{subfig}
% More options for tabular envrionments.
\RequirePackage{array}
\RequirePackage{tabu}
\RequirePackage{longtable}
\RequirePackage{booktabs}
% Support for listings (for displaying algorithms, source code, etc.).
\RequirePackage{listings}
% Provides todo notes that help you keep track of what you have to do.
\RequirePackage{todonotes}
% Produces nonsense text. Can be removed as soon as you started writing your own text.
\RequirePackage{blindtext}
% Provides the glossary function.
\RequirePackage[toc,
                acronyms,
                automake=true,
                numberedsection=nameref,
                translate=babel]{glossaries}
% Some small improvements for the KOMA script packages.
\RequirePackage{scrhack}
% Allows you to rotate a page correctly in the PDF.
\RequirePackage{pdfpages}
% A more intelligent reference system
\RequirePackage{cleveref}
% ---------------------------------

% Language options for specific packages
\if@langgerman
    \renewcommand{\lstlistlistingname}{Auflistungsverzeichnis}
    \renewcommand{\lstlistingname}{Auflistung}
    \renewcommand{\acronymname}{Abkürzungsverzeichnis}
\else
    \renewcommand{\lstlistlistingname}{List of Listings}
    \microtypecontext{spacing=nonfrench}
\fi
% ---------------------------------

% Layout tweaks
%
% Schusterjungen und Hurenkinder verhindern. Siehe deutsches TeX-FAQ (6.1.3)
\clubpenalty = 10000
\widowpenalty = 10000
\displaywidowpenalty = 10000
% ---------------------------------

% Title page
\title{\textnormal{\textsc{\Large \insertsubject}}\\
\vspace{0.4cm}
\inserttitle}
\author{\insertauthordetails}
\publishers{\insertsupervisordetails\\
\vspace{1cm}
\insertinstitution}
% ---------------------------------

% Adaptions for the actual document
\AtBeginDocument
{
\hypersetup{
    pdftitle = {\inserttitle},
    pdfauthor = {\insertauthor},
    pdfsubject = {\insertsubject},
    pdfkeywords = {PI4 Template v1.6},
    citebordercolor = {.36 .93 0},
    linkbordercolor = {1 .6 .33},
    menubordercolor = {1 .6 .33},
    urlbordercolor = {.39 .82 1},
    pdfborder = {0 0 .5}
}

\setlength{\parindent}{15pt}

\frontmatter
\maketitle
}
% ---------------------------------

以及main.tex

\documentclass[oneside]{pi4-thesis}
% Choose between bachelor thesis or master thesis.
\piivsubject{stuff \texorpdfstring{\\
more \\
stuff}{}}
% The title of your work.
\piivtitle{title}
% Your name.
\piivauthor{Me}
% Name of your supervisor.
\piivsupervisor{Dr. X}
% The date you submit your thesis. You can substitute the command with any date.
\date{\today}

% If you want to use the glossary make sure your 'makeindex' toolchain is working correctly.
% Alternetively, you might want to look into the 'xindy' option of the glossaries package.
\makeglossaries

\begin{document}
%\input{src/glossary}

% ---------------------------------
% Begin of abstract
\abstractchap
% \blindtext creates a paragraph of non-sense text. Replace it with your actual content.
\blindtext
% End of abstract
% ---------------------------------

% ---------------------------------
% Begin of listings
\microtypesetup{protrusion=false} % disables protrusion locally in the document
\tableofcontents
% If you should not have any figures, tables or acronyms in your paper remove the according list.
%\listoffigures
%\listoftables
% Uncomment the next line if you use listings in your document.
% \lstlistoflistings
\microtypesetup{protrusion=true} % enables protrusion

\printglossary[type=\acronymtype]
% End of listings
% ---------------------------------

% ---------------------------------
% Begin of main part
\mainmatter

%\input{src/chapter_1} 

%\input{src/chapter_2}

%\input{src/chapter_3}

% End of main part
% ---------------------------------

% ---------------------------------
% Begin of appendix
\appendix
% Appendix chapters are optional. Use it if you have very long tables or additional figures that
% do not belong to the main text.
%\input{src/appendix}

% Remove this from the final document
%\input{src/checklist}

\backmatter

\bibliography{library}

% Fix for long URLs in bibliography
\sloppy
\printglossary
\fussy
   
% End of appendix
% ---------------------------------

\end{document}

答案1

您的班级正在尝试以 形式排版标题\AtBeginDocument。这不是一个好主意。

如果您有当前的 latex(格式为 2020-10-01),您可以声明一条规则将代码移动到另一个位置:

\makeglossaries
\DeclareHookRule{begindocument}{pi4-thesis}{after}{cleveref}
\begin{document}

这也不是完美的,但至少颜色现在设置正确了。

相关内容