Page LayoutPage border colors

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
Txuko
Posts: 16
Joined: Mon Jan 17, 2011 9:17 am

Page border colors

Post by Txuko »

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
Last edited by Txuko on Thu Apr 21, 2011 2:09 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

meho_r
Posts: 823
Joined: Tue Aug 07, 2007 5:28 pm

Page border colors

Post by meho_r »

fancyhdr documentation, section 21.
Txuko
Posts: 16
Joined: Mon Jan 17, 2011 9:17 am

Page border colors

Post by Txuko »

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.

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}

meho_r
Posts: 823
Joined: Tue Aug 07, 2007 5:28 pm

Page border colors

Post by meho_r »

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

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}

Txuko
Posts: 16
Joined: Mon Jan 17, 2011 9:17 am

Re: Page border colors

Post by Txuko »

Good solution. Thanks.
mas
Posts: 226
Joined: Thu Dec 04, 2008 4:39 am

Page border colors

Post by mas »

Even though you have already marked this as solved, have a look at
fancytabs package.

Regards,

OS: Debian/GNU Linux; LaTeX System : TeXLive; Editor : Vim
Post Reply