내 템플릿 관련 문제

내 템플릿 관련 문제

내 모든 문서에 대해 모든 파일로 가져오는 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

와 별도로 사용하는 것보다 형상 정의에 headheightfootskip( 아님 )을 포함하는 것이 좋습니다 .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}

관련 정보