![写入 \newpage 时出现“未定义的控制序列”错误](https://linux22.com/image/445860/%E5%86%99%E5%85%A5%20%5Cnewpage%20%E6%97%B6%E5%87%BA%E7%8E%B0%E2%80%9C%E6%9C%AA%E5%AE%9A%E4%B9%89%E7%9A%84%E6%8E%A7%E5%88%B6%E5%BA%8F%E5%88%97%E2%80%9D%E9%94%99%E8%AF%AF.png)
在我的论文序言中,当我写入 \newpage 时出现以下错误:
Undefined control sequence. LaTex Error: File ´' not found.
请注意,下面的代码中有 2 个 x \newpage
,但只有第二个会产生问题。我尝试过\clearpage
改为这样写,但结果是一样的。
有人能看出是什么导致了这个错误吗?
\documentclass[oneside]{article}
%%%% packages
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage{footnote}
\usepackage{csquotes}
\usepackage{eso-pic}
\usepackage[dvipdfm]{graphicx}
\usepackage{bmpsize}
\usepackage[a4paper, hmargin={2.5cm, 3cm}, vmargin={3cm, 3cm}]{geometry}
\usepackage{fancyhdr}
\graphicspath{ {figures/} }
\usepackage{array}
\usepackage[titletoc]{appendix}
\usepackage{tcolorbox}
\usepackage{tabularx}
\usepackage{multirow}
\usepackage{topcapt}
\usepackage{marginnote}
\usepackage{threeparttable}
\usepackage[font=small,format=plain,labelfont=bf,textfont=normal,justification=justified,singlelinecheck=false]{caption}
\usepackage{booktabs}
\usepackage{amsmath}
\usepackage{setspace}
\usepackage{parskip}
\usepackage{float}
\usepackage{wrapfig}
\usepackage[style=apa, citestyle=apa, sorting=nyt ]{biblatex}
\addbibresource{Biblo.bib}
\pagestyle{fancy}
\usepackage{etoolbox}\apptocmd\appendix{\pretocmd\section{\clearpage}{}{}}{}{}
\usepackage{subfiles}
% commands
\setstretch{1.25}
\newcommand{\margmod}[1]{\marginnote{\setstretch{.5}\parbox[t]{\marginparwidth}{\raggedright\emph{#1}}}}
\author{
\LARGE{My name} \\
\vspace{0cm} \\
{Academic Supervisor: Supervisor name} \\
\vspace{.5cm} \\
}
\title{
\vspace{3mm}
\Huge{Master's Thesis}\\
\vspace{18mm}
\LARGE{Name of thesis}
\vspace{90mm}
}
\date{February 2022}
%%%% Layout style
\linespread{1.5}
\fancyhead[L]{}
\fancyhead[R]{\slshape \rightmark}
\setlength{\parskip}{1em}
\usepackage{tikz}
\usetikzlibrary{calc,matrix}
\usepackage{lipsum}
\newcommand{\Maroonunderline}[1]{{\color{Maroon}\underline{{\color{black}#1}}}}
\definecolor{Maroon_1}{RGB}{144,26,30}
%%%% Frontpage layout
\begin{document}
\pagenumbering{roman}
\AddToShipoutPicture*{\put(0,602){\includegraphics*[viewport=0 600 700 1600]{\ColourPDF}}} % adds frontpage image
\AddToShipoutPicture*{\put(0,0){\includegraphics*{\TitlePDF}}}
\thispagestyle{empty}
\newpage % This one doesn't create any trouble
%%%% Meta info
\begin{table}[!ht]
\begin{tabular}{lll}
\vspace{5mm}
\textbf{University} & & {University of Copenhagen} \\
\vspace{5mm}
\textbf{Name of Department} & & {Department of Political Science} \\
\vspace{5mm}
\textbf{Study Programme} & & {Master of Science (MSc) in Political Science} \\
\vspace{5mm}
\textbf{Author} & & {My name} \\
\vspace{5mm}
\textbf{Student ID} & & {My student ID} \\
\vspace{5mm}
\textbf{Academic Supervisor} & & {Supervisor name} \\
\textbf{Title} & & {Title of thesis} \\
% \vspace{5mm}
%\textbf{Subtitle} & & {Subtitle} \\
%\vspace{5mm}
\\
\textbf{Date of Submission} & & {March 20, 2021} \\
% \vspace{5mm}
\\
\textbf{ECTS} & & {30} \\
\end{tabular}
\end{table}
\newpage % This line creates the problem
更新了图形问题的代码和图片(基于对 samcarter_is_at_topanswers 的回答):
%%%% Packages
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage{footnote}
\usepackage{csquotes}
\usepackage[style=apa, citestyle=apa, sorting=nyt ]{biblatex}
\addbibresource{Biblo.bib}
\usepackage{eso-pic}
\usepackage{graphicx}
\usepackage[a4paper, hmargin={2.5cm, 3cm}, vmargin={3cm, 3cm}]{geometry}
\usepackage{fancyhdr}
\graphicspath{ {figures/} }
\usepackage{array}
\usepackage[titletoc]{appendix}
\usepackage{tcolorbox}
\usepackage{tabularx}
\usepackage{multirow}
\usepackage{marginnote}
\usepackage{threeparttable}
\usepackage[font=small,format=plain,labelfont=bf,textfont=normal,justification=justified,singlelinecheck=false]{caption}
\usepackage{amsmath}
\usepackage{setspace}
\usepackage{parskip}
\usepackage{float}
\pagestyle{fancy}
\usepackage{etoolbox}\apptocmd\appendix{\pretocmd\section{\clearpage}{}{}}{}{}
\usepackage{subfiles}
% Extra packages
\usepackage[T1]{fontenc}
\usepackage{bmpsize}
\usepackage{topcapt}
\usepackage{booktabs}
\usepackage{wrapfig}
% commands
\setstretch{1.25}
\newcommand{\margmod}[1]{\marginnote{\setstretch{.5}\parbox[t]{\marginparwidth}{\raggedright\emph{#1}}}}
% Front page
\def \ColourPDF {Images/Metaimages/Front page_Political Science.pdf}
\def \TitlePDF {Images/Metaimages/Front page_Political Science.pdf}
\author{
\LARGE{My name} \\
\vspace{0cm} \\
{Academic Supervisor: Supervisor name} \\
\vspace{.5cm} \\
}
\title{
\vspace{3mm}
\Huge{Master's Thesis}\\
\vspace{18mm}
\LARGE{Name of thesis}
\vspace{90mm}
}
\date{February 2022}
%%%% Layout style
\linespread{1.5}
\fancyhead[L]{}
\fancyhead[R]{\slshape \rightmark}
\setlength{\parskip}{1em}
%%%% Frontpage layout
\begin{document}
\pagenumbering{roman}
\AddToShipoutPicture*{\put(0,602){\includegraphics*[viewport=0 600 700 1600]{example-image}}} % adds frontpage image
\AddToShipoutPicture*{\put(0,0){\includegraphics*{example-image}}}
\thispagestyle{empty}
\newpage
%%%% Meta info
\begin{table}[!ht]
\begin{tabular}{lll}
\vspace{5mm}
\textbf{University} & & {University of Copenhagen} \\
\vspace{5mm}
\textbf{Name of Department} & & {Department of Political Science} \\
\vspace{5mm}
\textbf{Study Programme} & & {Master of Science (MSc) in Political Science} \\
\vspace{5mm}
\textbf{Author} & & {My name} \\
\vspace{5mm}
\textbf{Student ID} & & {My student ID} \\
\vspace{5mm}
\textbf{Academic Supervisor} & & {Supervisor name} \\
\textbf{Title} & & {Title of thesis} \\
% \vspace{5mm}
%\textbf{Subtitle} & & {Subtitle} \\
%\vspace{5mm}
\\
\textbf{Date of Submission} & & {March 20, 2021} \\
% \vspace{5mm}
\\
\textbf{ECTS} & & {30} \\
\end{tabular}
\end{table}
\newpage
Start of thesis..
\end{document}
答案1
您的代码中未定义这两个命令\ColourPDF
和。请定义它们或将它们替换为您想要包含的图像的名称。\TitlePDF
最好不要在 中指定驱动程序\usepackage[dvipdfm]{graphicx}
。如果你不指定,latex 将自动选择与你用于编译文档的引擎匹配的驱动程序。
\documentclass[oneside]{article}
%%%% packages
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage{footnote}
\usepackage{csquotes}
\usepackage{eso-pic}
\usepackage{graphicx}
\usepackage{bmpsize}
\usepackage[a4paper, hmargin={2.5cm, 3cm}, vmargin={3cm, 3cm}]{geometry}
\usepackage{fancyhdr}
\graphicspath{ {figures/} }
\usepackage{array}
\usepackage[titletoc]{appendix}
\usepackage{tcolorbox}
\usepackage{tabularx}
\usepackage{multirow}
\usepackage{topcapt}
\usepackage{marginnote}
\usepackage{threeparttable}
\usepackage[font=small,format=plain,labelfont=bf,textfont=normal,justification=justified,singlelinecheck=false]{caption}
\usepackage{booktabs}
\usepackage{amsmath}
\usepackage{setspace}
\usepackage{parskip}
\usepackage{float}
\usepackage{wrapfig}
\usepackage[style=apa, citestyle=apa, sorting=nyt ]{biblatex}
\addbibresource{Biblo.bib}
\pagestyle{fancy}
\usepackage{etoolbox}\apptocmd\appendix{\pretocmd\section{\clearpage}{}{}}{}{}
\usepackage{subfiles}
% commands
\setstretch{1.25}
\newcommand{\margmod}[1]{\marginnote{\setstretch{.5}\parbox[t]{\marginparwidth}{\raggedright\emph{#1}}}}
\author{
\LARGE{My name} \\
\vspace{0cm} \\
{Academic Supervisor: Supervisor name} \\
\vspace{.5cm} \\
}
\title{
\vspace{3mm}
\Huge{Master's Thesis}\\
\vspace{18mm}
\LARGE{Name of thesis}
\vspace{90mm}
}
\date{February 2022}
%%%% Layout style
\linespread{1.5}
\fancyhead[L]{}
\fancyhead[R]{\slshape \rightmark}
\setlength{\parskip}{1em}
\usepackage{tikz}
\usetikzlibrary{calc,matrix}
\usepackage{lipsum}
\newcommand{\Maroonunderline}[1]{{\color{Maroon}\underline{{\color{black}#1}}}}
\definecolor{Maroon_1}{RGB}{144,26,30}
%%%% Frontpage layout
\begin{document}
\pagenumbering{roman}
\AddToShipoutPicture*{\put(0,602){\includegraphics*[viewport=0 600 700 1600]{example-image}}} % adds frontpage image
\AddToShipoutPicture*{\put(0,0){\includegraphics*{example-image}}}
\thispagestyle{empty}
\newpage % This one doesn't create any trouble
%%%% Meta info
\begin{table}[!ht]
\begin{tabular}{lll}
\vspace{5mm}
\textbf{University} & & {University of Copenhagen} \\
\vspace{5mm}
\textbf{Name of Department} & & {Department of Political Science} \\
\vspace{5mm}
\textbf{Study Programme} & & {Master of Science (MSc) in Political Science} \\
\vspace{5mm}
\textbf{Author} & & {My name} \\
\vspace{5mm}
\textbf{Student ID} & & {My student ID} \\
\vspace{5mm}
\textbf{Academic Supervisor} & & {Supervisor name} \\
\textbf{Title} & & {Title of thesis} \\
% \vspace{5mm}
%\textbf{Subtitle} & & {Subtitle} \\
%\vspace{5mm}
\\
\textbf{Date of Submission} & & {March 20, 2021} \\
% \vspace{5mm}
\\
\textbf{ECTS} & & {30} \\
\end{tabular}
\end{table}
\newpage % This line creates the problem
test
\end{document}