
對於我的所有文檔,我建立了一個 template.tex 文件,該文件會匯入到我的所有文件中。但它說我遇到了這些問題:
/home/rperrod/rp/PERSO/LaTeX/Test/template/t.tex:20: Undefined control sequence. [ \setlength{\footheight}{10mm}]
/home/rperrod/rp/PERSO/LaTeX/Test/template/t.tex:20: LaTeX Error: Missing \begin{document}. [ \setlength{\footheight}{10mm}]
/home/rperrod/rp/PERSO/LaTeX/Test/template/t.tex:25: Undefined control sequence. [ \allowdisplaybreaks]
這是我的測試文件:
\documentclass[a4paper, 12pt]{article}
\usepackage[english, french]{babel}
\usepackage{fancyhdr}
\usepackage{geometry}
\usepackage{varwidth}
%----------- My template file ---------
\geometry{
a4paper,
left=16mm,
top=16mm,
bottom=16mm,
right=16mm
}
\pagestyle{fancy}
\fancyhf{}
\setlength{\headheight}{10mm}
\lhead{\textsc{Some Text}}
\rhead{\textsc{SOME} Text}
\setlength{\footheight}{10mm}
\rfoot{\thepage}
\date{}
\author{}
\allowdisplaybreaks
%-----------------------------------
\title{I'm a giraffe}
\begin{document}
\maketitle\thispagestyle{fancy}
Lorem ipsum
\section{Colorado}
\newpage
\newpage
\section{Says}
\newpage
\section{Giraaaaaaaaaaaaaaaffe}
\end{document}
問題出在哪裡?我剛剛從我的朋友那裡複製了這個,對他來說,它有效。我是否忘了某個包裹?
答案1
最好在幾何定義中包含headheight
和footskip
(而不是),而不是單獨包含。footheight
\setlength
\documentclass[a4paper, 12pt]{文章}
\usepackage[english, french]{babel}
\usepackage{fancyhdr}
\usepackage{geometry}
\usepackage{varwidth}
\usepackage{amsmath}
%----------- My template file ---------
\geometry{
a4paper,
left=16mm,
top=16mm,
bottom=16mm,
right=16mm,
headheight=10mm,
footskip=10mm,
}
\pagestyle{fancy}
\fancyhf{}
\lhead{\textsc{Some Text}}
\rhead{\textsc{SOME} Text}
\rfoot{\thepage}
\date{}
\author{}
\allowdisplaybreaks
%-----------------------------------
\title{I'm a giraffe}
\begin{document}
\maketitle\thispagestyle{fancy}
Lorem ipsum
\section{Colorado}
\newpage
\newpage
\section{Says}
\newpage
\section{Giraaaaaaaaaaaaaaaffe}
\end{document}
答案2
您顯示的錯誤訊息的格式具有誤導性,因為它掩蓋了哪個命令未定義。
第一個錯誤是
! Undefined control sequence.
<argument> \footheight
l.23 \setlength{\footheight}{10mm}
?
如果你註解掉第 23 行,然後重新運行,那麼你會得到
! Undefined control sequence.
l.28 \allowdisplaybreaks
amsmath
這是尚未加載的命令,因此添加
\usepackage{amsmath}
你還得到
Package french.ldf Warning: OT1 encoding should not be used for French.
(french.ldf) Add \usepackage[T1]{fontenc} to the preamble
(french.ldf) of your document; reported on input line 35.
因此,將所有這些放在一起,不會出現以下警告或錯誤:
\documentclass[a4paper, 12pt]{article}
\usepackage[T1]{fontenc}
\usepackage[english, french]{babel}
\usepackage{fancyhdr}
\usepackage{geometry}
\usepackage{varwidth}
\usepackage{amsmath}
%----------- My template file ---------
\geometry{
a4paper,
left=16mm,
top=16mm,
bottom=16mm,
right=16mm
}
\pagestyle{fancy}
\fancyhf{}
\setlength{\headheight}{10mm}
\lhead{\textsc{Some Text}}
\rhead{\textsc{SOME} Text}
% \setlength{\footheight}{10mm}
\rfoot{\thepage}
\date{}
\author{}
\allowdisplaybreaks
%-----------------------------------
\title{I'm a giraffe}
\begin{document}
\maketitle\thispagestyle{fancy}
Lorem ipsum
\section{Colorado}
\newpage
\newpage
\section{Says}
\newpage
\section{Giraaaaaaaaaaaaaaaffe}
\end{document}