1

I would like to make tikz box with a letter (thumb index) longer (stretch it over the cropping edge), but I need to leave the position of the letter and placement of the box untouched.

Creation of the original box can be found in this answer.

Updated: working MWE included. MWE bellow illustrates A4 papersize, C5 layout. Currently thumb index is anchored to the edge of the paper, so that it is placed out of the printing area (C5). I need to placed the thumb to the original position (at the edge of the printing area), while ensure that the letter is correctly positioned and thumb indexed stretches over the edge. Original width of the thumbs is 0.5 cm and letter is centered inside.

enter image description here

\documentclass[8pt, a4paper, twoside, openright]{extbook}
\usepackage{geometry}
\geometry
{ headsep    =   \baselineskip
, textwidth  = 42\baselineskip
, textheight = 60\baselineskip
, hmarginratio = 2:3
, vmarginratio = 2:3
, bindingoffset = 0cm
, onecolumn
, layout=c5paper,
, layouthoffset=\dimexpr(\paperwidth-\csname Gm@layoutwidth\endcsname)/2\relax
, layoutvoffset = 2cm
, showcrop
}

\usepackage[icelandic, latin, czech]{babel}
\usepackage{csquotes}
\usepackage{lipsum}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{tgpagella}
\usepackage[scaled=0.88]{helvet}      % relative scale of the two fonts
\def\phvfamily{\fontfamily{phv}\selectfont}

% \normalsize should be {8pt}{9.6pt}
\def\HUGE {\fontsize{23.887872pt}{3\baselineskip}\selectfont}
\def\Huge {\fontsize{19.906560pt}{3\baselineskip}\selectfont}
\def\huge {\fontsize{16.588800pt}{3\baselineskip}\selectfont}
\def\LARGE{\fontsize{13.824000pt}{2\baselineskip}\selectfont}
\def\Large{\fontsize{11.520000pt}{2\baselineskip}\selectfont}
\def\large{\fontsize{ 9.600000pt}{2\baselineskip}\selectfont}

% Two columns layout ruler
\setlength\columnsep    {2\baselineskip}
\setlength\columnseprule{0.4pt}

% Necessary for baseline alignment
\topskip=\baselineskip
\raggedbottom
\setlength\parskip{0pt} % it's better to avoid glue


% ######################################################### ASSORTED PACKAGES #

\usepackage{tikz}
\usetikzlibrary{calc}

% ############################################################ BASELINE GRID #

\usepackage{eso-pic}
\usepackage{tikzpagenodes}

% Command to draw a baseline grid
\newcommand\drawbaselinegrid{%
  \begin{tikzpicture}[overlay,remember picture]
    \draw [red!30!white, ultra thin, dashed]
      (0,0) grid [ ystep  = \baselineskip, xstep = \textwidth
                 , shift  = (current page text area.north west)
                 , yshift = -\dp\strutbox
                 ] ++(\textwidth,-\textheight);
    \draw [red!30!white, thin]
      (0,0) grid [ step = \baselineskip, xstep = \textwidth
                 , shift=(current page text area.north)
                 ] ++(0.5\textwidth,-\textheight)
      (0,0) grid [ step = \baselineskip, xstep = \textwidth
                 , shift=(current page text area.north)
                 ] ++(-0.5\textwidth,-\textheight);
    \draw[black!10!white]
      (current page text area.north west)
        rectangle (current page text area.south east);
  \end{tikzpicture}}

% Draw a baseline grid on every page
\AddToShipoutPicture{\drawbaselinegrid}


% ############################################################### PAGE STYLES #

\usepackage{fancyhdr}

% -------------------------------------- BASIC PAGE STYLE
\fancypagestyle{plain}{
  \fancyhf\relax                       % Clear header/footer
  \renewcommand \headrulewidth {0.0pt} % No header rule
  \renewcommand \footrulewidth {0.0pt} % No footer rule
  \fancyfoot[C]{\thepage}              % Page number in footer, centred
}

% -------------------------------------- DICTIONARY PAGE STYLE
\fancypagestyle{myheadings}{
  \fancyhf\relax                       % Clear header/footer
  \renewcommand \headrulewidth {0.4pt} % Thin header rule
  \fancyhead[CO,CE]{\thepage}          % Page number in header, centred
  % NOTE: the page numbers will be printed when the dictionary is ready
  \fancyhead[LE,LO]{\phvfamily\bfseries\rightmark}
  \fancyhead[RE,RO]{\phvfamily\bfseries\leftmark}
}

\pagestyle{plain}  

% #################################################################### COLORS #

\usepackage{color}
\definecolor {darkgreen}          {rgb} {0.40, 0.01, 0.24}

