Page LayoutMoving box with chapter number on margin

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
bartzmc
Posts: 10
Joined: Thu Apr 06, 2017 9:15 pm

Moving box with chapter number on margin

Post by bartzmc »

Hi,
I need to make some sort of moving shape with chapter number inside which will be moving with scrolling pages on twosided document.
Something like this:
page.jpg
page.jpg (147.34 KiB) Viewed 4082 times
Which package can provide me some help to implement this or it is even possible to do this?

Recommended reading 2024:

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

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

User avatar
Stefan Kottwitz
Site Admin
Posts: 10324
Joined: Mon Mar 10, 2008 9:44 pm

Moving box with chapter number on margin

Post by Stefan Kottwitz »

Welcome to the forum!

This looks like a job for chapterthumbs.

Stefan
LaTeX.org admin
bartzmc
Posts: 10
Joined: Thu Apr 06, 2017 9:15 pm

Moving box with chapter number on margin

Post by bartzmc »

Thanks, it should work but I need more help to adjust some things.
I'm using phd report class and I had to use scrpage2 instead fancyhdr.
This is result: http://i.imgur.com/vB4upJm.jpg
Box is static, does not move with scrolling pages, it shows only 0 in TOC and 1 on every odd page, does not change to 2nd chapter and it is in wrong place on the left from page number. I marked where I want it to be.
Code:

Code: Select all

Code, edit and compile here:
%########################################
\documentclass[a4paper,12pt,twoside,openright]{phd}
\usepackage{sectsty}
\chapterfont{\centering}
\sectionfont{\centering}
\subsectionfont{\centering}
\indexsetup{othercode=\small}
\makeindex[program=makeindex,columns=2,intoc=true,options={-s indeks-styl.ist}]
\makeatletter
\renewcommand{\@seccntformat}[1]{}
\renewcommand{\numberline}[1]{}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Chapter thumbs with scrpage2
%
% 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}%
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
bartzmc
Posts: 10
Joined: Thu Apr 06, 2017 9:15 pm

Moving box with chapter number on margin

Post by bartzmc »

I come up with other solution but it also needs to be modified.
It looks like https://i.imgur.com/Fbtxy2W.jpg
The problem is that chapter thumb does not increment down the page as dictated by the chapters and I want it to be placed where I marked.

Code: Select all

Code, edit and compile here:
\documentclass[a4paper,12pt,twoside,openright]{phd}
\usepackage{sectsty}
\chapterfont{\centering}
\sectionfont{\centering}
\subsectionfont{\centering}
\indexsetup{othercode=\small}
\makeindex[program=makeindex,columns=2,intoc=true,options={-s indeks-styl.ist}]
\makeatletter
\renewcommand{\@seccntformat}[1]{}
\renewcommand{\numberline}[1]{}
%======================================================================================
% CHAPTER THUMB
%======================================================================================
\pagestyle{plain}
% auxiliary counter
\newcounter{chapshift}
\addtocounter{chapshift}{-1}
% the list of colors to be used (add more if needed)
\newcommand\BoxColor{%
%\ifcase\thechapshift blue!30\or red!30\or olive!30\or magenta!30\else yellow!30\fi}
ultramarine}
% redefinition of \chaptermark to contain only the title
\renewcommand\chaptermark[1]{\markboth{\thechapter.~#1}{}}
\makeatletter
\newcommand\ChapterBox{%
\begin{tikzpicture}[overlay,remember picture]
\node[fill=\BoxColor,inner sep=0pt,rectangle,text width=1cm,
text height=4cm,align=center,anchor=north east]
at ($ (current page.north east) + (-0cm,-2*\thechapshift cm) $)
{\rotatebox{90}{\parbox{4cm}{%
\centering\textcolor{white}{\scshape\@chapapp~\thechapter}}}};
\end{tikzpicture}%
}
\makeatother
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Post Reply