QuickGuide Chapterthumb 在书籍类中工作

QuickGuide Chapterthumb 在书籍类中工作

在下面的代码中,我想让章节名称显示在页面的右侧,就像在 QuickGuide.tex 文件中所做的那样:

在此处输入图片描述

这是我的代码:

\documentclass[11pt,fleqn]{book}

\usepackage{etex}
\reserveinserts{28}

\usepackage[top=3cm,bottom=3cm,left=3.2cm,right=3.2cm,headsep=10pt,a4paper]{geometry}

\usepackage{graphicx}
\usepackage{lipsum} 
\usepackage{tikz}
\usepackage[english]{babel} 
\usepackage{enumitem}
\setlist{nolistsep} 
\usepackage{booktabs} 
\usepackage{xcolor} 
\usepackage{avant} 
\usepackage{mathptmx} 
\usepackage{microtype}
\usepackage[utf8]{inputenc} 
\usepackage[T1]{fontenc}

\usepackage{xcolor}
\definecolor{ocre}{RGB}{52,177,201}
\definecolor{ultramarine}{RGB}{0,45,97}
\definecolor{cpiOrange}{RGB}{241,85,44}
\definecolor{cpiGray}{RGB}{106,100,100}

\usepackage[refsection=chapter,defernumbers=true,sorting=none,sortcites=true,autopunct=true,babel=hyphen,abbreviate=false,backref=true,backend=biber]{biblatex}
\addbibresource{chapter1.bib}
 \defbibheading{bibempty}{}

%======================================================================================
%   PAGE HEADERS
%======================================================================================

\usepackage{fancyhdr} 