% COLORS FOR THUMB INDEXES
\definecolor {color1}             {RGB} { 182,   86,    0}
\definecolor {color2}             {RGB} { 143,    9,    6}
\definecolor {color3}             {RGB} {   3,   23,  118}
\definecolor {color4}             {RGB} {   0,   82,  168}
\definecolor {color5}             {RGB} {   0,   85,  142}

% ############################################################# THUMB INDEXES #

\newcommand\BoxColor[1]{%
\ifcase#1 darkgreen!30\or color1\or color2\or color3\or color4\or color5\fi}

% THUMB INDEXES
% new counter to hold the current number of the letter to determine the vertical position
\newcounter{letternum}
% newcounter for the sum of all letters to get the right height of a box
\newcounter{lettersum}
\setcounter{lettersum}{34}
% some margin settings
\newlength{\thumbtopmargin}
\setlength{\thumbtopmargin}{3cm} %1cm
\newlength{\thumbbottommargin}
\setlength{\thumbbottommargin}{6cm} %2.5cm
% calculate the box height by dividing the page height
\newlength{\thumbheight}
\pgfmathsetlength{\thumbheight}{%
(\paperheight-\thumbtopmargin-\thumbbottommargin)%
/%
\value{lettersum}
}
% box width
\newlength{\thumbwidth}
\setlength{\thumbwidth}{2cm} %0.5cm
% style the boxes
\tikzset{
thumb/.style={
   text=white,
   minimum height=\thumbheight,
   text width=\thumbwidth,
   outer sep=0pt,
   font=\sffamily\bfseries,
 }
 }

\def\thumbnew{}
\def\thumbold{}
\usepackage{everypage}
\AddEverypageHook{\if\relax\thumbnew\relax\xdef\thumbnew{\thumbold}\fi}

\def\ethumbs#1,#2\relax{\if\relax#1\relax\else\eventhumb{#1}\fi%
                        \if\relax#2\relax\else\ethumbs#2\relax\fi%
                        \gdef\thumbnew{}%
                        \gdef\thumbold{#1,}%
}

\def\othumbs#1,#2\relax{\if\relax#1\relax\else\oddthumb{#1}\fi%
                        \if\relax#2\relax\else\othumbs#2\relax\fi%
                        \gdef\thumbold{#1,}%
                        \gdef\thumbnew{}%
}

\newcommand{\drawthumb}[2]{%
  % see pgfmanual.pdf for more information about this part
  \begin{tikzpicture}[remember picture, overlay]
    \node [thumb, fill=\BoxColor{#1}, text centered, anchor=north #2]
       at ($(current page.north #2)-%
%            (0,\thumbtopmargin+\value{letternum}*\thumbheight)%
            (0,\thumbtopmargin+#1*\thumbheight)$) {\csname Let#1\endcsname};
   \end{tikzpicture}}

% I had to exchange the east/west anchors of the thumbs
% because they were being drawn flipped. I don't know why.
\newcommand{\oddthumb} [1]{\drawthumb{#1}{west}}
\newcommand{\eventhumb}[1]{\drawthumb{#1}{east}}

% create a new command to set a new lettergroup with thumb indexes
\newcommand{\lettergroup}[1]{%
  % step the counter of the letters
  \refstepcounter{letternum}%
  \expandafter\gdef\csname Let\theletternum\endcsname{#1}%
  \xdef\thumbnew{\theletternum,\thumbnew}%
  \fancyhead[LO]{\phvfamily\bfseries\rightmark%
    \expandafter\ethumbs\thumbnew\relax\relax\relax}%
  \fancyhead[RE]{\phvfamily\bfseries\leftmark%
    \expandafter\othumbs\thumbnew\relax\relax\relax}%
}

% #################################################### ASSORTED CUSTOM MACROS #

\def\textIS#1{\foreignlanguage{icelandic}{#1}}
\def\textCS#1{\foreignlanguage{czech}{#1}}
\def\textLA#1{\foreignlanguage{latin}{#1}}

\usepackage{pgffor}

\newcommand\blspace[1][1]{\vspace{#1\baselineskip}}

\usepackage{placeins}

\newcommand*{\dicLetter}[2]{%
  \FloatBarrier\newpage\phantomsection\pdfbookmark[1]{#1}{#2}%
  \noindent\parbox[b][9\baselineskip][c]{\columnwidth}
    {\centering\HUGE\strut\smash{\MakeUppercase{#1}~\MakeLowercase{#1}}}%
      %\par\xdef\tpd{\the\prevdepth}
      %\par\prevdepth\tpd%
  \expandafter\lettergroup{\MakeLowercase{#1}}}

% ###################################################### HYPERREF & PDF INFO #
\usepackage[pdftex, unicode, hyperfootnotes=false]{hyperref}

\begin{document}
\dicLetter{a}{letter1}
\lipsum[1-2]
\clearpage
\dicLetter{b}{letter2}
\lipsum[1-2]
\clearpage
\dicLetter{c}{letter3}
\lipsum[1-2]
\clearpage
\dicLetter{d}{letter4}
\lipsum[1-2]
\clearpage
\dicLetter{e}{letter5}
\lipsum[1-2]
\end{document}
chejnik
  • 1,441
  • 2
  • 23
  • 42
  • 4
    Much better if you made a complete example instead. – Torbjørn T. Nov 25 '15 at 08:34
  • I have added MWE as requested. – chejnik Nov 26 '15 at 07:43
  • Defining the \thumbwidth by setting \setlength{\thumbwidth}{\dimexpr(\csname Gm@layouthoffset\endcsname)+0.5cm} creates a box that stretches from the border of the paper across the cutting edge to 0.5 cm to the printed layout area. It remains to solve how to place the letter correctly. – chejnik Nov 26 '15 at 15:21
  • Without having looked at this in detail, will adding \hspace{\dimexpr(\csname Gm@layouthoffset\endcsname)/2} at the start of the node label for the thumbs be what you need? – Torbjørn T. Nov 26 '15 at 15:53

1 Answers1

0

The problem was solved by Paulo Brasolin. I repost the correct answer. I hope it might help other users in the future.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newcounter{letternum}
\newcounter{lettersum}                 \setcounter{lettersum}{34}
% these margins separate top thumb from top of page and last thumb from
% bottom of page. BEWARE, it's from top of the (cut out) page, not the folio!
\newlength{\thumbtopmargin}            \setlength{\thumbtopmargin}{1cm}
\newlength{\thumbbottommargin}         \setlength{\thumbbottommargin}{1cm}
\newlength{\thumbwidth}                \setlength{\thumbwidth}{2.20cm}
\newlength{\thumbheight}
\pgfmathsetlength{\thumbheight}%
  {(\csname Gm@layoutheight\endcsname-\thumbtopmargin-\thumbbottommargin)/\value{lettersum}}
% inner xsep of letter from box margin
\newlength{\thumbsep}                  \setlength{\thumbsep}{.30cm}
% overlap over cutting line
\newlength{\thumboverlap}              \setlength{\thumboverlap}{3cm}

\tikzset{
  thumb/.style={
    text=white,
    outer sep=0pt,
    inner xsep=\thumbsep,
    minimum height=\thumbheight,
    text width=\thumbwidth-2\thumbsep,
    font=\sffamily\bfseries,},
  thumb east/.style={thumb,
    xshift=\dimexpr(+\thumboverlap-\paperwidth+\csname Gm@layoutwidth\endcsname)/2\relax,
    align=left,anchor=north east,},
  thumb west/.style={thumb,
    xshift=\dimexpr(-\thumboverlap+\paperwidth-\csname Gm@layoutwidth\endcsname)/2\relax,
    align=right,anchor=north west,},
}

\def\thumbnew{}
\def\thumbold{}
\usepackage{everypage}
\AddEverypageHook{\if\relax\thumbnew\relax\xdef\thumbnew{\thumbold}\fi}

\def\ethumbs#1,#2\relax%
  {\if\relax#1\relax\else\eventhumb{#1}\fi%
   \if\relax#2\relax\else\ethumbs#2\relax\fi%
   \gdef\thumbnew{}%
   \gdef\thumbold{#1,}}

\def\othumbs#1,#2\relax%
  {\if\relax#1\relax\else\oddthumb{#1}\fi%
   \if\relax#2\relax\else\othumbs#2\relax\fi%
   \gdef\thumbold{#1,}%
   \gdef\thumbnew{}}

\newcommand{\drawthumb}[2]{%
  \begin{tikzpicture}[remember picture, overlay]
    \node [thumb #2, fill=\BoxColor{#1}]
       at ($(current page.north #2)-%
            (0,\csname Gm@layoutvoffset\endcsname+\thumbtopmargin-\thumbheight+%
               #1*\thumbheight)$) {\csname Let#1\endcsname};
   \end{tikzpicture}}

\newcommand{\oddthumb} [1]{\drawthumb{#1}{west}}
\newcommand{\eventhumb}[1]{\drawthumb{#1}{east}}

\newcommand{\lettergroup}[1]%
  {\refstepcounter{letternum}%
   \expandafter\gdef\csname Let\theletternum\endcsname{#1}%
   \xdef\thumbnew{\theletternum,\thumbnew}%
   \fancyhead[LO]{\phvfamily\bfseries\rightmark%
     \expandafter\ethumbs\thumbnew\relax\relax\relax}%
   \fancyhead[RE]{\phvfamily\bfseries\leftmark%
     \expandafter\othumbs\thumbnew\relax\relax\relax}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
chejnik
  • 1,441
  • 2
  • 23
  • 42