如何在 LaTeX 中创建序言?

如何在 LaTeX 中创建序言?

我想知道如何在目录前插入序言。页面将以罗马数字形式列出,但不会放入实际的目录中。我的代码的初始部分是:

\documentclass[12pt, a4paper]{article}
\usepackage{a4wide}
\documentclass[12pt, openright ]{book}
\usepackage{array}
\newcolumntype{C}{>{\centering\arraybackslash}X}
\renewcommand{\arraystretch}{1.2}
\usepackage{booktabs}
\usepackage{tabularx}
\usepackage{caption}
\usepackage{array}
\usepackage{float}
\usepackage[utf8]{inputenc}
\usepackage{natbib}
\usepackage{graphicx}
\begin{document}
\

begin{titlepage}
    \pagenumbering{Roman} 

Title


    \end{titlepage}

    \shipout\null

\tableofcontents
\listoffigures
\listoftables

答案1

我认为创建新环境有点过头了。只需在前添加\chapter*{Preface}或即可。如果添加到章节和部分,则目录会忽略它们。\section*{Preface}\tableofcontents*

答案2

在此处输入图片描述

使用此代码定义序言环境

% ===== Define a preface environment =====
\newcommand{\prefacename}{Preface}
\newenvironment{preface}{
    \vspace*{\stretch{2}}
    {\noindent \bfseries \Huge \prefacename}
    \begin{center}
        % \phantomsection \addcontentsline{toc}{chapter}{\prefacename} % enable this if you want to put the preface in the table of contents
        \thispagestyle{plain}
    \end{center}%
}
{\vspace*{\stretch{5}}}

完整代码

\documentclass[12pt, openright]{book}
\usepackage{a4wide}
\usepackage{array}
\newcolumntype{C}{>{\centering\arraybackslash}X}
\renewcommand{\arraystretch}{1.2}
\usepackage{booktabs}
\usepackage{tabularx}
\usepackage{caption}
\usepackage{array}
\usepackage{float}
\usepackage{natbib}
\usepackage{graphicx}
\usepackage{blindtext}



\usepackage{tocloft}


    % ===== Define abstract environment =====
    \newcommand{\prefacename}{Preface}
    \newenvironment{preface}{
        \vspace*{\stretch{2}}
        {\noindent \bfseries \Huge \prefacename}
        \begin{center}
            % \phantomsection \addcontentsline{toc}{chapter}{\prefacename} % enable this if you want to put the preface in the table of contents
            \thispagestyle{plain}
        \end{center}%
    }
    {\vspace*{\stretch{5}}}

\begin{document}

\pagestyle{empty}

\begin{titlepage}

Title

\end{titlepage}

\shipout\null

\frontmatter
\pagenumbering{Roman} 

\begin{preface}
    \blindtext
\end{preface}

\clearpage

\tableofcontents

\clearpage
\listoffigures

\clearpage
\listoftables



\mainmatter

\Blinddocument

\end{document}

相关内容