我遇到了一个问题。我想在包含首字母缩略词的标题中显示章节名称。错误如下:
包词汇表错误:词汇表条目“AC:CSR”尚未定义。
但是,我可以在文档中看到打印的首字母缩略词列表。当我从章节名称中删除我的首字母缩略词时,不再出现错误。
这是我的代码:
主文件:
\usepackage[utf8]{inputenc}
\usepackage[LAE,LFE,T1]{fontenc}
\usepackage[greek,main=english]{babel}
\usepackage{CJKutf8}
\usepackage{arabtex}
\usepackage{utf8}
\usepackage{xcolor}
\usepackage{pifont}
\usepackage{float}
\usepackage{gensymb} % Symbole °
\usepackage{amsmath} % Pour encadrer les équations
\usepackage{cancel} % Pour barrer des termes dans les équations
\usepackage[breaklinks,hidelinks]{hyperref}
\usepackage{palatino} % Police
\usepackage{fancyhdr} % Pour faire une en-tête
\usepackage{color} % Pour les tableaux en couleur
\usepackage{xcolor}
\usepackage{colortbl} % Pour les tableaux en couleur
\usepackage{multicol}
\usepackage{listings}
\usepackage{verbatim}
\usepackage{tabularx}
\usepackage{minted}
\usepackage{afterpage}
\usepackage{biblatex}
\usepackage[nottoc]{tocbibind}
\usepackage{tocloft}
\usepackage{pgffor}
\usepackage{svg}
\usepackage{systeme}
\usepackage{pdfpages}
\usepackage{chngcntr}
\usepackage{amsfonts}
\usepackage{pdfpages}
\usepackage{multirow}
\usepackage{longtable}
\usepackage{lscape}
\usepackage{makecell}
\title{Internship Report - V2}
\author{Dylan \textsc{Chevalier}}
\date{June 2022}
\input{Others/acronyms}
\addbibresource{Others/References.bib}
\begin{document}
\appendix
\chapter{\acrfull{ac:csr}}
\label{ap:csr}
\input{Chapters/Appendices/CSR/csr}
\end{document}
类文件:
\ProvidesClass{Internship_Report}[2022/06/02 - Internship Report]
\LoadClass[11pt,twoside]{report}
\RequirePackage[toc,page]{appendix}
\RequirePackage{fancyhdr}
\RequirePackage[toc,acronym]{glossaries}
\RequirePackage{caption}
\RequirePackage{graphicx}
\RequirePackage[titles]{tocloft}
\RequirePackage[bottom]{footmisc}
\RequirePackage{fancyhdr, titlesec}
\RequirePackage{lastpage}
\RequirePackage{tabularx}
\RequirePackage{makeidx}
\RequirePackage{rotating}
\RequirePackage{pifont}
\RequirePackage{listings}
\RequirePackage{color}
\RequirePackage{xifthen}
\RequirePackage{pdfpages}
\RequirePackage[framemethod=TikZ]{mdframed}
\RequirePackage{calc}
\RequirePackage[strict]{changepage}
\RequirePackage{csquotes}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Geometry
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\RequirePackage{calc}
\RequirePackage[a4paper,top=3.5cm,bottom=2.5cm,outer=1in,inner=1.5in]{geometry}
\RequirePackage{showframe}
\setlength{\headheight}{13.59999pt}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Chapter / Section / Appendix
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\RequirePackage{fmtcount}
\makeatletter
\def\@makechapterhead#1{%
\vspace*{-23\p@}%
{\parindent \z@ \raggedright \normalfont
\ifnum \c@secnumdepth >\m@ne
\thispagestyle{fancy} \huge\bfseries \thechapter.\space % Change the size of the chapter title
%\huge\bfseries \@chapapp\space \thechapter
\fi
\interlinepenalty\@M
\huge \bfseries #1\par\nobreak %\Huge \bfseries #1\par\nobreak
\vskip 40\p@
}}
\newcommand\appendix@chapter[1]{%
\addtocontents{toc}{\protect\setcounter{tocdepth}{0}}
\refstepcounter{chapter}%
\def\app@ct{Appendix \@Alph\c@chapter: #1}
\orig@chapter*{\thispagestyle{fancy}\vspace*{-70\p@} \huge\bfseries \app@ct} % Change the size of the chapter title
\markboth{\MakeUppercase{\app@ct}}{\MakeUppercase{\app@ct}}
\addcontentsline{toc}{chapter}{\normalsize\bfseries\app@ct}%
}
\let\orig@chapter\chapter
\g@addto@macro\appendix{\let\chapter\appendix@chapter}
\patchcmd{\@makechapterhead} {\vskip 40}{\vskip 20}{}{}
\patchcmd{\@makeschapterhead}{\vskip 40}{\vskip 20}{}{}
\makeatother
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Hearder / Footer
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\pagestyle{fancy}
\fancyhf{}
\fancyhead[LE]{\thepage}
\fancyhead[RE]{\leftmark}
\fancyhead[LO]{\leftmark}
\fancyhead[RO]{\thepage}
\fancyfoot[LE]{}
\fancyfoot[RO]{}
\fancyfoot[LO]{}
\fancyheadoffset{0cm}
\fancypagestyle{PageNum}{%
\fancyhead{}
\fancyhf{}
\fancyhead[LE]{\thepage}
\fancyhead[RE]{}
\fancyhead[LO]{}
\fancyhead[RO]{\thepage}
\fancyfoot[LE]{}
\fancyfoot[RO]{}
\fancyfoot[LO]{}
\fancyheadoffset{0cm}
\renewcommand{\headrulewidth}{0pt}
}
\newcommand{\BlankPageNum}{
\newpage
\thispagestyle{PageNum}
\mbox{}
\newpage
}
\newcommand{\BlankPage}{
\newpage
\thispagestyle{empty}
\mbox{}
\newpage
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Contents / Figures / Tables / Bibliography Acronyms names
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\renewcommand\contentsname{\vspace{-2.55cm} \centering \huge\bfseries Table of Contents}
\renewcommand\listfigurename{\vspace{-2.55cm} \centering \huge\bfseries List of Figures}
\renewcommand\listtablename{\vspace{-2.55cm} \centering \huge\bfseries List of Tables}
\renewcommand\bibname{\centering \huge\bfseries Bibliography}
提前致谢 !!
答案1
分段命令内的命令必须是健壮的。
标准方法是在它前面添加\protect
。
\chapter{\protect\acrfull{ac:csr}}
在这里不起作用(我不知道为什么),但是在定义为健壮的\chapter{\csr}
地方却起作用。\csr
(使用简化的序言)
\documentclass{report}
\RequirePackage{fancyhdr}
\RequirePackage[toc,acronym]{glossaries}
\RequirePackage[a4paper,top=3.5cm,bottom=2.5cm,outer=1in,inner=1.5in]{geometry}
\RequirePackage{showframe}
\setlength{\headheight}{13.59999pt}
\makeatletter
\def\@makechapterhead#1{%
\vspace*{-23\p@}%
{\parindent \z@ \raggedright \normalfont
\ifnum \c@secnumdepth >\m@ne
\thispagestyle{fancy} \huge\bfseries \thechapter.\space % Change the size of the chapter title
%\huge\bfseries \@chapapp\space \thechapter
\fi
\interlinepenalty\@M
\huge \bfseries #1\par\nobreak %\Huge \bfseries #1\par\nobreak
\vskip 40\p@
}}
\newcommand\appendix@chapter[1]{%
\addtocontents{toc}{\protect\setcounter{tocdepth}{0}}
\refstepcounter{chapter}%
\def\app@ct{Appendix \@Alph\c@chapter: #1}
\orig@chapter*{\thispagestyle{fancy}\vspace*{-70\p@} \huge\bfseries \app@ct} % Change the size of the chapter title
\markboth{\MakeUppercase{\app@ct}}{\MakeUppercase{\app@ct}}
\addcontentsline{toc}{chapter}{\normalsize\bfseries\app@ct}%
}
\let\orig@chapter\chapter
\g@addto@macro\appendix{\let\chapter\appendix@chapter}
\patchcmd{\@makechapterhead} {\vskip 40}{\vskip 20}{}{}
\patchcmd{\@makeschapterhead}{\vskip 40}{\vskip 20}{}{}
\makeatother
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Hearder / Footer
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\pagestyle{fancy}
\fancyhf{}
\fancyhead[LE]{\thepage}
\fancyhead[RE]{\leftmark}
\fancyhead[LO]{\leftmark}
\fancyhead[RO]{\thepage}
\fancyfoot[LE]{}
\fancyfoot[RO]{}
\fancyfoot[LO]{}
\fancyheadoffset{0cm}
\newacronym[type=\glsdefaulttype]{ac:csr}{CSR}{Corporate Social Responsabity} % added <<<<<<<<<<<<<<<<<<<
\begin{document}
\appendix
\DeclareRobustCommand{\csr}{\acrfull{ac:csr}} % <<<<<<<<<<<<<<<<
\chapter{\csr}
\end{document}