编辑

编辑

我喜欢在几乎所有页面的标题内上部显示章节名称,但不要在以新章节开头的页面、目录和索引中显示章节名称。

除标题页、空白页、目录外,每一页都应在最外层位置标明页码。

因此我花了很多时间才找到最佳解决方案。在我的文档中,我遇到了这些与页码有关的问题:

  • 我不喜欢目录中“Anhang”条目旁边的页码
  • 当我点击“Anhang”和“Stichwortverzeichnis”时,它会正确打开特定页面。但是当我点击“Glossar”时,我被重定向到错误的页面。

  • 我不喜欢在“Inhaltsverzeichnis”、“Einleitung”、“Anhang”、“Glossar”、“Stichwortverzeichnis”页面标题上使用章节引用“Inhaltsverzeichnis”和“Einleitung”,因为它已经在这些页面中写过一次了。

  • 最后两页缺少页码。

我在 Windows 8 下使用 LyX 和 Texmaker 的组合,但最终可能想改用 Texmaker。

我使用并缩短的代码:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
% LyX 2.1.0 created this file.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 

\documentclass[twoside,ngerman,fontsize=10pt]{scrreprt}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage[a4paper]{geometry}
\geometry{verbose,tmargin=2.5cm,bmargin=2.5cm,lmargin=2.5cm,rmargin=2.5cm}
\pagestyle{empty}
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}
\setlength{\parskip}{1em}
\setlength{\parindent}{0pt}
\synctex=-1
\usepackage{fancybox}
\usepackage{calc}
\PassOptionsToPackage{normalem}{ulem}
\usepackage{ulem}
\usepackage{nomencl}
\providecommand{\printnomenclature}{\printglossary}
\providecommand{\makenomenclature}{\makeglossary}
\makenomenclature
\makeatletter

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
% User specified LaTeX commands.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 

%%%% Heading lines
\usepackage[headsepline, ilines,automark]{scrpage2}
\pagestyle{scrheadings}
\clearscrheadings 
\clearscrplain 
\ihead[\headmark]{\headmark}
\ohead{\pagemark}
\chead{}
\cfoot{}

%%%% Inhaltsverzeichnis!
\usepackage[colorlinks,pdfpagelabels,pdfstartview = FitH,bookmarksopen = true,bookmarksnumbered = true,linkcolor = black,plainpages = false,hypertexnames = false,citecolor = black] {hyperref}

