我想使用 KOMA 脚本中的 chapterthumbs 制作半圆形缩略图索引。为此,我用 tikz 制作了圆圈,并分别在奇数页和偶数页上将它们移动适当的距离。当然,这也会移动章节号。我尝试过使用\hspace*{}
,但这要么移动整个缩略图索引,要么什么也不做。
如何移动拇指索引内的文本不同地奇数页和偶数页?或者我必须为奇数页和偶数页分别制作章节缩略图命令吗?(我希望不需要)
\documentclass[twoside, openright]{scrreprt}
\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage{tikz}
\usepackage[automark]{scrlayer-scrpage}
%%%---thumb indices using chapterthumb
% the following bases on an example in the KOMA-Script book:
\newcommand*{\firstchapterthumbskip}{.1\paperheight}
\newcommand*{\lastchapterthumbskip}{\firstchapterthumbskip}
\newcommand*{\chapterthumbheight}{.1\paperheight}
\newcommand*{\chapterthumbwidth}{.01\paperheight}
\newcommand*{\chapterthumbskip}{.1\paperheight}
\colorlet{chapterthumbboxcolor}{gray!30}
\newcommand*{\chapterthumbcolor}{white}
\newcommand*{\chapterthumbformat}{\thechapter}
\newkomafont{chapterthumb}{\normalfont\Large\color{\chapterthumbcolor}}
\makeatletter
\newcommand*\chapterthumb@box{%
\usekomafont{chapterthumb}%
\parbox[c][\chapterthumbheight][c]{\chapterthumbwidth}{%
\centering
\begin{tikzpicture}
\node[circle, minimum width=2.5cm, minimum height=2.5cm, fill=chapterthumbboxcolor]
{\chapterthumbformat};
\end{tikzpicture}%
}%
}
\newcommand*{\chapterthumbbox}{%
\if@mainmatter
\ifnum\value{chapter}>\z@
\ifnum \value{chapterthumb}<\z@
\else
\begingroup
\protected@edef\reserved@a{\chapterthumbformat}%
\ifx\reserved@a\lastchapterthumbformat\else
\stepcounter{chapterthumb}%
\global\let\lastchapterthumbformat\reserved@a
\fi
\@tempcnta=\numexpr
\dimexpr
\paperheight
-\firstchapterthumbskip
-\chapterthumbwidth
-\lastchapterthumbskip
\relax / \dimexpr
\chapterthumbskip
\relax
+1
\relax
\ifnum \value{chapterthumb}<\@tempcnta
\else
\setcounter{chapterthumb}{0}%
\fi
\vspace*{%
\dimexpr
\firstchapterthumbskip
+ ( \chapterthumbskip )
* \value{chapterthumb}%
- \baselineskip
\relax
}\par
\setlength{\fboxsep}{0pt}%
\ifodd\value{page}
\hfill
\makebox[0pt][r]{%
\rotatebox[origin=c]{0}{\chapterthumb@box}}%
\hspace*{0.9cm}
\else
\hspace*{-1.4cm}
\makebox[0pt][l]{%
\rotatebox[origin=c]{0}{\chapterthumb@box}}%
\fi
\endgroup
\fi
\fi
\fi
}
\makeatother
\newcounter{chapterthumb}
\setcounter{chapterthumb}{10000}
\newcommand*{\lastchapterthumbformat}{\relax}
\DeclareNewLayer[%
background,%
outermargin,%
contents=\chapterthumbbox
]{chapterthumb}
\newcommand*\EnableChapterthumb{%
\IfLayerAtPageStyle{scrheadings}{chapterthumb}{}
{\AddLayersToPageStyle{@everystyle@}{chapterthumb}}%
}
\newcommand*\DisableChapterthumb{%
\RemoveLayersFromPageStyle{@everystyle@}{chapterthumb}%
}
\EnableChapterthumb
\usepackage{lipsum}
\begin{document}
\chapter{First}
\lipsum[1-6]
\chapter{Second}
\lipsum[7-12]
\end{document}
答案1
根据 Ulrike Fischer 的评论,以下是包含答案的 MWE:
\documentclass[twoside, openright]{scrreprt}
\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage{tikz}
\usepackage[automark]{scrlayer-scrpage}
%%%---thumb indices using chapterthumb
% the following bases on an example in the KOMA-Script book:
\newcommand*{\firstchapterthumbskip}{.1\paperheight}
\newcommand*{\lastchapterthumbskip}{\firstchapterthumbskip}
\newcommand*{\chapterthumbheight}{.1\paperheight}
\newcommand*{\chapterthumbwidth}{.01\paperheight}
\newcommand*{\chapterthumbskip}{.1\paperheight}
\colorlet{chapterthumbboxcolor}{gray!30}
\newcommand*{\chapterthumbcolor}{white}
\newcommand*{\chapterthumbformat}{\thechapter}
\newkomafont{chapterthumb}{\normalfont\Large\color{\chapterthumbcolor}}
\makeatletter
\newcommand*\chapterthumb@box{%
\usekomafont{chapterthumb}%
\parbox[c][\chapterthumbheight][c]{\chapterthumbwidth}{%
\centering
\begin{tikzpicture}
\node[circle, minimum width=2.5cm, minimum height=2.5cm, fill=chapterthumbboxcolor]
{\ifodd\value{page}\makebox[0pt][c]{\hspace{-1cm}\chapterthumbformat} \else\makebox[0pt][c]{\hspace{1cm}\chapterthumbformat}\fi};
\end{tikzpicture}%
}%
}
\newcommand*{\chapterthumbbox}{%
\if@mainmatter
\ifnum\value{chapter}>\z@
\ifnum \value{chapterthumb}<\z@
\else
\begingroup
\protected@edef\reserved@a{\chapterthumbformat}%
\ifx\reserved@a\lastchapterthumbformat\else
\stepcounter{chapterthumb}%
\global\let\lastchapterthumbformat\reserved@a
\fi
\@tempcnta=\numexpr
\dimexpr
\paperheight
-\firstchapterthumbskip
-\chapterthumbwidth
-\lastchapterthumbskip
\relax / \dimexpr
\chapterthumbskip
\relax
+1
\relax
\ifnum \value{chapterthumb}<\@tempcnta
\else
\setcounter{chapterthumb}{0}%
\fi
\vspace*{%
\dimexpr
\firstchapterthumbskip
+ ( \chapterthumbskip )
* \value{chapterthumb}%
- \baselineskip
\relax
}\par
\setlength{\fboxsep}{0pt}%
\ifodd\value{page}
\hfill
\makebox[0pt][r]{%
\rotatebox[origin=c]{0}{\chapterthumb@box}}%
\hspace*{0.9cm}
\else
\hspace*{-1.4cm}
\makebox[0pt][l]{%
\rotatebox[origin=c]{0}{\chapterthumb@box}}%
\fi
\endgroup
\fi
\fi
\fi
}
\makeatother
\newcounter{chapterthumb}
\setcounter{chapterthumb}{10000}
\newcommand*{\lastchapterthumbformat}{\relax}
\DeclareNewLayer[%
background,%
outermargin,%
contents=\chapterthumbbox
]{chapterthumb}
\newcommand*\EnableChapterthumb{%
\IfLayerAtPageStyle{scrheadings}{chapterthumb}{}
{\AddLayersToPageStyle{@everystyle@}{chapterthumb}}%
}
\newcommand*\DisableChapterthumb{%
\RemoveLayersFromPageStyle{@everystyle@}{chapterthumb}%
}
\EnableChapterthumb
\usepackage{lipsum}
\begin{document}
\chapter{First}
\lipsum[1-6]
\chapter{Second}
\lipsum[7-12]
\end{document}