1

Another user asked asked a similar question; yet I just need the top header and not the full design from edp. And I provide a minimal working example.

This is how it should look like:

Edp LaTeX deisgn header.

If you press one of the upper header boxes, they will redirect you to the right chapter. I thought it was really nice, so I wanted it for private purpose. Yet I have trouble with recreating the effect.

Here is what I tried with tikz:

\documentclass{book}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{lipsum}
\pagestyle{empty}


\begin{document}

\begin{tikzpicture}[overlay, remember picture]
\foreach \x in {1,...,7};
\draw let \p1 = (current page.west), \p2 = (current page.east) in node[minimum width=\x2-\x1, minimum height=2cm, draw, rectangle, fill=black!90, anchor=north west, align=left, text width=\x2-\x1] at ($(current page.north west)$) {\Large\bfseries \quad #1};
\end{tikzpicture}


\chapter{Chapter one}
\end{document}

Well, it creates a big black box in the header with no text in it. So it doesn't work at all. I thought of using the \foreach function, but had trouble with it.

Basically I need help with creating the boxes at the top and I have problems with letting them redirect to the chapter.

Hopefully you can help me?

  • You have fill=black!90 so you create a line of almost completely black rectangles. – cfr Mar 26 '16 at 20:09
  • 1
    Your code does not compile for me. Don't you get an error rather than black boxes? – cfr Mar 26 '16 at 20:14
  • here an idea http://tex.stackexchange.com/questions/298006/table-of-contents-navigation-sidebar-in-non-beamer-document-classes/298194#298194 – touhami Mar 26 '16 at 20:30
  • I am no TikZ expert, but what's the replacement for #1 here? Something from the \foreach loop? –  Mar 26 '16 at 20:45

2 Answers2

5

Here's a tcolorbox version with automatic linking to the chapters. Since tcolorbox is TikZ package much additions can be done to those boxes with over- or underlays.

\documentclass{book}
\usepackage[lmargin=1.5cm,rmargin=1.5cm,headheight=1.5cm]{geometry}
\usepackage{tikz}
\usepackage[most]{tcolorbox}
\usetikzlibrary{calc}
\usepackage{lipsum}
\pagestyle{empty}

\usepackage{totcount}

\usepackage{fancyhdr}

\usepackage[hidelinks]{hyperref}


\newtcolorbox{mycolorboxinternal}[1][]{%
  enhanced jigsaw,
  sharp corners,
  boxrule=0.0pt,
  boxsep=0pt,
  colupper={white},
  fontupper={\bfseries},
  equal height group=headerboxes,
  colback=orange,
  halign=center,
  valign=center,
  nobeforeafter,
  height=0.8cm,
  #1,
}


\newcommand{\mycolorbox}[2][]{%
  \begin{mycolorboxinternal}[#1]%
    #2%
  \end{mycolorboxinternal}%
}

\regtotcounter{chapter}

\rhead{}
\lhead{}
\chead{%
\begin{tcbraster}[%raster valign=center,
  raster row skip=0pt,
  raster before skip=0pt,
  raster columns={5}, 
  raster equal height=all, 
  raster equal height group=headerboxes,
  raster column skip=0pt,
  nobeforeafter,
  raster left skip=0pt, 
  raster right skip=0pt]
  \foreach \x in {1,...,\totvalue{chapter}} {%
    \ifodd\x 
    \def\backgroundcolor{orange}%
    \else
    \def\backgroundcolor{red}%
    \fi
    \mycolorbox[colback=\backgroundcolor]{\protect\nameref{chaplabel:\x}}%
  }
\end{tcbraster}
}


\pagestyle{fancy}
\usepackage{blindtext}
\begin{document}

\chapter{Kirche}\label{chaplabel:1}
\chapter{Soziales}\label{chaplabel:2}
\chapter{Gesellschaft}\label{chaplabel:3}
\chapter{Umwelt}\label{chaplabel:4}
\chapter{Kultur}\label{chaplabel:5}
\chapter{Entwicklung}\label{chaplabel:6}
\chapter{Ausland}\label{chaplabel:7}

\newpage
\blindtext[5]
\end{document}

enter image description here

3

This draws the tabs at the top and inserts the chapter numbers using LaTeX's \label/\ref system. In my opinion, that is quite enough for one question and hyperlinking is left as an exercise for the reader.

In other words, I can make TikZ do some stuff, but I can't make hyperref behave when it doesn't want to and it didn't want to.

However, there really is more than one question here, so I think it is worth answering one of the questions even if I cannot answer the other.

tabs

\documentclass{book}
\usepackage{tikz,calc}
\pagestyle{empty}
\begin{document}
\newlength\tabwidth
\setlength\tabwidth{\paperwidth/7}%
\begin{tikzpicture}[overlay, remember picture]
  \path [fill=red] (current page.north west) rectangle +(\paperwidth,-20mm);
  \path (current page.north west) foreach \i [evaluate=\i as \j using {25*(mod(\i,2)}] in {1,...,7} {%
    +({(\i-1)*\tabwidth},0) node [minimum width=\tabwidth, minimum height=2cm, rectangle, fill=white!\j!red, font=\Large\bfseries, text=white, anchor=north west] {\ref{ch:\i}}
  };
\end{tikzpicture}
\chapter{Chapter one}\label{ch:1}
\chapter{2}\label{ch:2}
\chapter{3}\label{ch:3}
\chapter{4}\label{ch:4}
\chapter{5}\label{ch:5}
\chapter{6}\label{ch:6}
\chapter{7}\label{ch:7}
\end{document}
cfr
  • 198,882
  • Thank your for your answer, but I get a lotof errors: like missing semicolon, number and illegal unit. – Amabile Scientius Mar 26 '16 at 21:13
  • @AmabileScientius All I can say is that it works for me and I do not get errors. Do you get errors when you copy just my code into a new, empty .tex file and compile that? If so, precisely which error? The first error is the important one. Most of the others are probably consequences of the first and, if any aren't, you can't tell which until you've fixed the first. – cfr Mar 26 '16 at 21:19
  • 2
    @AmabileScientius: This works for me out of the box! Maybe you need to update your TeX distribution –  Mar 26 '16 at 21:35
  • it's not good idea to hundle labels this way, you can think for some thing that does this automatic – touhami Mar 27 '16 at 14:03
  • @touhami I just meant it to demonstrate the TikZ part i.e. drawing the tabs. as I said, it doesn't address the linking part of the question so the content of the tabs is only intended for demonstration purposes. If the question were just getting the content into the tabs, I would have worked on a way to automatise it. But since that would still leave the linking question, I assume it would be better to address the content along with the linking. – cfr Mar 27 '16 at 14:41
  • ok, my bad, i am sorry – touhami Mar 27 '16 at 15:15
  • @touhami Not bad. I just don't understand hyperref that well and my attempt to use it at all threw errors everywhere, so I decided I'd just post on the TikZ-bit and maybe somebody else would address the linking bit. Really, I think there are 2 questions here and I can't answer the other one! – cfr Mar 27 '16 at 21:44
  • your code works fine if you add \usepackage{hyperref}. my point is that one need to patch chapter so that labels are auto add. – touhami Mar 27 '16 at 21:59
  • @touhami Re. patching: Yes, I know. Re. hyperref: Strange. My code didn't work for me when I did that. – cfr Mar 27 '16 at 22:16
  • try it https://www.overleaf.com/ – touhami Mar 27 '16 at 22:46