我想根据这。
问题 1:我如何为框定义自定义颜色(最好是十六进制代码)? 编辑:我通过之前定义自定义颜色并插入自定义描述符解决了这个问题。
问题2:我希望缩略图索引均匀分布在整个页面高度上(且不重叠),与章节数相关。例如:对于第 1 章,缩略图索引从最顶部开始,是页面长度的 x 分之一(其中 x 等于章节数);对于第 2 章,缩略图索引的框从第 1 章框的末尾开始,依此类推。
有什么方法可以将这两件事实现到我的文档中吗?
任何帮助将不胜感激。
答案1
知道了!
我对 MWE 进行了一些小改动,但都进行了评论。
我做的改变是:
- 白色无衬线字体,小号,所有内容居中
- 拇指索引的大小现在是页面高度的 1/x(A4 纸)
- 自定义颜色定义
- 拇指索引框的垂直移动量等于框的高度
- 宽度略小(1.5厘米)
希望这对遇到这种情况的任何人都有帮助。:-)
\documentclass[a4paper]{report}
\usepackage{background}
\usetikzlibrary{calc}
\usepackage{ifthen}
\usepackage{lipsum}
\usepackage{xcolor}
\pagestyle{plain}
% define custom colors in hex code here:
\definecolor{Thumb1}{HTML}{FB8500}
\definecolor{Thumb2}{HTML}{FD9E02}
\definecolor{Thumb3}{HTML}{FFB703}
\definecolor{Thumb4}{HTML}{817425}
\definecolor{Thumb5}{HTML}{425236}
\definecolor{Thumb6}{HTML}{023047}
\definecolor{Thumb7}{HTML}{219EBC}
\definecolor{Thumb8}{HTML}{58B4D1}
\definecolor{Thumb9}{HTML}{8ECAE6}
% background common settings
\SetBgScale{1}
\SetBgAngle{0}
\SetBgOpacity{1}
\SetBgContents{}
% auxiliary counter
\newcounter{chapshift}
\addtocounter{chapshift}{-1}
% the list of colors to be used (add more if needed)
\newcommand\BoxColor{%
\ifcase\thechapshift Thumb1\or Thumb2\or Thumb3\or Thumb4\or Thumb5\or Thumb6\or Thumb7\or Thumb8\else Thumb9\fi}
% the main command; the mandatory argument sets the color of the vertical box; the value 3.3cm is for A4 document size and 9 chapters, change accordingly (divide document height in cm by total no. of chapters)
\makeatletter
\newcommand\ChapFrame{%
\AddEverypageHook{%
\ifthenelse{\isodd{\thepage}}
{\SetBgContents{%
\begin{tikzpicture}[overlay,remember picture]
\node[fill=\BoxColor,inner sep=0pt,rectangle,text width=1.5cm, % 1.5cm is the width of the box
text height=3.3cm,align=center,anchor=north east]
at ($ (current page.north east) + (-0cm,-3.3*\thechapshift cm) $)
{\rotatebox{90}{\parbox[c][1.5cm][c]{3.3cm}{%
\center\textcolor{white}{\textsf{\scriptsize{\MakeUppercase{\textbf{\leftmark}}}}}}}};
\end{tikzpicture}}%
}
{\SetBgContents{%
\begin{tikzpicture}[overlay,remember picture]
\node[fill=\BoxColor,inner sep=0pt,rectangle,text width=1.5cm, % 1.5cm is the width of the box
text height=3.3cm,align=center,anchor=north west]
at ($ (current page.north west) + (-0cm,-3.3*\thechapshift cm) $)
{\rotatebox{90}{\parbox[c][1.5cm][c]{3.3cm}{%
\center\textcolor{white}{\textsf{\scriptsize{\MakeUppercase{\textbf{\leftmark}}}}}}}};
\end{tikzpicture}}
}
\bg@material}%
\stepcounter{chapshift}
}
\makeatother
% redefinition of \chaptermark to contain only the title
\renewcommand\chaptermark[1]{\markboth{\thechapter.~#1}{}}
\begin{document}
\chapter[intro]{Introduction}
\ChapFrame
\lipsum[1-7]
\chapter{Results}
\ChapFrame
\lipsum[1-7]
\chapter{Discussion}
\ChapFrame
\lipsum[1-7]
\end{document}