重新定义 \maketitle 后 LaTeX 无法编译

重新定义 \maketitle 后 LaTeX 无法编译

这是我的主要文件:

\documentclass{report}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[francais]{babel}

\include{definitions/pagetitre}

\title{Text}

\author{Text}

\sujet{Text}

\motsclefs{Text}

\datedebut{September 26th}
\datefin{December 3, 2005}

\superviseurs{Name1 \textsc{Blabla} (ACRONYM)}

\proverbe{A leader is someone who steps back from the entire system and tries to build a more collaborative, more innovative system that will work over the long term.}
\auteurproverbe{Robert Reich, United States Secretary of Labor (1993--1997)}

\begin{document}

\maketitle

\paragraph{Lorem ipsum}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur vestibulum risus nec dapibus aliquam. Phasellus ultricies egestas erat sed mollis. Etiam euismod tortor ut ante rutrum consequat. Nunc id sem convallis, iaculis diam quis, facilisis nulla. Aliquam leo lorem, ultricies.

\end{document}

这是 definitions/pagetitre.tex:

%%%%%%%% Feuilles de style page de titre %%%%%%%%%%

\makeatletter
\def\maketitle{%
    \thispagestyle{empty}%\vbox to \vsize{%
    \LARGE
        \begin{flushright}%
            \@sujet\\  
            \hrulefill
        \end{flushright}%
    \vfill
    \begin{center}%
        \textbf{\huge \@title}\\
        \vspace{1cm}%
        \Large{ \@author}%
    \end{center}%
\par
\vfill

\large
    \begin{tabularx}{\textwidth}{lX}%
        \textbf{Keywords} & \@motsclefs\\[0.2cm]
        \textbf{Dates} & \@datedebut  --- \@datefin\\[0.2cm]
        \textbf{Supervisors} & \@superviseurs
    \end{tabularx}%
  %  }%
  \clearpage
\vfill
\Large
\emph{\og\@proverbe\fg}
\begin{flushright}
    \@auteurproverbe
\end{flushright}
\vfill
\normalsize
%\clearpage
  }

\def\date#1{\def\@date{#1}}
\def\author#1{\def\@author{#1}}
\def\title#1{\def\@title{#1}}
\def\departement#1{\def\@departement{#1}}
\def\filiere#1{\def\@filiere{#1}}
\def\motsclefs#1{\def\@motsclefs{#1}}
\def\datedebut#1{\def\@datedebut{#1}}
\def\datefin#1{\def\@datefin{#1}}
\def\sujet#1{\def\@sujet{#1}}
\def\proverbe#1{\def\@proverbe{#1}}
\def\auteurproverbe#1{\def\@auteurproverbe{#1}}
\def\superviseurs#1{\def\@superviseurs{#1}}



% Valeurs par défaut
\proverbe{}
\auteurproverbe{}
\sujet{}
\departement{}
\filiere{}
\motsclefs{}
\datedebut{\today}
\datefin{\today}
\superviseurs{\@author} 

有人知道为什么它不能编译吗?错误是 LaTeX 不知道命令 \maketitle...

当我删除命令 \maketitle 时,它​​可以起作用,但是自定义标题根本没有出现。

答案1

由于错误消息指出tabularx未定义,因此您需要加载tabularx。此外,您的页面标题文件中有一些重音符号 A,看起来像是 utf8 无分隔符的错误编码。我删除了它们,并在\noindent之前添加了tabularx,以便您可以获得全宽表格(否则行会超出 15pt = 段落缩进)。也\input不要使用\include

\documentclass{report}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[francais]{babel}
\usepackage{tabularx}
\input{pagetitre}

\title{Text}

\author{Text}

\sujet{Text}

\motsclefs{Text}

\datedebut{September 26th}
\datefin{December 3, 2005}

\superviseurs{Name1 \textsc{Blabla} (ACRONYM)}

\proverbe{A leader is someone who steps back from the entire system and tries to build a more collaborative, more innovative system that will work over the long term.}
\auteurproverbe{Robert Reich, United States Secretary of Labor (1993--1997)}

\begin{document}

\maketitle

\paragraph{Lorem ipsum}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur vestibulum risus nec dapibus aliquam. Phasellus ultricies egestas erat sed mollis. Etiam euismod tortor ut ante rutrum consequat. Nunc id sem convallis, iaculis diam quis, facilisis nulla. Aliquam leo lorem, ultricies.

\end{document}

%%%%%%%% Feuilles de style page de titre %%%%%%%%%%

\makeatletter
\def\maketitle{%
    \thispagestyle{empty}%\vbox to \vsize{%
    \LARGE
        \begin{flushright}%
            \@sujet\\
            \hrulefill
        \end{flushright}%
    \vfill
    \begin{center}%
        \textbf{\huge \@title}\\
        \vspace{1cm}%
        \Large{ \@author}%
    \end{center}%
\par
\vfill

\large
    \noindent\begin{tabularx}{\textwidth}{lX}%
        \textbf{Keywords} & \@motsclefs\\[0.2cm]
        \textbf{Dates} & \@datedebut  --- \@datefin\\[0.2cm]
        \textbf{Supervisors} & \@superviseurs
    \end{tabularx}%
%}%
\clearpage
\vfill
\Large
\emph{\og\@proverbe\fg}
\begin{flushright}
    \@auteurproverbe
\end{flushright}
\vfill
\normalsize
%\clearpage
}

\def\date#1{\def\@date{#1}}
\def\author#1{\def\@author{#1}}
\def\title#1{\def\@title{#1}}
\def\departement#1{\def\@departement{#1}}
\def\filiere#1{\def\@filiere{#1}}
\def\motsclefs#1{\def\@motsclefs{#1}}
\def\datedebut#1{\def\@datedebut{#1}}
\def\datefin#1{\def\@datefin{#1}}
\def\sujet#1{\def\@sujet{#1}}
\def\proverbe#1{\def\@proverbe{#1}}
\def\auteurproverbe#1{\def\@auteurproverbe{#1}}
\def\superviseurs#1{\def\@superviseurs{#1}}



% Valeurs par défaut
\proverbe{}
\auteurproverbe{}
\sujet{}
\departement{}
\filiere{}
\motsclefs{}
\datedebut{\today}
\datefin{\today}
\superviseurs{\@author} 

相关内容