latex 报告类 \frontmatter \mainmatter 和页码

latex 报告类 \frontmatter \mainmatter 和页码

我正在使用该类report。我希望我的摘要、致谢和目录位于目录中,并且其页码为罗马数字。然后我希望其后的其余部分为数字。我使用下面的代码,但我的摘要上没有页码。它只显示在目录中。我不知道如何使用书籍类,因为如果我将函数从更改为,reportbook会得到一个很大的错误。以下是代码和图片。

\documentclass[pdftex,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{hyperref}
\hypersetup{
  colorlinks=false,
  urlbordercolor=red
}

\makeatletter

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

enter image description here

enter image description here

当我使用下面的代码时出现此错误

(no line number):
This is BibTeX, Version 0.99d (TeX Live 2016/Debian)
Capacity: max_strings=100000, hash_size=100000, hash_prime=85009
The top-level auxiliary file: main.aux
The style file: IEEEtran.bst
Reallocated singl_function (elt_size=4) to 100 items from 50.
Reallocated singl_function (elt_size=4) to 100 items from 50.
Reallocated singl_function (elt_size=4) to 100 items from 50.
Reallocated wiz_functions (elt_size=4) to 6000 items from 3000.
Reallocated singl_function (elt_size=4) to 100 items from 50.
Database file #1: sample.bib
Repeated entry---line 88 of file sample.bib
 : @article{videoanalysis
 :                       ,
I'm skipping whatever remains of this entry
Repeated entry---line 163 of file sample.bib
 : @article{vrnn
 :              ,
I'm skipping whatever remains of this entry
-- IEEEtran.bst version 1.14 (2015/08/26) by Michael Shell.
-- http://www.michaelshell.org/tex/ieeetran/bibtex/
-- See the "IEEEtran_bst_HOWTO.pdf" manual for usage information.
Name 6 in "Jeff Donahue and Lisa Anne Hendricks and Marcus Rohrbach and Subhashini Venugopalan and Sergio Guadarrama and Kate Saenko, and Trevor Darrell" has a comma at the end for entry videoanalysis
while executing---line 2403 of file IEEEtran.bst
Name 2 in "Ilya Sutskever and Oriol Vinyals, and Quoc V. Le" has a comma at the end for entry machinetranslation
while executing---line 2403 of file IEEEtran.bst
Name 3 in "Oriol Vinyals and Alexander Toshev and Samy Bengio, and Dumitru Erhan" has a comma at the end for entry imagecaptioning1
while executing---line 2403 of file IEEEtran.bst
Name 3 in "Marco Fraccaroy and Soren Kaae Sonderbyz and Ulrich Paquet, and Ole Winther" has a comma at the end for entry srnn
while executing---line 2403 of file IEEEtran.bst
Name 3 in "Diederik P. Kingma and Danilo J. Rezende and Shakir Mohamed, and Max Welling" has a comma at the end for entry cvae1
while executing---line 2403 of file IEEEtran.bst
Name 1 in "Kihyuk Sohn, Honglak Lee, and Xinchen Yan" has a comma at the end for entry cvae2
while executing---line 2403 of file IEEEtran.bst
Name 2 in "Nitish Srivastava and Elman Mansimov, and Ruslan Salakhutdinov" has a comma at the end for entry unsupvideo
while executing---line 2403 of file IEEEtran.bst
Name 3 in "Serena Yeung and Anitha Kannan and Yann Dauphin, and Li Fei-Fei" has a comma at the end for entry overpruning
while executing---line 2403 of file IEEEtran.bst
Name 4 in "Casper Kaae Sonderby and Tapani Raiko and Lars Maaloe and Soren Kaae Sonderby, and Ole Winther" has a comma at the end for entry trainvae
while executing---line 2403 of file IEEEtran.bst
Name 4 in "Anirudh Goyal and Alessandro Sordoni and Marc-Alexandre Cote and Nan Rosemary Ke, and Yoshua Bengio" has a comma at the end for entry zforcing
while executing---line 2403 of file IEEEtran.bst
Name 5 in "Xingjian Shi and Zhourong Chen and Hao Wang and Dit-Yan Yeung and Wai-kin Wong, and Wang-chun Woo" has a comma at the end for entry convlstm
while executing---line 2403 of file IEEEtran.bst

Done.
You've used 23 entries,
            4087 wiz_defined-function locations,
            914 strings with 10786 characters,
and the built_in function-call counts, 10057 in all, are:
= -- 758
> -- 312
< -- 0
+ -- 146
- -- 73
* -- 447
:= -- 1769
add.period$ -- 46
call.type$ -- 23
change.case$ -- 23
chr.to.int$ -- 0
cite$ -- 23
duplicate$ -- 881
empty$ -- 906
format.name$ -- 94
if$ -- 2235
int.to.chr$ -- 0
int.to.str$ -- 23
missing$ -- 165
newline$ -- 92
num.names$ -- 23
pop$ -- 469
preamble$ -- 1
purify$ -- 0
quote$ -- 2
skip$ -- 752
stack$ -- 0
substring$ -- 23
swap$ -- 489
text.length$ -- 0
text.prefix$ -- 0
top$ -- 5
type$ -- 23
warning$ -- 0
while$ -- 23
width$ -- 25
write$ -- 206
(There were 13 error messages)

答案1

默认情况下report使用titlepage选项或更好的选项\@titlepagetrue(从一开始就设置,因此titlepage选项没有明确设置) - 这对abstract(代码来自report.cls

  \newenvironment{abstract}{%
      \titlepage
      \null\vfil
      \@beginparpenalty\@lowpenalty
      \begin{center}%
        \bfseries \abstractname
        \@endparpenalty\@M
      \end{center}}%
     {\par\vfil\null\endtitlepage}

现在,\titlepage本身使用\thispagestyle{empty},所以不会显示页码。

补丁

\xpatchcmd{\titlepage}{\thispagestyle{empty}}{\pagestyle{plain}}{}{}%

解决了这个问题。

请注意book.cls没有抽象环境。

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

\end{document}

相关内容