GeneralExample for chapter thumbs with KOMA Script

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
NinV
Posts: 69
Joined: Sun Oct 05, 2008 12:57 pm

Example for chapter thumbs with KOMA Script

Post by NinV »

Hi, all.

I'm trying to use this code for thumb indexes in KOMA Script, because I'm using the KOMA Script scrbook.

The result is someway weird. The thumbs show only the bottom half of the chapter numbers and the tags

Code: Select all

<b></b>
, furthermore the thumbs are on every even page.
manuale.jpg
manuale.jpg (41.16 KiB) Viewed 5670 times
Can someone help me? I add a minimal example with the complete preamble, because I suppose some package incompatibility which I wasn't able to find out.
prova3.tex
(8.4 KiB) Downloaded 425 times
I beg your pardon for asking help about KOMA Script, but I sent this message to komascript.de but the answer I got was an inexplicably locking of my account!

Thanks a lot,
Nino
Window + MiKTeX 2.7
Ubuntu + TexLive + Kile
Xandros (eeePC) + TeTex + TexMaker

Recommended reading 2024:

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

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

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Example for chapter thumbs with KOMA Script

Post by gmedina »

Hi, Nino

to solve the thumbs issue, remove the line

Code: Select all

<b>\\</b>
from this part of your code

Code: Select all

         \rotatebox{90}{\colorbox{\chapterthumbboxcolor}%
          {%
           \parbox[c][\chapterthumbheight][c]{\chapterthumbwidth}%
           {%
            \centering
            \textcolor{\chapterthumbtextcolor}{%
             \strut\thechapter}
             <b>\\</b>
           }%
          }%
        }%
When I compiled your code (using pdflatex and latex) I received the following error:

Code: Select all

! LaTeX Error: Command \I already defined.
               Or name \end... illegal, see p.192 of the manual.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.136 \newcommand{\I}{\COOL@notation@ISymb}
removing arabic from the options to the babel package and commenting out the line

Code: Select all

\DeclareFixedFont{\tr}{LAE}{cmr}{m}{n}{4mm}
solved the problem, so there's an issue there. However, I don't have time right now to figure out the real cause of the error, so that you can still be able to use the arabic option. Perhaps someone else will be able to help you with this issue.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
NinV
Posts: 69
Joined: Sun Oct 05, 2008 12:57 pm

Example for chapter thumbs with KOMA Script

Post by NinV »

Thanks again, gmedina!

I discovered that solution, too. But I don't understand why the authors put those

Code: Select all

<b> // </b>
, what were they for?

As for the arabic option of the babel package, I need it because I have to write some arabic words in my document. Is there an alternative?

Ciao,
Nino
Window + MiKTeX 2.7
Ubuntu + TexLive + Kile
Xandros (eeePC) + TeTex + TexMaker
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Example for chapter thumbs with KOMA Script

Post by localghost »

I guess this has to be a mistake of the author because to me <b> and </b> look like HTML tags to get the stuff between them in bold face. I'm almost sure that you can neglect that. But you should keep the \\ command for a line break. The code below works fine for me.

Code: Select all

\documentclass[english]{scrbook}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{scrpage2}
\usepackage{graphicx}
\usepackage{xcolor}
\usepackage{blindtext}

\makeatletter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%  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}%
    \addtolength{\@tempdima}{\paperwidth}%
    \addtolength{\@tempdima}{-\oddsidemargin}%
    \addtolength{\@tempdima}{-1in}%
    % putting the thumbs should not change the horizontal
    % possition
    \rlap{%
      % move to the calculated horizontal possition
      \hspace*{\@tempdima}%
      % putting the thumbs should not change the vertical
      % possition
      \vbox to 0pt{%
        % calculate the vertical possition of the thumbs (I ignore
        % \voffset for the same reasons told above)
        \setlength{\@tempdima}{\chapterthumbwidth}%
        \multiply\@tempdima by\value{chapter}%
        \addtolength{\@tempdima}{-\chapterthumbwidth}%
        \addtolength{\@tempdima}{-\baselineskip}%
        % move to the calculated vertical possition
        \vspace*{\@tempdima}%
        % put the thumbs left so the current horizontal possition
        \llap{%
          % and rotate them
          \rotatebox{90}{\colorbox{\chapterthumbboxcolor}{%
              \parbox[c][\chapterthumbheight][c]{\chapterthumbwidth}{%
                \centering
                \textcolor{\chapterthumbtextcolor}{%
                  \strut\thechapter}\\
              }%
            }%
          }%
        }%
        % avoid overfull \vbox messages
        \vss
      }%
    }%
  \endgroup
}
 
% New command, which works like \lohead but also puts the thumbs (you
% cannot use \ihead with this definition but you may change this, if
% you use more internal scrpage2 commands)
\newcommand*{\loheadwithchapterthumbs}[2][]{%
  \lohead[\putchapterthumb#1]{\putchapterthumb#2}%
}
 
% initial use
\loheadwithchapterthumbs{}
\pagestyle{scrheadings}
 
}
%
%  End of chapter thumbs with scrpage2
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\makeatother

\begin{document}
  \blinddocument
\end{document}

Best regards
Thorsten
NinV
Posts: 69
Joined: Sun Oct 05, 2008 12:57 pm

Re: Example for chapter thumbs with KOMA Script

Post by NinV »

Thank you, Thorsten.

Anyway it works fine for me even without "//".

Ciao,
Nino
Window + MiKTeX 2.7
Ubuntu + TexLive + Kile
Xandros (eeePC) + TeTex + TexMaker
Post Reply