2

First off: I have literally no experience with LaTeX, so what I am looking for is just a static Layout where I can put my text/pictures into. Sadly I am already failing creating a real layout, since there is so much stuff that you can specify when creating a document.

I want to create a customized layout for my documentation. I imagine the following layout:

       |   
       |
       |
       |
       | 
       |
<3cm>  |                   The usual stuff (Text/Images etc.)
       |
       |
       |
       |
       |

And to the right site I would like to get some kind of navigation bar, so that the reader can see what chapter he currently reads (I would like to manually specify the text of these tabs, so they do not need to match the table of content). Sadly I have no idea how to create that. I imagine the following:

This is what I imagine for the right site. There should not be too much space to the very right

What I found out is that I can specify my page-dimensions with

\pdfpagewidth 8.25in
\pdfpageheight 10.75in

But I am missing the horizontal line to the left (right after the margin) and where/how to access the menu bar to the right.

So I assumed from this site, that the margin-notes might help out for this, but it seems not to be across the full page.

This is my code so far:

\documentclass{article}
\pdfpagewidth 21cm
\pdfpageheight 21cm
\usepackage[
%bindingoffset=0.2in,%
left=3cm,right=0cm,top=3cm,bottom=3cm,%
footskip=.25in]{geometry}

\begin{document}


Some placeholder Text


\end{document}

Which kinda seems to do a part of the formatting for the moment. Now I am still facing the issues of the dashed line and the menu bar. Can anyone give me a hint?

  • Welcome to TeX.SX! – Bobyandbob Jul 1 '18 at 13:26
  • maybe tex.stackexchange.com/questions/48641/… could help – user36296 Jul 1 '18 at 13:33
  • 1
    You should not combine \pdfpagewidth with changing the layout via the geometry package - it has its own method to set the paper size, e.g. papersize={⟨width⟩,⟨height⟩} – user36296 Jul 1 '18 at 13:34
  • Also have a look at the questions listed here: tex.stackexchange.com/questions/linked/48641 – user36296 Jul 1 '18 at 13:42
  • 1
    Do you really want zero margin on the right? Even for electronic documents, that tends to be problematic. For printing, it is definitely problematic on anything but high quality (expensive) and properly calibrated printers. – cfr Jul 1 '18 at 21:40
2

I think that something like this is potentially really useful as for many documents on-screen viewing is becoming the default. Of course, to be really useful, the tabs should not only show that the current chapter, as requested by the OP, but they should also be hyperlinks to the other chapters. The code below produces documents with hyperlnks that look like this:

enter image description here

The bulk of the work is done by tikz. The extra tricks are:

  • the tabs are added to each page using \AddEverypageHook from the everypage package
  • the total number of chapters in the document is stored in the aux file as \numberofchapters, which defaults to 0
  • every chapter is automatically given a label (chapter1, chapter2, ...), in the aux file so that hyperref can create a link to it
  • I found that I had to use \rotatebox from graphicx because rotating the text in a tikz \node did not rotate the hyperlink
  • Using tikzpagenodes, the first chapter tab is in line with the bottom of the page header

Ideally details such as the distance of this menu-bar to the margin, the rotation angle and the choice of colours etc should be handled by some nice interface. Some, but not all, of these details are easy to change using the tikz styles at the top of the code. If there are a lot of chapters the tabs will go off the bottom of the page so this will not work so well. One way around this would be to have an option for displaying only the chapter numbers. One could imagine doing this with sections as well...

Here is the code:

\documentclass[svgnames]{book}
\usepackage[
    a4paper,
    left=3cm,
    right=0cm,
    top=3cm,
    bottom=3cm,
    footskip=.25in
]{geometry}

\usepackage{etoolbox}
\usepackage{everypage}
\usepackage{graphicx}
\usepackage{tikz}
\usepackage{tikzpagenodes}

\usepackage{hyperref}
\hypersetup{
  colorlinks = false,%
  linkbordercolor = LightSkyBlue
}

% define some tikz styles to control the chapter tabs
\usetikzlibrary{calc}
\tikzset{
  chaptertab/.style = {
    rectangle,
    anchor = north west,
    rounded corners,
    draw=DodgerBlue,
    line width=1mm,
    fill=LightSkyBlue,
    text=NavyBlue,
    %rotate=270,
    inner sep=1mm,
    minimum height=24mm,
    minimum width=10mm,
    font=\bfseries
  },
  current chapter/.style={
    text=red
  },
  menu background/.style = {
     fill=LightSteelBlue
  }
}

% we keep track of the total number of chapters in the aux file. By
% default this is 0
\providecommand\numberofchapters{0}
\makeatletter
\AtEndDocument{
   \write\@auxout{\string\gdef\string\numberofchapters{\arabic{chapter}}}
}
\makeatother

% the chapter tabs are added to each page using the following command
\newcommand\addchaptertabs{%
  \begin{tikzpicture}[remember picture, overlay]
    \draw[menu background](current page.north west) rectangle ($ (current page.south west)+(1.2,0) $);
    \foreach \chap [evaluate=\chap as \offset using {2.4*(1-\chap)}] in {1,...,\numberofchapters} {
       \ifnum\value{chapter}=\chap
          \def\chapterextra{current chapter}
       \else
          \def\chapterextra{}
       \fi
       \node[chaptertab,\chapterextra] (chapter\chap) at
          ($ (current page.north west|-current page header area.south west)+(0,\offset) $)
          {\rotatebox{-270}{\hyperref[chapter\chap]{Chapter \chap}}};
     }
  \end{tikzpicture}%
}

% create a label (and hence a hyperlink) to each to chapter
\appto\chapter{\relax\label{chapter\arabic{chapter}}}

\AddEverypageHook{\addchaptertabs}

\begin{document}

  \chapter{One}
  \chapter{Two}
  \chapter{Three}

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.