\usepackage{fancybox}
\newcommand{\nobreakword}[1]{\mbox{#1}}
\usepackage{etoolbox}
\usepackage{makeidx}\makeindex
\makeatletter
\def\@idxitem{\par\addvspace{10\p@ \@plus 5\p@ \@minus 3\p@}\hangindent 40\p@}
\def\subitem{\par\hangindent 40\p@ \hspace*{20\p@}}
\def\subsubitem{\par\hangindent 40\p@ \hspace*{30\p@}}
\def\indexspace{}
\patchcmd\theindex{\indexname}{\indexname\vspace{12pt}}{}{}
\makeatother

%text before glossar!
\renewcommand{\nompreamble}{%
This text should be written for the entry Schokolade:

Lorem ipsum dolor sit amet,\\...consetetur sadipscing elitr,\\...sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren,\\...no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, \\...no sea takimata sanctus est Lorem ipsum dolor sit amet.Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata\\...sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero \\...eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
\par}

\usepackage{babel}
\makenomenclature

\begin{document}

\newpage
\setcounter{page}{1}
\thispagestyle{empty} 
\begin{center}
\vspace*{10cm}
titlepage
\end{center}

\pagestyle{scrheadings}
\clearpage\pdfbookmark{\contentsname}{toc}\tableofcontents

\chapter{Einleitung}
In diesem Dokument geht es um Haustiere.
\chapter{Tiere}
Heute ass meine \index{Katze}Katze \nomenclature{Katze}{Haustier} Schokolade und musste daher zum \index{Tierarzt}Tierarzt. \nomenclature{Tiger}{Raubtier}
\nomenclature{Schokolade}{Lorem ipsum dolor sit amet,\\...consetetur sadipscing elitr,\\...sed diam}
%
\newpage
neue Seite
\newpage
neue Seite
\addpart{Anhang}
\pagestyle{empty} %ohne Seitenzahlen und Kolumnentitel
\addcontentsline{toc}{chapter}{Glossar}
\renewcommand{\nomname}{Glossar}
\printnomenclature[2.5 cm]
%
\clearpage 
\phantomsection 
\addcontentsline{toc}{chapter}{Stichwortverzeichnis} 
\renewcommand{\indexname}{Stichwortverzeichnis}
\printindex
%
\end{document}

如果有解决方案的话我会非常高兴,如果没有确切的解决方案,那么带有内部和外部的标题不是强制性的,我很高兴能有一个妥协。

答案1

这可以满足您的大部分要求,但并非全部。我犹豫着是否要破解 KOMA Script 的目录代码。因此,这不会从部分的目录条目中删除页码。据我了解,它实现了问题中提到的所有其他要求。

在可能的情况下,我使用了 KOMA 的工具来实现您的设计。这包括确保索引包含在目录中,段落以垂直空间区分,页面布局大致符合要求。这是通过使用包选项的组合、来自的命令typearea(用于布局尺寸)和来自的命令scrlayer-scrpage(用于页眉和页脚)来实现的。请注意,您的代码包含大量来自旧版本 KOMA Script 的过时和弃用的命令。这些命令已在必要时被当前版本替换。

如果您不能将\maketitle其用作标题页,那么您至少应该使用环境titlepage

如果您确实需要指定边距,则必须使用geometry。但这样做与充分利用专门用于良好布局页面的 KOMA Script 不兼容。我提供的代码也不是很好,尽管它比使用geometry指定边距要好。下面的代码强制 KOMA 使用指定尺寸的类型块。这根本不好,因为它破坏了 KOMA 使布局看起来不错的大部分尝试。但是,它并不像强制设置边距那么糟糕,因为它仍然允许 KOMA 使用其某些功能,尽管使用范围相对较小。

您绝对不应该手动设置\parskip\parindent这会进一步搞砸 KOMA 的计算。在这里,我使用了一个示例设置作为类选项。有关其他可能性,请参阅 KOMA 的文档。

最好将索引的格式也留给 KOMA。同样,除非您绝对不能这样做。请参阅文档以了解可以自定义的方式以及有关与类一致和不一致的更改类型的评论。

请注意,我所做的更改的结果是,实际文档的代码比以前干净得多,因为所需的显式格式少了很多。最好在文档级别进行更改。在文档中摆弄特定位不仅会导致不一致,还会在您最意想不到的时候造成意想不到的混乱!文档中的标记应该是语义尽可能地使用非语义标记,即使在无法使用语义标记的情况下,也应该三思而后行。

\synctex=-1
\documentclass[twoside=semi,a4paper,latin,fontsize=10pt,headsepline,parskip=half-,index=totoc]{scrreprt}
% if you are required to have set margins because you are producing the document for a typographical ignoramus, then you will have to load geometry to force the margins (but leave a4paper as a class option). Pretty much all institutions qualify as typographical ignoramuses, unfortunately.
% The next line is far from ideal. It would be better to specify DIV=<integer> as a class option. But if you must have a type area of a specified size, this will work.
\areaset[0pt]{160mm}{247mm}% no binding correction, text width is 160mm, text height is 247mm; with twoside=semi, the margins will be set with a single-sided layout i.e. for symmetry, even though the document is double-sided.
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}
\usepackage[normalem]{ulem}
\usepackage{fancybox,calc,etoolbox,lipsum}
\usepackage[intoc]{nomencl}
\renewcommand{\nomname}{Glossar}
\makenomenclature
\usepackage{scrlayer-scrpage}% scrpage2 is obsolete
  \pagestyle{scrheadings}
  \clearpairofpagestyles% \clearscrheadings, \clearscrplain are deprecated
  \automark[chapter]{chapter}
%   \renewcommand*\chaptermarkformat{}% uncomment if you don't want chapter numbers in the headers
  \ihead[]{\headmark}
  \ohead[\pagemark]{\pagemark}
\usepackage[colorlinks,pdfpagelabels,pdfstartview = FitH,bookmarksopen = true,bookmarksnumbered = true,linkcolor = black,plainpages = false,hypertexnames = false,citecolor = black] {hyperref}

\newcommand{\nobreakword}[1]{\mbox{#1}}
\usepackage{makeidx}
\makeindex
\makeatletter
  \def\@idxitem{\par\addvspace{10\p@ \@plus 5\p@ \@minus 3\p@}\hangindent 40\p@}
  \def\subitem{\par\hangindent 40\p@ \hspace*{20\p@}}
  \def\subsubitem{\par\hangindent 40\p@ \hspace*{30\p@}}
  \def\indexspace{}
  \patchcmd\theindex{\indexname}{\indexname\vspace{12pt}}{}{}
\makeatother

%text before glossar!
\renewcommand{\nompreamble}{%
This text should be written for the entry Schokolade:

Lorem ipsum dolor sit amet,\\...consetetur sadipscing elitr,\\...sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren,\\...no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, \\...no sea takimata sanctus est Lorem ipsum dolor sit amet.Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata\\...sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero \\...eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
\par}

\makenomenclature

\begin{document}
\begin{titlepage}% if you need a custom layout - otherwise, use \maketitle
  \centering
  \vspace*{10cm}
  titlepage
\end{titlepage}

\clearpage\pdfbookmark{\contentsname}{toc}
\tableofcontents\thispagestyle{empty}

\chapter{Einleitung}
\lipsum[1-20]

\chapter{Tiere}
\lipsum[21-25]
\index{Katze}Katze \nomenclature{Katze}{Haustier}
\lipsum[26]
\index{Tierarzt}Tierarzt
\nomenclature{Tiger}{Raubtier}
\nomenclature{Schokolade}{Lorem ipsum dolor sit amet,\\...consetetur sadipscing elitr,\\...sed diam}

\newpage
\lipsum[27]
\newpage
\lipsum[28-37]

\addpart{Anhang}

\printnomenclature[2.5 cm]

\renewcommand{\indexname}{Stichwortverzeichnis}
\printindex

\end{document}

KOMA 布局

编辑

要使用DIV=<integer>配置,请将加载类的行更改为

\documentclass[twoside=semi,a4paper,latin,fontsize=10pt,headsepline,parskip=half-,index=totoc,DIV=15]{scrreprt}

并删除该\areaset线。

要更改部分的页面样式,请添加

\renewcommand*\partpagestyle{empty}

到序言部分。(我在设置后添加了它\ohead。)

答案2

这是我尝试的代码Tarun 的回答

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
% LyX 2.1.0 created this file.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 

\documentclass[twoside,ngerman,fontsize=10pt]{scrreprt}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage[a4paper]{geometry}
\geometry{verbose,tmargin=2.5cm,bmargin=2.5cm,lmargin=2.5cm,rmargin=2.5cm}
\pagestyle{empty}
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}
\setlength{\parskip}{1em}
\setlength{\parindent}{0pt}
\synctex=-1
\usepackage{fancybox}
\usepackage{calc}
\PassOptionsToPackage{normalem}{ulem}
\usepackage{ulem}
\usepackage{nomencl}
\providecommand{\printnomenclature}{\printglossary}
\providecommand{\makenomenclature}{\makeglossary}
\makenomenclature
\makeatletter

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
% User specified LaTeX commands.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 

%%%% Heading lines
\usepackage{fancyhdr}
\pagestyle{fancy}
\renewcommand{\chaptername}{}
\fancyhf{}
\fancyhead[RE,LO]{\textit{\nouppercase{\leftmark}}}
\fancyhead[LE,RO]{\textbf\thepage}

\fancypagestyle{anotherfancy}{ %define another style for first page of chapters.
\renewcommand{\chaptername}{}
\fancyhf{}
\fancyhead[LE,RO]{\textbf\thepage}
} 

%%%% Inhaltsverzeichnis!
\usepackage[colorlinks,pdfpagelabels,pdfstartview = FitH,bookmarksopen =  
true,bookmarksnumbered = true,linkcolor = black,plainpages = false,hypertexnames =     
false,citecolor = black] {hyperref}

\usepackage{fancybox}
\newcommand{\nobreakword}[1]{\mbox{#1}}
\usepackage{etoolbox}
\usepackage{makeidx}\makeindex
\makeatletter
\def\@idxitem{\par\addvspace{10\p@ \@plus 5\p@ \@minus 3\p@}\hangindent 40\p@}
\def\subitem{\par\hangindent 40\p@ \hspace*{20\p@}}
\def\subsubitem{\par\hangindent 40\p@ \hspace*{30\p@}}
\def\indexspace{}
\patchcmd\theindex{\indexname}{\indexname\vspace{12pt}}{}{}
\makeatother

\usepackage{babel}
\makenomenclature

\begin{document}

\newpage
\setcounter{page}{1}
\thispagestyle{empty} 
\begin{center}
\vspace*{10cm}
titlepage
\end{center}

{
\pagestyle{newfancy} %makes the page style the way we want (without page numbers)
\tableofcontents
} % curly braces ensure that the new page style is applicable only for the TOC

\chapter{Introduction} % for the chapter titled "Introduction"
\protect\thispagestyle{anotherfancy} % try this and see if it works. Note the 
In diesem Dokument geht es um Haustiere.
\chapter{Tiere}
Heute ass meine \index{Katze}Katze \nomenclature{Katze}{Haustier} Schokolade und 

musste daher zum \index{Tierarzt}Tierarzt. \nomenclature{Tiger}{Raubtier}
\nomenclature{Schokolade}{Lorem ipsum dolor sit amet,\\...consetetur sadipscing 

elitr,\\...sed diam}
%
\newpage
neue Seite
\newpage
neue Seite
\addpart{Anhang}
\pagestyle{empty} %ohne Seitenzahlen und Kolumnentitel
\addcontentsline{toc}{chapter}{Glossar}
\renewcommand{\nomname}{Glossar}
\printnomenclature[2.5 cm]
%
\clearpage 
\phantomsection 
\addcontentsline{toc}{chapter}{Stichwortverzeichnis} 
\renewcommand{\indexname}{Stichwortverzeichnis}
\printindex
%
\end{document}

答案3

我做了以下操作并且对我有用:

\pagestyle{fancy}
\renewcommand{\chaptername}{}
\fancyhf{}
\fancyhead[RE,LO]{\textit{\nouppercase{\leftmark}}}
\fancyhead[LE,RO]{\textbf\thepage}

\fancypagestyle{newfancy}{ %define new style for TOC. Use this 'newfancy' page style just before the command for generating TOC:
\renewcommand{\chaptername}{}
\fancyhf{}
\fancyhead[LE,RO]{\textit{\nouppercase{\leftmark}}}
} 

当开始新的篇章时,我使用以下命令:

\chapter{Introduction} % for the chapter titled "Introduction"
\thispagestyle{empty} % this helped in no page number or chapter name in the header or footer.
%the above two lines wold be followed by the other contents of the chapter.

如果目录中没有页码,请在命令前使用以下行来生成目录:

{
\pagestyle{newfancy} %makes the page style the way we want (without page numbers)

\tableofcontents
} % curly braces ensure that the new page style is applicable only for the TOC

更新 1: 如果章节首页需要页码,我认为可以在序言中定义另一种页面样式,如下所示:

\fancypagestyle{anotherfancy}{ %define another style for first page of chapters.
\renewcommand{\chaptername}{}
\fancyhf{}
\fancyhead[LE,RO]{\textbf\thepage}
} 

接下来,在开始新的章节时,使用以下方式的命令protect

\chapter{Introduction} % for the chapter titled "Introduction"
\protect\thispagestyle{anotherfancy} % try this and see if it works. Note the '\protect'

尝试一下,看看是否有效。请告诉我。以下是页码的显示方式:

在此处输入图片描述

相关内容