\pagestyle{fancy}
\renewcommand{\chaptermark}[1]{\markboth{\sffamily\normalsize\bfseries \ #1}{}} 
\renewcommand{\sectionmark}[1]{\markright{\sffamily\normalsize\thesection\hspace{5pt}#1}{}} 
\fancyhf{} \fancyhead[LE,RO]{\sffamily\normalsize\thepage} 
\fancyhead[LO]{\rightmark} 
\fancyhead[RE]{\leftmark} 
\renewcommand{\headrulewidth}{0.5pt} 
\addtolength{\headheight}{2.5pt} 
\renewcommand{\footrulewidth}{0pt} 
\fancypagestyle{plain}{\fancyhead{}\renewcommand{\headrulewidth}{0pt}} 
\makeatletter
\renewcommand{\cleardoublepage}{
\clearpage\ifodd\c@page\else
\hbox{}
\vspace*{\fill}
\thispagestyle{empty}
\newpage
\fi}


\begin{document}

%----------------------------------------------------------------------------------------
%   TITLE PAGE
%----------------------------------------------------------------------------------------


\begingroup
\thispagestyle{empty}
\centering
\vspace*{5cm}
\par\normalfont\fontsize{25}{35}\sffamily\selectfont
\textbf{Test Subject}\\
\par\normalfont\fontsize{20}{35}\sffamily\selectfont(EEL XXXX - XXXX)\\
{\LARGE Assignment 1}\par % Book title
\vspace*{1cm}
{\Huge Johnny Boy}\par % Author name

\frontmatter

\endgroup

%----------------------------------------------------------------------------------------
%   COPYRIGHT PAGE
%----------------------------------------------------------------------------------------
\newpage
~\vfill
\thispagestyle{empty}

Just some text for the copyright page.

%----------------------------------------------------------------------------------------
%   TABLE OF CONTENTS
%----------------------------------------------------------------------------------------

\pagestyle{empty} % No headers

\tableofcontents % Print the table of contents itself

\listoffigures

\pagestyle{fancy} % Print headers again

%========================================================================================
%   MAINMATTER
%========================================================================================

\mainmatter

\chapter{This is the first chapter}
\lipsum \lipsum\cite{egan}

\chapter{This is the second chapter}
\lipsum \lipsum

%===============================================================================

\backmatter

\newpage
\chapter{Bibliography}

\addcontentsline{toc}{section}{Bibliography}
\subsection*{Books}

\printbibliography[heading=bibempty,type=book,prefixnumbers={B}]
\subsection*{Articles}

\printbibliography[heading=bibempty,type=article,prefixnumbers={A}]
\subsection*{Online}

\printbibliography[heading=bibempty,type=misc,prefixnumbers={O}]


%========================================================================================

\end{document} 

这是 QuickGuide.tex 文件中使用的 chapterthumb.sty:

\ProvidesPackage{chapterthumb}%
  [2005/03/10 v0.1 unsupported LaTeX package]
\DeclareOption*{%
  \PassOptionsToPackage{\CurrentOption}{scrpage2}}
\ProcessOptions\relax
\RequirePackage{graphics,color}
\RequirePackage{scrpage2}
\newcommand*{\putchapterthumb}{%
  \begingroup
    \makebox[0pt][l]{%
      \hspace{-\oddsidemargin}\hspace{-1in}%
      \hspace{-\@oddheadshift}%
      \hspace{\paperwidth}%
      \parbox[t][0pt][t]{0pt}{%
        \vspace{-\topmargin}%
        \vspace{-1in}%
        \vspace{-\headheight}%
        \vspace{\dp\strutbox}%
        \vspace{\firstchapterthumbskip}%
        \setlength{\@tempdima}{\paperheight}%
        \addtolength{\@tempdima}{-\chapterthumbwidth}%
        \addtolength{\@tempdima}{1pt}%
        \setlength{\@tempdimb}{\chapterthumbskip}%
        \divide\@tempdima by\@tempdimb
        \@tempcnta=\@tempdima
        \advance\@tempcnta by 1
        \@tempcntb=\value{chapter}%
        \advance\@tempcntb by -1
        \divide\@tempcntb by \@tempcnta
        \multiply\@tempcntb by -\@tempcnta
        \advance\@tempcntb by \value{chapter}%
        \advance\@tempcntb by -1
        \setlength{\@tempdima}{\chapterthumbskip}%
        \vspace{\@tempcntb\@tempdima}%
        \makebox[0pt][r]{%
          \rotatebox{90}{%
            \colorbox{\chapterthumbboxcolor}{%
              \parbox[t][\chapterthumbheight][c]%
                     {\chapterthumbwidth}{%
                \centering
                \color{\chapterthumbcolor}%
                \chapterthumbfont{\chapterthumbformat}}}}}%
      }%
    }%
  \endgroup
}
\newcommand*{\firstchapterthumbskip}{0pt}
\newcommand*{\chapterthumbheight}{2em}
\newcommand*{\chapterthumbwidth}{.2\paperheight}%
\newcommand*{\chapterthumbskip}{.1\paperheight}%
\newcommand*{\chapterthumbboxcolor}{black}%
\newcommand*{\chapterthumbcolor}{white}
\newcommand*{\chapterthumbformat}{\@chapapp~\thechapter}
\newcommand*{\chapterthumbfont}{\normalfont\Large\sffamily}
\newcommand*{\scr@fnt@chapterthumb}{\chapterthumbfont}
\endinput

为了实现这个chapterthumb索引,所用的代码如下:

% chapters with thumb index

    \usepackage{chapterthumb}
    \renewcommand*{\chapterthumbboxcolor}{Navy}
    \renewcommand*{\chapterthumbfont}{\normalfont\Large\sffamily\bfseries}
    \renewcommand{\chapterthumbwidth}{.125\paperheight}
       \lohead[\putchapterthumb]{\putchapterthumb}
       \addtokomafont{chapterthumb}{\small{\bfseries}} 

与 QuickGuide PDF 一样,章节缩略图索引会随着章节编号的增加而变化。

答案1

该包chapterthumb由 Markus Kohm 编写,用于 KOMA-Script。因此您应该使用文档类scrbook

你懂德语吗?如果懂,请查看网址http://www.komascript.de/node/289Markus Kohm 指出chapterthumb需要使用scrpage2,您可以找到一个正在运行的最小示例。在给定的代码(不是真正的 MWE)中,您正在使用fancyhdr。因此,这无法工作...

chapterthumb.sty如果您将文件复制到同一目录中,则会编译以下 MWE :

\documentclass[paper=a4,11pt]{scrbook} 

\usepackage[english]{babel} 
\usepackage[T1]{fontenc}

\usepackage{blindtext} % to generate a dummy text

\usepackage{chapterthumb} 
\usepackage{hyperref} 

\pagestyle{scrheadings}
\lohead[\putchapterthumb]{\putchapterthumb}
\lehead[The Title]{The Title}
\setkomafont{pagehead}{\footnotesize\bfseries}
\setkomafont{pagenumber}{\normalfont}


\begin{document}

\pagenumbering{arabic}
\Blinddocument   % Generates dummy document

\end{document}

这是 Markus Kohm 编写的原始 MWE(我将其改为英语,原文是德文),scrlayer-scrpage其中包含您应该使用的新包scrpage2

\documentclass{scrbook}
\usepackage[english]{babel}
\usepackage{chapterthumb} % copy chapterthumb.sty in the same directory!
\usepackage{scrlayer-scrpage} % instead obsolete scrpage2
\usepackage{blindtext}        % to create dummy text
\pagestyle{scrheadings}
\AddLayersToPageStyle{@everystyle@}{chapterthumb}
\addtokomafont{chapterthumb}{\bfseries}


\begin{document}
\chapter{The beginning}\dots

\Blinddocument

\chapter{next}\dots
\chapter{and next}\dots
\chapter{and the next}\dots
\chapter{and so on}\dots
\chapter{until the end}
\end{document}

相关内容