¿Cómo creo un prefacio en LaTeX?

¿Cómo creo un prefacio en LaTeX?

Me pregunto cómo podría insertar un prefacio antes del índice. La página se enumeraría en romanos pero no se incluiría en la tabla de contenido real. La parte inicial de mi código es:

\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

Respuesta1

En mi opinión, crear un nuevo entorno es excesivo. Simplemente agregue \chapter*{Preface}o \section*{Preface}antes \tableofcontents. Al agregar *capítulos y secciones, la tabla de contenido los ignora.

Respuesta2

ingrese la descripción de la imagen aquí

Utilice este código para definir un entorno de prefacio

% ===== 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}}}

código completo

\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}

información relacionada