我需要打印不包含正文的文档,但目录必须包含所有章节和部分的标题,并且附录必须包含没有正文页码的正确页码页码。
你有什么秘诀可以做到这一点吗?
\documentclass[11pt,a4paper,DIV=12,oneside]{scrbook}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{scrlayer-scrpage}
\usepackage[french]{babel}
\usepackage{hyperref}
\usepackage{bookmark}
%name of toc \addto\captionsfrench{\renewcommand*\contentsname{Plan}}
\begin{document}
\frontmatter
\input{tex/titlepage}
\input{tex/introduction}
\setcounter{tocdepth}{1} \tableofcontents
\mainmatter
\input{tex/chapter1}
\input{tex/chapter2} %etc.
\appendix
\input{tex/appendix1}
\input{tex/appendix2}
\backmatter
\chapter{Bibliography}
\end{document}
答案1
我不明白“好数字页面”是什么意思。也许你正在寻找类似
\documentclass[11pt,a4paper,DIV=12,oneside]{scrbook}[2017/04/13]% needs at least version 3.23
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[automark]{scrlayer-scrpage}
\usepackage[french]{babel}
\usepackage{bookmark}% loads hyperref too
\usepackage{xpatch}
\usepackage{blindtext}% only for dummy text
\setcounter{tocdepth}{1}
\newif\ifsetmtoc
%\setmtoctrue% uncomment for one run to renew the mtoc file
\newif\ifusemtoc
\usemtoctrue
\newcommand*\printmtoc{}
\xapptocmd\mainmatter
{%
\addtocontents{toc}{\protect\begingroup\protect\printmtoc}%
\ifusemtoc
\begingroup\renewcommand*{\blinddocument}{}% redefine \blinddocument to avoid the output
\fi
}{}{\mainmatterPatchFailed}
\xpretocmd\appendix
{%
\ifusemtoc\endgroup\fi
\addtocontents{toc}{\protect\endgroup}%
}{}{\appendixPatchFailed}
\makeatletter
\ifusemtoc
\IfFileExists{\jobname.mtoc}
{%
\renewcommand*\printmtoc{%
\RedeclareSectionCommands[
tocpagenumberformat=\@gobble,
toclinefill=\hfill
]{chapter,section}%
\hypersetup{linktoc=none}%
\input{\jobname.mtoc}
}
}{\setmtoctrue}%
\fi
\ifsetmtoc
\DeclareNewTOC[
owner=\jobname
]{mtoc}
\AtBeginDocument{\listoftoc{mtoc}}%
\xapptocmd\mainmatter
{\renewcommand*\ext@toc{mtoc}}
{}{\mainmatterPatchFailed}%
\xapptocmd\appendix
{\renewcommand*\ext@toc{toc}}
{}{\appendixPatchFailed}%
\usemtocfalse
\fi
\makeatother
\begin{document}
\frontmatter
Titelpage
\clearpage
\chapter{Introduction}
\Blindtext[3]
\tableofcontents
\mainmatter
\blinddocument
\blinddocument
\blinddocument
\appendix
\blinddocument
\blinddocument
\end{document}
mtoc
如果主要内容有任何更改,则必须删除扩展名的文件或运行一个文件\setmtoctrue
来更新文件的内容mtoc
。
如果您发表评论,则\usemtoctrue
主要内容将照常打印。
请注意,我改用了MWE 中的宏。因此,我已针对主要事项重新定义,\blinddocument
而您必须重新定义。\input
\blinddocument
\input