如何使章节缩略图与 KOMA-Script 中的章节标题相匹配?

如何使章节缩略图与 KOMA-Script 中的章节标题相匹配?

这是一个附加问题以前的一个关于 chapterthumbs 的。请考虑下面的 MWE,chapterthumbs 与章节标题不匹配(应该出现讨论而不是材料和方法),因此如何:

目标

  • 将章节缩略图与章节标题相匹配 - 已回答
  • 在 MWE 中激活摘要/参考书目的 chapterthumb -- 已回答
  • 抑制 MWE 中关于简历的章节缩略图 - 已回答
  • 拇指的推进应该进步沿着页面的整个右边缘 - 回答!

平均能量损失

\documentclass{scrbook}
\usepackage{chapterthumb}%
\usepackage{etoolbox}%
\usepackage{nameref}%
\lohead[\putchapterthumb]{\putchapterthumb}
\addtokomafont{chapterthumb}{\bfseries}

%
\let\LaTeXStandardChapter\chapter%
\renewcommand*{\chapterthumbformat}{\refcommand{chapter::title::\number\value{chapter}}}%

\makeatletter

\newcounter{totalchaptercounter}%

\newrobustcmd{\WriteChapterTitleToAux}[1]{%
\refstepcounter{totalchaptercounter}%
\immediate\write\@auxout{%
\string\newlabel{chapter::title::\number\value{totalchaptercounter}}{{\thesection}{\thepage}{\unexpanded{#1}}{}}
}% End of writing to AUX file
}%

\newrobustcmd{\refcommand}[1]{%
\nameref*{#1}%
}%

\newcommand{\chapter@noopt}[1]{%
\WriteChapterTitleToAux{#1}%
\LaTeXStandardChapter{#1}%
}%

\newcommand{\chapter@opt}[2][]{%
\WriteChapterTitleToAux{#2}%
\LaTeXStandardChapter[#1]{#2}%
}%


\newcommand{\unstarredchapter}{%
\@ifnextchar[{\chapter@opt}{\chapter@noopt}%
}%

\newcommand{\starredchapter}[1]{%
\LaTeXStandardChapter*{#1}
}%



\renewcommand{\chapter}{%
\@ifstar{\starredchapter}{\unstarredchapter}%
}%

%=====================Bibliography=============================
\usepackage{biblatex}
\usepackage{filecontents}
\begin{filecontents}{jobname.bib}
@article{rand_objective_1971,
    title = {Objective criteria for the evaluation of clustering methods},
    volume = {66},
    issn = {01621459},
    url = {http://www.jstor.org/discover/10.2307/2284239?uid=3737864&uid=2&uid=4&sid=21103234673533},
    doi = {10.2307/2284239},
    pages = {846},
    number = {336},
    journaltitle = {Journal of the American Statistical Association},
    shortjournal = {J Amer Statist Assoc},
    author = {Rand, William M.},
    urldate = {2013-12-18},
    date = {1971-12},
    keywords = {Comparing partitions, Rand, statistics}
}

@article{hubert_comparing_1985,
    title = {Comparing partitions},
    volume = {2},
    issn = {0176-4268, 1432-1343},
    url = {http://link.springer.com/article/10.1007/BF01908075},
    doi = {10.1007/BF01908075},
    pages = {193-218},
    number = {1},
    journaltitle = {Journal of Classification},
    shortjournal = {J Classif},
    author = {Hubert, Lawrence and Arabie, Phipps},
    urldate = {2013-12-18},
    date = {1985-12-01},
    langid = {english},
    keywords = {{ARI}, Comparing partitions, Consensus indices, Measures of agreement, Measures of association, statistics, Statistics, general}
}   
\end{filecontents}
\addbibresource{jobname.bib}
%==================================================
\title{Title of the Dissertation}
\author{Author Name} 
\publishers{Faculty Name}

\begin{document}
\maketitle
\frontmatter
\pagestyle{plain}%
\tableofcontents %chapterthumb:no
\chapter{Acknowledgements} %chapterthumb:no
\chapter{Abstract}\dots
\clearpage
\mainmatter
\pagestyle{scrheadings}
\chapter{Introduction}\dots
Sample text here cited \parencite{hubert_comparing_1985}, which is different from \textcite{rand_objective_1971}.

\chapter{Materials \& Methods}\dots 
\chapter{Results}\dots 
\chapter{Discussion}\dots
\backmatter
\printbibliography[heading=bibintoc]
\clearpage%
\pagestyle{plain} % Or any other user defined style
\chapter*{Curriculum Vitae} %chapterthumb:no
\end{document}

MWE 输出
在此处输入图片描述

笔记

  • chapterthumbTexLive2013 尚不支持,因此应手动安装

  • chapterthumb.sty v0.1用于上述 MWE,而不是更新的v0.2在windows 7平台上打包。

更新
由于 KOMA 脚本更新,无法保证 MWE 或解决方案中的代码能够正常工作。新版本的chapterthumb软件包不再基于该scrpage2软件包,而是基于其后继scrlayer软件包。请参阅http://www.komascript.de/chapterthumbs-example了解更多信息。

答案1

使用\frontmatter和 加星标章节 强调了我几天前给 OP 的另一个问题的旧版本,因此必须修改该解决方案并在此处提供。首先,我放弃了\chapter*{}制作章节缩略图的可能性,必须重新定义\tableofcontents\listoffigures并且\listoftables为了安全起见,不要使用更改的加星标章节命令并totalchaptercounter意外增加。

  • 不要在某处更改章节编号,这会导致错误的引用
  • 不要\chapter*{}在两个正常之间使用\chapters,无论 \chapter[shorttitle]{longtitle}\chapter{longtitle}
  • 不要改变\totalchaptercounter某个地方,这会弄乱计数。
  • **切勿用来\frontmatter切换到罗马页码,它的设置很奇怪,我至今无法弄清楚,请改用\pagenumbering{roman}

我无法测试任何个别事件如果某人做了某事会发生什么... 当然


更改后的代码如下:

\documentclass{scrbook}
\usepackage{blindtext}
\usepackage{chapterthumb}%
\usepackage{etoolbox}%
\usepackage{nameref}%


\lohead[\putchapterthumb]{\putchapterthumb}
\addtokomafont{chapterthumb}{\bfseries}


\newrobustcmd{\refcommand}[1]{%
\nameref*{#1}%
}%

\renewcommand*{\chapterthumbformat}{\refcommand{chapter::title::\number\value{chapter}}}%

\makeatletter

\newcounter{totalchaptercounter}%

\newrobustcmd{\CreateUniqueChapterLabel}[1]{% Well, `unique` as it can be ;-)
\refstepcounter{totalchaptercounter}%
\label{chapter::title::\number\value{totalchaptercounter}}%
}%


\let\LaTeXStandardChapter\chapter%

\newcommand{\chapter@noopt}[1]{%
\LaTeXStandardChapter{#1}%
\CreateUniqueChapterLabel{#1}% Must appear after chapter title is done
}%

\newcommand{\chapter@opt}[2][]{%
\LaTeXStandardChapter[#1]{#2}%
\CreateUniqueChapterLabel{#2}% Must appear after chapter title is done
}%


\newcommand{\unstarredchapter}{%
\@ifnextchar[{\chapter@opt}{\chapter@noopt}%
}%

\newcommand{\starredchapter}[1]{%
\lohead[]{}% Clear the headers -> no chapterthumb here 
\LaTeXStandardChapter*{#1}%   
}%

\renewcommand{\chapter}{%
\@ifstar{\starredchapter}{\unstarredchapter}%
}%


\let\LaTeXStandardTOC\tableofcontents%
\renewcommand{\tableofcontents}{%
\begingroup%
\renewcommand{\chapter}{\LaTeXStandardChapter}%
\LaTeXStandardTOC%
\endgroup%
}%


\let\LaTeXStandardLOF\listoffigures%
\renewcommand{\listoffigures}{%
\begingroup%
\renewcommand{\chapter}{\LaTeXStandardChapter}
\LaTeXStandardLOF%
\endgroup
}%

\let\LaTeXStandardLOT\listoftables%
\renewcommand{\listoftables}{%
\begingroup%
\renewcommand{\chapter}{\LaTeXStandardChapter}
\LaTeXStandardLOT%
\endgroup
}%

\makeatother


%==================================================
\title{Title of the Dissertation}
\author{Author Name} 
\publishers{Faculty Name}

\begin{document}
\maketitle%
\pagestyle{plain}%
%%%% Set roman page numbers here, but do **not** use \frontmatter!!!!!!
\pagenumbering{Roman}% or \pagenumbering{roman}%
\tableofcontents %chapterthumb:no
\listoffigures
\listoftables
\cleardoublepage
\chapter{Acknowledgements} %chapterthumb:no
\chapter{Abstract}\dots
\cleardoublepage
\mainmatter% Can be done safely
\pagestyle{scrheadings}
\chapter{Introduction}\dots
\begin{figure}
\caption{dummyfigure}
\end{figure}
\chapter{Materials \& Methods}\dots 
\chapter{Results}\dots 

\begin{table}
\caption{dummy table}
\end{table}

\chapter{Discussion}\dots
\blindtext
\cleardoublepage
\pagestyle{plain} % Or any other user defined style

\chapter*{Curriculum Vitae} %chapterthumb:no
\end{document}

编辑——更新版本

  • 添加\chapter*{}到目录中很容易,用于\addcontentsline
  • \printbibliography更难,因为它基本上是一个没有星号的部分,所以章节号不会增加。这必须手动完成,或者通过修改并在文件中\printbibliography明确写入带有内容的标签来完成。Bibliography.aux

  • 我引入了一个可以设置为或 的toggle标志,但是,它在开始时手动设置为,并且在更改为 之后,如果需要章节缩略图,则必须再次设置它。UseChapterThumbtruefalsetruefalse

  • 参考书目必须目前是文件中的最后一个“章节”, 一定不\chapter{}是参考书目之后的另一个,\chapter*{}但是没有问题。

  • 章节缩略图会根据章节数分布在整个右页。但是,如果章节数较多,缩略图的空间会变得非常小,并且如果章节标题中有较长的单词,文本会被包裹或部分被吞噬。


这是更新后的代码

\documentclass{scrbook}
\usepackage{blindtext}
\usepackage{calc}%
\usepackage{chapterthumb}%
\usepackage{etoolbox}%
\usepackage{nameref}%
\usepackage[backend=bibtex]{biblatex}
\usepackage{totcount}
\bibliography{bib}%

\regtotcounter{chapter}%


\AtBeginDocument{%
\ifnumequal{\number\totvalue{chapter}}{0}{%
\renewcommand{\chapterthumbwidth}{\paperheight}%
\renewcommand{\chapterthumbskip}{\paperheight}%
}{%
\typeout{There are \number\totvalue{chapter} chapter in this document}%
\renewcommand{\chapterthumbskip}{\paperheight/\number\totvalue{chapter}}%
\renewcommand{\chapterthumbwidth}{\paperheight/\number\totvalue{chapter}}%
}%
}%

\lohead[\putchapterthumb]{\putchapterthumb}
\addtokomafont{chapterthumb}{\bfseries}

\newrobustcmd{\SetChapterThumbHeader}{%
\lohead[\putchapterthumb]{\putchapterthumb}%
}%

\newrobustcmd{\ClearChapterThumbHeader}{%
\lohead[]{}%
}%

\newrobustcmd{\refcommand}[1]{%
\nameref*{#1}%
}%

\newtoggle{UseChapterThumb}%
\toggletrue{UseChapterThumb}%

\renewcommand*{\chapterthumbformat}{\refcommand{chapter::title::\number\value{chapter}}}%

\makeatletter

\newcounter{totalchaptercounter}%

\newrobustcmd{\CreateUniqueChapterLabel}[1]{% Well, `unique` as it can be ;-)
\refstepcounter{totalchaptercounter}%
\label{chapter::title::\number\value{totalchaptercounter}}%
}%


\let\LaTeXStandardChapter\chapter%

\newcommand{\chapter@noopt}[1]{%
\iftoggle{UseChapterThumb}{\SetChapterThumbHeader}{\ClearChapterThumbHeader}
\LaTeXStandardChapter{#1}%
\CreateUniqueChapterLabel{#1}% Must appear after chapter title is done
}%

\newcommand{\chapter@opt}[2][]{%
\iftoggle{UseChapterThumb}{\SetChapterThumbHeader}{\ClearChapterThumbHeader}
\LaTeXStandardChapter[#1]{#2}%
\CreateUniqueChapterLabel{#2}% Must appear after chapter title is done
}%


\newcommand{\unstarredchapter}{%
\@ifnextchar[{\chapter@opt}{\chapter@noopt}%
}%

\newcommand{\starredchapter}[1]{%
\ClearChapterThumbHeader% Clear the headers -> no chapterthumb here 
\LaTeXStandardChapter*{#1}%   
}%

\renewcommand{\chapter}{%
\@ifstar{\starredchapter}{\unstarredchapter}%
}%


\let\LaTeXStandardTOC\tableofcontents%
\renewcommand{\tableofcontents}{%
\begingroup%
\renewcommand{\chapter}{\LaTeXStandardChapter}%
\LaTeXStandardTOC%
\endgroup%
}%


\let\LaTeXStandardLOF\listoffigures%
\renewcommand{\listoffigures}{%
\begingroup%
\renewcommand{\chapter}{\LaTeXStandardChapter}
\LaTeXStandardLOF%
\endgroup
}%

\let\LaTeXStandardLOT\listoftables%
\renewcommand{\listoftables}{%
\begingroup%
\renewcommand{\chapter}{\LaTeXStandardChapter}
\LaTeXStandardLOT%
\endgroup
}%


\let\LaTeXStandardPrintBibliography\printbibliography%


\newrobustcmd{\commonprintbibliographysetup}[1][]{%
\iftoggle{UseChapterThumb}{\SetChapterThumbHeader\refstepcounter{chapter}}{\ClearChapterThumbHeader}
\LaTeXStandardPrintBibliography[#1]%
\iftoggle{UseChapterThumb}{%
\immediate\write\@auxout{%
\string\newlabel{chapter::title::\number\value{chapter}}{{\thepage}{\thepage}{Bibliography}{}}%
}%
}{}%
}%



\newrobustcmd{\printbibliography@@noopt}{%
\commonprintbibliographysetup[]%
}%

\newrobustcmd{\printbibliography@@opt}[1][]{%
\commonprintbibliographysetup[#1]%
}

\renewcommand{\printbibliography}{%
\@ifnextchar[{\printbibliography@@opt}{\printbibliography@@noopt}%
}%

\makeatother


%==================================================
\title{Title of the Dissertation}
\author{Author Name} 
\publishers{Faculty Name}

\begin{document}


\maketitle%
\pagestyle{plain}%
%%%% Set roman page numbers here, but do **not** use \frontmatter!!!!!!
\pagenumbering{Roman}% or \pagenumbering{roman}%
\tableofcontents %chapterthumb:no
\listoffigures
\listoftables
\cleardoublepage
\chapter*{Acknowledgements} %chapterthumb:no
\addcontentsline{toc}{chapter}{Acknowledgements}%
\chapter*{Abstract}\dots
\addcontentsline{toc}{chapter}{Abstract}%
\cleardoublepage
\lohead[\putchapterthumb]{\putchapterthumb}% Again here...
\mainmatter% Can be done safely
\pagestyle{scrheadings}
\chapter{Introduction}\dots
\begin{figure}
\caption{dummyfigure}
\end{figure}
\chapter{Materials \& Methods}\dots 
\chapter{Results}\dots 

\begin{table}
\caption{dummy table}
\end{table}

\chapter{Dummy Chapter}%            Please remove this afterwards
\chapter{Another Dummy Chapter}%     Please remove this afterwards

\chapter{Discussion}\dots
\blindtext
In his book \cite{lamport94} Leslie Lamport
\cleardoublepage

\togglefalse{UseChapterThumb}% Switch off chapter thumbs for this section
\chapter*{Curriculum Vitae} %chapterthumb:no

\cleardoublepage
\toggletrue{UseChapterThumb}%
\printbibliography[heading=bibintoc]




\end{document}

在此处输入图片描述

相关内容