I want to put color marks in the border of each page with a color and a position for each chapter. This allows to move easily to any chapter by watching the edge of the book.
How can I do that?
Thanks
Page Layout ⇒ Page border colors
Page border colors
Last edited by Txuko on Thu Apr 21, 2011 2:09 pm, edited 1 time in total.
NEW: TikZ book now 40% off at Amazon.com for a short time.
Page border colors
fancyhdr documentation, section 21.
Page border colors
Thanks.
Now I can make an index and put marks in different possitions for each chapter but I don't know how to use different colors for the marks. They are all black.
Now I can make an index and put marks in different possitions for each chapter but I don't know how to use different colors for the marks. They are all black.
Code: Select all
\documentclass[a4paper]{book}
\setlength{\unitlength}{18mm}
\newcommand{\blob}{\rule[-.2\unitlength]{.5\unitlength}{.5\unitlength}}
\newcommand\rblob{\thepage
\begin{picture}(0,0)
\put(1,-\value{chapter}){\blob}
\end{picture}}
\newcommand\lblob{%
\begin{picture}(0,0)
\put(-3,-\value{chapter}){\blob}
\end{picture}%
\thepage}
\usepackage{fancyhdr}
\pagestyle{fancy}
\cfoot{}
\newcounter{line}
\newcommand{\secname}[1]{\addtocounter{line}{1}%
\put(1,-\value{line}){\blob}
\put(-7.5,-\value{line}){\Large \arabic{line}}
\put(-7,-\value{line}){\Large #1}}
\newcommand{\overview}{\thepage
\begin{picture}(0,0)
\secname{Introduction}
\secname{The first year}
\secname{Specialisation}
\end{picture}}
\begin{document}
\fancyhead[R]{\overview}\mbox{}\newpage % This produces the overview page
\fancyhead[R]{} % Front matter may follow here
\clearpage
\chapter{Introduction}
\fancyhead[RE]{\rightmark}
\fancyhead[RO]{\rblob}
\fancyhead[LE]{\lblob}
\fancyhead[LO]{{\leftmark}}
Text
\chapter{The first year}
Text
\chapter{Specialisation}
Text
\end{document}
Page border colors
OK, here's a manual approach, i.e., you'll have to specify colors which will be used in your document and change them manually for each chapter using a custom command. If you don't have a hundred of chapters, this shouldn't be a painful endeavor
Of course, if some TeXpert would be so kind to show us how to do this automatically, please, go ahead.
There are only small changes to your original MWE (and thanks for providing it, makes things a lot easier):
1. added first couple of lines for color definitions,
2. line 34, added #1 argument to change blob color in the overview page
3. lines 40–42, specified different colors as optional arguments for different chapters
4. the custom \blobcolor command used after every \chapter command to change blob color

There are only small changes to your original MWE (and thanks for providing it, makes things a lot easier):
1. added first couple of lines for color definitions,
2. line 34, added #1 argument to change blob color in the overview page
3. lines 40–42, specified different colors as optional arguments for different chapters
4. the custom \blobcolor command used after every \chapter command to change blob color
Code: Select all
\documentclass[a4paper]{book}
\usepackage{xcolor}
\newcommand{\colori}{\color{red}}
\newcommand{\colorii}{\color{green}}
\newcommand{\coloriii}{\color{magenta}}
\newcommand{\blobcolor}[1]{% To change blob color for chapters
\renewcommand{\blob}{#1\rule[-.2\unitlength]{.5\unitlength}{.5\unitlength}}
}
\setlength{\unitlength}{18mm}
\newcommand{\blob}{\rule[-.2\unitlength]{.5\unitlength}{.5\unitlength}}
\newcommand\rblob{\thepage
\begin{picture}(0,0)
\put(1,-\value{chapter}){\blob}
\end{picture}}
\newcommand\lblob{%
\begin{picture}(0,0)
\put(-3,-\value{chapter}){\blob}
\end{picture}%
\thepage}
\usepackage{fancyhdr}
\pagestyle{fancy}
\cfoot{}
\newcounter{line}
\newcommand{\secname}[2][\color{black}]{\addtocounter{line}{1}%
\put(1,-\value{line}){#1\blob}% #1 here is to change blob color in the overview page
\put(-7.5,-\value{line}){\Large \arabic{line}}
\put(-7,-\value{line}){\Large #2}}
\newcommand{\overview}{\thepage
\begin{picture}(0,0)
\secname[\colori]{Introduction}
\secname[\colorii]{The first year}
\secname[\coloriii]{Specialisation}
\end{picture}}
\begin{document}
\fancyhead[R]{\overview}\mbox{}\newpage % This produces the overview page
\fancyhead[R]{} % Front matter may follow here
\clearpage
\chapter{Introduction}
\blobcolor{\colori}
\fancyhead[RE]{\rightmark}
\fancyhead[RO]{\rblob}
\fancyhead[LE]{\lblob}
\fancyhead[LO]{{\leftmark}}
Text
\chapter{The first year}
\blobcolor{\colorii}
Text
\chapter{Specialisation}
\blobcolor{\coloriii}
Text
\end{document}
Page border colors
OS: Debian/GNU Linux; LaTeX System : TeXLive; Editor : Vim