![为章节缩略图编号,从目录中删除 0](https://linux22.com/image/352696/%E4%B8%BA%E7%AB%A0%E8%8A%82%E7%BC%A9%E7%95%A5%E5%9B%BE%E7%BC%96%E5%8F%B7%EF%BC%8C%E4%BB%8E%E7%9B%AE%E5%BD%95%E4%B8%AD%E5%88%A0%E9%99%A4%200.png)
我正在使用 KOMA-Script 制作章节缩略图。我该如何修改它以从目录中删除“0”章节缩略图?
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Chapter thumbs with scrpage2
%
% Copyright 2008 Markus Kohm
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
% The latest version of this license is in
% http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
% This work has the LPPL maintenance status `maintained'.
%
% The Current Maintainer of this work is Markus Kohm.
%
% This work consists of the code until
% `End of chapter thumbs with scrpage2' only.
% You should not remove the link to the original code:
% <http://www.komascript.de/node/25>.
%
% Safty first
\@ifundefined{chapter}{\let\chapter\undefined
\chapter must be defined to use chapter thumbs!}{%
% Two new commands for the width and height of the boxes with the
% chapter number at the thumbs (use of commands instead of lengths
% for sparing registers)
\newcommand*{\chapterthumbwidth}{2em}
\newcommand*{\chapterthumbheight}{1em}
% Two new commands for the colors of the box background and the
% chapter numbers of the thumbs
\newcommand*{\chapterthumbboxcolor}{black}
\newcommand*{\chapterthumbtextcolor}{white}
% New command to set a chapter thumb. I'm using a group at this
% command, because I'm changing the temporary dimension \@tempdima
\newcommand*{\putchapterthumb}{%
\begingroup
\Large
% calculate the horizontal possition of the right paper border
% (I ignore \hoffset, because I interprete \hoffset moves the page
% at the paper e.g. if you are using cropmarks)
\setlength{\@tempdima}{\@oddheadshift}% (internal from scrpage2)
\setlength{\@tempdima}{-\@tempdima}%
\addtolength{\@tempdima}{\paperwidth}%
\addtolength{\@tempdima}{-\oddsidemargin}%
\addtolength{\@tempdima}{-1in}%
% putting the thumbs should not change the horizontal
% possition
\rlap{%
% move to the calculated horizontal possition
\hspace*{\@tempdima}%
% putting the thumbs should not change the vertical
% possition
\vbox to 0pt{%
% calculate the vertical possition of the thumbs (I ignore
% \voffset for the same reasons told above)
\setlength{\@tempdima}{\chapterthumbwidth}%
\multiply\@tempdima by\value{chapter}%
\addtolength{\@tempdima}{-\chapterthumbwidth}%
\addtolength{\@tempdima}{-\baselineskip}%
% move to the calculated vertical possition
\vspace*{\@tempdima}%
% put the thumbs left so the current horizontal possition
\llap{%
% and rotate them
\rotatebox{90}{\colorbox{\chapterthumbboxcolor}{%
\parbox[c][\chapterthumbheight][c]{\chapterthumbwidth}{%
\centering
\textcolor{\chapterthumbtextcolor}{%
\strut\thechapter}\\
}%
}%
}%
}%
% avoid overfull \vbox messages
\vss
}%
}%
\endgroup
}
% New command, which works like \lohead but also puts the thumbs (you
% cannot use \ihead with this definition but you may change this, if
% you use more internal scrpage2 commands)
\newcommand*{\loheadwithchapterthumbs}[2][]{%
\lohead[\putchapterthumb#1]{\putchapterthumb#2}%
}
% initial use
\loheadwithchapterthumbs{}
\pagestyle{scrheadings}
}
%
% End of chapter thumbs with scrpage2
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
答案1
用于\lohead[]{}
删除章节缩略图并\loheadwithchapterthumbs{}
启用它们。
\documentclass{scrbook}
\usepackage{rotating}
\usepackage{xcolor}
\usepackage{scrpage2}
\usepackage{chapterthumbs}
\usepackage{blindtext}% dummy text
\begin{document}
\lohead[]{}% no chapterthumbs
\tableofcontents
\cleardoublepage
\loheadwithchapterthumbs{}% use chapterthumbs
\blinddocument
\end{document}
但请注意,该包chapterthumbs
已经过时,因为它基于已弃用的包scrpage2
。
我建议使用chapterthumb
可以与一起使用的包scrlayer-scrpage
。chapterthumb.sty
这是 KOMA-Script 书籍示例的一部分。您可以从https://komascript.de/komascriptbuch5examples. 它位于 zip 文件的“Anhang-B”文件夹中。
\documentclass{scrbook}
\usepackage[ngerman]{babel}
\usepackage{chapterthumb}[2016/02/01]
\usepackage{scrlayer-scrpage}
\pagestyle{scrheadings}
\AddLayersToPageStyle{@everystyle@}{chapterthumb}
\addtokomafont{chapterthumb}{\bfseries}
\renewcommand*{\chapterthumbwidth}{.05\paperheight}
\renewcommand*{\chapterthumbskip}{.05\paperheight}
\renewcommand*{\chapterthumbformat}{\thechapter}
\usepackage{blindtext}% dummy text
\begin{document}
\tableofcontents
\blinddocument
\end{document}
这两个示例也适用于标准类book
。
chapterthumb
如果您想手动启用或禁用章节缩略图,您可以定义分别向所有图层页面样式添加或删除图层的命令:
\documentclass{scrbook}
\usepackage[ngerman]{babel}
\usepackage{chapterthumb}[2016/02/01]
\usepackage{scrlayer-scrpage}
\addtokomafont{chapterthumb}{\bfseries}
\renewcommand*{\chapterthumbwidth}{.05\paperheight}
\renewcommand*{\chapterthumbskip}{.05\paperheight}
\renewcommand*{\chapterthumbformat}{\thechapter}
\newcommand*\chapterthumbson{%
\AddLayersToPageStyle{@everystyle@}{chapterthumb}%
}% command to enable chapter thumbs
\newcommand*\chapterthumbsoff{%
\RemoveLayersFromPageStyle{@everystyle@}{chapterthumb}%
}% command to disable chapter thums
\chapterthumbsoff% disable chapter thumbs
\usepackage{blindtext}% dummy text
\begin{document}
\tableofcontents
\blinddocument
\clearpage
\chapterthumbson% enable chapter thumbs
\blinddocument
\end{document}