从目录中删除附录章节。目录中仅保留附录

从目录中删除附录章节。目录中仅保留附录
\documentclass[12pt,a4paper]{report}
\usepackage{titlesec}
\usepackage[toc]{appendix}
\titleformat{\chapter}[display] {\normalfont\Huge\bfseries}{\chaptertitlename\ \thechapter}{0pt}{\Huge}

\usepackage[english]{babel}
\usepackage{pdfpages}
\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{subfig}
\usepackage{float}
\usepackage{booktabs}
\linespread{1.5}   
\usepackage[a4paper,top=3cm,bottom=2cm,left=3cm,right=3cm,marginparwidth=1.75cm]{geometry}

\usepackage{amsmath}
\usepackage{graphicx}
\usepackage[colorinlistoftodos]{todonotes}
\usepackage{xcolor}
\usepackage{tocbibind}
\usepackage{xpatch}
\usepackage{hyperref}
\hypersetup{
  colorlinks=false,
  urlbordercolor=red
}
\makeatletter

\xpatchcmd{\titlepage}{\thispagestyle{empty}}{\pagestyle{plain}}{}{}% \xpatchcmd{\endtitlepage}{\setcounter{page}\@ne}{\cleardoublepage}{}{}% Remove the reset of page at the end of titlepage

\newcommand\frontmatter{%
  \cleardoublepage
  % \@mainmatterfalse
  \pagenumbering{roman}
}

\newcommand\mainmatter{%
    \cleardoublepage
    % \@mainmattertrue
    \pagenumbering{arabic}
  }

\newcommand\backmatter{%
  \if@openright
    \cleardoublepage
  \else
    \clearpage
  \fi
  % \@mainmatterfalse
}

\makeatother

\title{Your Paper}
\author{You}

\begin{document}

%\includepdf{Cover_Page}


\frontmatter
\begin{abstract}
\addcontentsline{toc}{chapter}{Abstract}    
\end{abstract}

\begingroup
  \hypersetup{hidelinks}
  \tableofcontents
\endgroup

\mainmatter
\chapter{Introduction}

\appendix
\chapter{MSE Reconstruction}
\chapter{Latent Encodings}
\end{document}

enter image description here

答案1

虽然不好看,但确实有用。注意:我使用了\addappheadtotoc而不是\appendixpage来保存一页文本。

\documentclass[12pt,a4paper]{report}
\usepackage{titlesec}
\usepackage[toc]{appendix}
\titleformat{\chapter}[display] {\normalfont\Huge\bfseries}{\chaptertitlename\ \thechapter}{0pt}{\Huge}

\usepackage[english]{babel}
\usepackage{pdfpages}
\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{subfig}
\usepackage{float}
\usepackage{booktabs}
\linespread{1.5}   
\usepackage[a4paper,top=3cm,bottom=2cm,left=3cm,right=3cm,marginparwidth=1.75cm]{geometry}

\usepackage{amsmath}
\usepackage{graphicx}
\usepackage[colorinlistoftodos]{todonotes}
\usepackage{xcolor}
\usepackage{tocbibind}
\usepackage{xpatch}
\usepackage{hyperref}
\hypersetup{
  colorlinks=false,
  urlbordercolor=red
}
\makeatletter

\xpatchcmd{\titlepage}{\thispagestyle{empty}}{\pagestyle{plain}}{}{}% \xpatchcmd{\endtitlepage}{\setcounter{page}\@ne}{\cleardoublepage}{}{}% Remove the reset of page at the end of titlepage

\newcommand\frontmatter{%
  \cleardoublepage
  % \@mainmatterfalse
  \pagenumbering{roman}
}

\newcommand\mainmatter{%
    \cleardoublepage
    % \@mainmattertrue
    \pagenumbering{arabic}
  }

\newcommand\backmatter{%
  \if@openright
    \cleardoublepage
  \else
    \clearpage
  \fi
  % \@mainmatterfalse
}

\makeatother

\title{Your Paper}
\author{You}

\begin{document}

%\includepdf{Cover_Page}


\frontmatter
\begin{abstract}
\addcontentsline{toc}{chapter}{Abstract}    
\end{abstract}

\begingroup
  \hypersetup{hidelinks}
  \tableofcontents
\endgroup

\mainmatter
\chapter{Introduction}

\appendix
\clearpage\addappheadtotoc% or \appendixpage
\refstepcounter{chapter}%
\chapter*{\appendixname~\thechapter\newline MSE Reconstruction}
\refstepcounter{chapter}%
\chapter*{\appendixname~\thechapter\newline Latent Encodings}
\end{document}

demo

相关内容