我正在使用 xelatex 撰写论文。我使用 TikZ 包来制作图表。虽然当我检查我的 pdf 时它可以正确地制作图表,但它给出了以下错误
“!缺少 { 插入。”
并且章节标题到处都消失了,尽管小节标题还在显示。为了清晰起见,我添加了论文代码的主文件。如果我删除 tikz 包,那么代码运行正常,只是没有生成图形。问题只出在 tikz 包上,我已经检查了好几次。
\documentclass[twoside,11pt,bibliography=totoc, fleqn,enabledeprecatedfontcommands]{scrbook}
\usepackage{fontspec}
\defaultfontfeatures{Ligatures=TeX}
\usepackage{scrpage2}
\ifoot[]{}
\cfoot[\pagemark]{\pagemark}
\ofoot[]{}
\pagestyle{scrplain}
\renewcommand*{\pnumfont}{\normalfont \sffamily\fontsize{10}{10}\bfseries}
\setlength{\parskip}{11pt} % 1ex plus 0.5ex minus 0.2ex}
\setlength{\parindent}{0.5in} % paragraph left indentation
\usepackage{indentfirst} % to set indent for first paragraph
\usepackage{tikz}
\usepackage[a4paper,
left=12.5mm,right=12.5mm,top=25mm,bottom=25mm,bindingoffset=19.5mm]{geometry}
\usepackage[small,sf,bf]{titlesec}
\setmainfont[]{Book Antiqua}
\setsansfont{Candara}
\titleformat{\chapter}[display]
{\normalfont\fontsize{18}{11} \flushright\sffamily \bfseries}{\normalfont
\fontsize{27}{11}\sffamily \textit \chaptername \thechapter}{0pt}
{\fontsize{27}{11}}
\titleformat{\section}
{\normalfont \sffamily\bfseries \fontsize{13}{11}\MakeUppercase}
{\sffamily\thesection}{0.2em}{}
\titleformat{\subsection}
{\normalfont\fontsize{12}{11}\sffamily\bfseries}{\sffamily\thesubsection}
{0.2em}{}
\titleformat{\subsubsection}
{\normalfont\fontsize{11}{11}\sffamily\bfseries\itshape}
{\sffamily\thesubsection}{0.2em}{}
\titlespacing*{\chapter} {0pt}{0pt}{44pt}
\titlespacing*{\section} {0pt}{22pt}{-11pt}
\titlespacing*{\subsection}{0pt}{11pt}{-11pt}
\titlespacing*{\subsubsection}{0pt}{11pt}{-11pt}
\usepackage{mdwlist}
\usepackage[labelfont=bf,font={normalsize,sf}]{caption}
\DeclareCaptionLabelSeparator{colon}{ : }
\captionsetup{labelsep=colon}
\usepackage{graphicx,subfigure}
\usepackage{multirow}
\usepackage{multicol}
\usepackage{mathptmx}
\usepackage{amsmath,amssymb,amsthm}
\usepackage{amsmath}
\usepackage{algorithm2e}
\newtheorem{theorem}{\sffamily\textbf{Theorem}\rmfamily}[chapter]
\newtheorem{proposition}{\sffamily\textbf{Proposition}\rmfamily}[chapter]
\newtheorem{definition}{\sffamily\textbf{Definition}\rmfamily}[chapter]
\newtheorem{pro}{\sffamily\textbf{Procedure}\rmfamily}[chapter]
\newtheorem{example}{\sffamily\textbf{Example}\rmfamily}[chapter]
\newtheorem{corollary}{\sffamily\textbf{Corollary}\rmfamily}[chapter]
\newtheorem{lemma}{\sffamily\textbf{Lemma}\rmfamily}[chapter]
\newtheorem{algo}{\sffamily\textbf{Algorithm}\rmfamily}[chapter]
\renewenvironment{proof}{\hspace{-35pt}\sffamily
\textbf{Proof:}\rmfamily}{}
\setlength{\mathindent}{1cm}
\usepackage[titletoc,title]{appendix}
\usepackage[square]{natbib}
\renewcommand\bibname{References} % to change name 'Bibliography' to
''References
\setlength{\bibsep}{0pt} % to force space between references to zero
\setlength{\textfloatsep}{33pt} %distance between floats on the top or
the bottom and the text;
\setlength{\floatsep}{33pt} %distance between two floats;
\setlength{\textfloatsep}{33pt} %distance between floats inserted inside
the page text (using h) and the text proper
\setlength{\abovecaptionskip}{11pt} % set space between caption and
figure float
\setlength{\belowcaptionskip}{11pt} % set space between caption and
table float
\usepackage[smaller,style=long3colheader,acronyms,nopostdot,nonumberlist]
{glossaries}
\renewcommand*{\glsnamefont}[1]{\textmd{#1}} % make name of the glossary
item in normal (bold otherwise)
\renewcommand{\glsnamefont}[1]{\sf \textmd{#1}\hspace{30pt}}
\renewcommand*{\acronymfont}[2]{\textsf{#1}} % for changing font of
acronyms
\renewcommand*{\firstacronymfont}[1]{\emph{#1}}
\setglossarystyle{long3colheader}
\renewcommand*{\glossaryheader}{%
\vspace{11pt} \sf \itshape \fontsize{10}{100} Symbol & \sf \itshape
\fontsize{10}{100} Description \\\endhead}
\renewcommand*{\acronymname}{acronym}
\renewcommand*{\entryname}{Abbreviation}
\renewcommand*{\descriptionname}{Full Form}
\renewcommand*{\pagelistname}{}
\setlength{\glsdescwidth}{0.9\linewidth}
\makeglossaries
\input{listofsymbols/listofsymbols} % .tex file containing glossary entries
for symbols
\input{listofabbreviations/listofabbreviations} % .tex file containing
acronym entries for abbriviations
\usepackage[subfigure,titles]{tocloft}
\renewcommand{\cftchapfont}{\fontsize{11}{10}\sffamily\bfseries}
\renewcommand{\cftchappagefont}{\normalfont \fontsize{10}
{10}\sffamily}
\renewcommand{\cftchappresnum}{Chapter }
\renewcommand{\cftchapaftersnum}{:}
\renewcommand{\cftchapnumwidth}{57pt}
\renewcommand{\cftsecindent}{0pt}
\renewcommand{\cftsubsecindent}{24pt}
\renewcommand{\cftsubsecnumwidth}{26pt}
\renewcommand{\cftsecfont}{\fontsize{10}{10} \sffamily}
\renewcommand{\cftsubsecfont}{\normalfont \fontsize{10}{11}
\sffamily\itshape}
\renewcommand{\cftsubsecpagefont}{\normalfont \fontsize{10}{11}
\sffamily\itshape}
\renewcommand{\cftfigfont}{\normalfont \fontsize{10}{10} \sffamily}
\renewcommand{\cfttabfont}{\normalfont \fontsize{10}{10} \sffamily}
\renewcommand{\cftdot}{}
\renewcommand{\cfttoctitlefont}{\normalfont \fontsize{14}{11}
\sffamily\bfseries}
\renewcommand{\cftloftitlefont}{\normalfont \fontsize{14}{11}
\sffamily\bfseries}
\renewcommand{\cftlottitlefont}{\normalfont \fontsize{14}{11}
\sffamily\bfseries}
\cftsetrmarg{60pt}
\makeatletter
\newcommand*\updatechaptername{%
\addtocontents{toc}
{\protect\renewcommand*\protect\cftchappresnum{Annexure}}
}
\makeatother
\makeatletter
\newcommand*\updatechapnumafter{%
\addtocontents{toc}
{\protect\renewcommand*\protect\cftchapnumwidth{67pt}}
}
\makeatother
\begin{document}
\include{titlepage/titlepage}
\frontmatter
\include{declaration/declaration}
\include{certificate/certificate}
\include{abstract/abstract}
\include{ack/ack}
\clearpage
\tableofcontents
\addtocontents{toc}{\protect \hfill \sffamily \fontsize{10}{10}
\textit{page} \par}
\addtocontents{toc}{\protect \sffamily \fontsize{10}{10}
\textit{Abstract} \protect \hfill \protect \sffamily \fontsize{10}
{10}\textit{i}\par}
\addtocontents{toc}{\protect \sffamily \fontsize{10}{10}
\textit{Acknowledgements} \protect \hfill \protect \sffamily
\fontsize{10}{10}\textit{iii}\par}
\addtocontents{toc}{\protect \sffamily \fontsize{10}{10}
\textit{Contents} \protect \hfill \protect \sffamily \fontsize{10}
{10}\textit{v}\par}
\addtocontents{toc}{\protect \sffamily \fontsize{10}{10} \textit{List
of Figures} \protect \hfill \protect \sffamily \fontsize{10}
{10}\textit{vii}\par}
\addtocontents{toc}{\protect \sffamily \fontsize{10}{10} \textit{List of
Tables} \protect \hfill \protect \sffamily \fontsize{10}
{10}\textit{viii}\par}
\addtocontents{toc}{\protect \sffamily \fontsize{10}{10}
\textit{List of Symbols} \protect \hfill \protect \sffamily
\fontsize{10}{10}\textit{ix}\par}
\addtocontents{toc}{\protect \sffamily \fontsize{10}{10} \textit{List of
Abbreviations} \protect \hfill \protect \sffamily \fontsize{10}
{10}\textit{x}\par}
\renewcommand{\cftfigindent}{10pt}
\renewcommand{\cftfignumwidth}{37pt}
\listoffigures
\addtocontents{lof}{\protect \sffamily\itshape \fontsize{10}{10} Figures
\protect\hspace{10pt} Title \protect\hfill\mbox{page}\par}
\renewcommand{\cfttabindent}{10pt}
\renewcommand{\cfttabnumwidth}{37pt}
\listoftables
\addtocontents{lot}{\protect \sffamily\itshape \fontsize{10}{10} Figures
\protect\hspace{10pt} Title \protect\hfill\mbox{page}\par}
\printglossary[title=List of Symbols]
\printglossary[type=acronym, title=List of Abbreviations]
\protect\renewcommand{\chaptername}{}
\mainmatter
\include{chapter1/chapter1}
\include{chapter2/chapter2}
\include{chapter3/chapter3}
\include{chapter4/chapter4}
\include{chapter5/chapter5}
\include{chapter6/chapter6}
\protect\renewcommand{\chaptername}{Annexure }
\appendix
\updatechapnumafter
\updatechaptername
\chapter{aa}
\backmatter
\bibliographystyle{iitjphd}
\bibliography{bibliography/references}
\end{document}
答案1
您的问题不是由包引起的,而是由节样式定义中使用的tikz
属性引起的。有关详细信息,请参阅scrbook
\MakeUppercase
Stefan Kottwitz 回答。基于此,看看您对\titleformat{\section}
以下内容的定义是否
\titleformat{\section}
{\sffamily\bfseries\fontsize{13}{11}\selectfont\uppercase}% <-- observe difference
{\sffamily\thesection}
{0.2em}
{}
给出了你所期望的:
根据上述定义,我可以无错误地编译您的文档(当然,我在文档中直接写了章节、节和小节标题)。
无关:
我必须承认,我迷失在你的文档中。你真的需要所有这些重新定义吗?顺便说一句,例如,你对字体大小的定义\fontsize{14}{11}
是错误的。第一个数字是字体大小,第二个是基线跳跃(必须大于字体大小),也缺失了\selectfont
。你为什么不使用更简单的small
、或\large
、或\Large
命令?