![如何在 LaTeX 中建立序言?](https://rvso.com/image/391705/%E5%A6%82%E4%BD%95%E5%9C%A8%20LaTeX%20%E4%B8%AD%E5%BB%BA%E7%AB%8B%E5%BA%8F%E8%A8%80%EF%BC%9F.png)
我想知道如何在目錄前插入序言。頁面將以羅馬字體枚舉,但不會放入實際的目錄中。我的程式碼的初始部分是:
\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}