如何在目錄中加入奉獻章節?

如何在目錄中加入奉獻章節?

請問如何在本奉獻中加入章節名稱並將其加入目錄中?

\newenvironment{dedication}
  {\clearpage           % we want a new page
   \thispagestyle{empty}% no header and footer
   \vspace*{\stretch{1}}% some space at the top 
   \slshape             % the text is in italics
   \raggedleft          % flush to the right margin
  }
  {\par % end the paragraph
   \vspace{\stretch{3}} % space at bottom is three times that at the top
   \clearpage           % finish off the page
  }
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{dedication}
ABC \\ DEF
\end{dedication}

我正在使用報告類。多謝!

答案1

您可以使用

\chapter*{Dedication}
 \addcontentsline{toc}{chapter}{Dedication}

完整程式碼:

\documentclass{report}
\usepackage{lmodern}
\usepackage[T1]{fontenc}
\newenvironment{dedication}
  {%\clearpage           % we want a new page             %%%<===== Comment this line
   \thispagestyle{empty}% no header and footer
   \vspace*{\stretch{1}}% some space at the top
   \itshape             % the text is in italics
   \raggedleft          % flush to the right margin
  }
  {\par % end the paragraph
   \vspace{\stretch{3}} % space at bottom is three times that at the top
   \clearpage           % finish off the page
  }
\begin{document}
 \pagenumbering{roman}
 \tableofcontents 
 \chapter*{Dedication}
 \addcontentsline{toc}{chapter}{Dedication}
  \begin{dedication}
    ABC 
    \par   %% or a blank line
    \vspace{2\baselineskip}
    DEF

    \vspace{\baselineskip}
    \usefont{T1}{LobsterTwo-LF}{bx}{it}
    John
  \end{dedication}
  \pagenumbering{arabic}
\end{document}

在此輸入影像描述

在此輸入影像描述

相關內容