16

I am trying to recreate in *TeX the same aspect that you can see in the following picture showing a document that I created a while ago with MS Publisher.

Desired layout

As you can see, page numbers are rendered with a custom font, as well as headers that only display tilted chapter names (on one side for odd pages, and on the other side for even pages). Both are positioned in the page border rather than in the usual position (typically the external header and footer of the page).

If possible, I would like to use the least number of packages: so far I have introduced KOMA script, fontspec and xcolor. If these packages do not allow to get the desired result, I would accept any package that gets the work done, but I would still like to use the the least number of packages. In that case, which are the best packages to use? Unfortunately, I have no clue about how to do it... could you provide some examples please? I guess tikz will be used, but is it possible to avoid to use fancyhdr (with whom I am really not familiar)?

In addition, I would like to understand how to insert logo on the top external corners, the external page borders, the internal page border, and the chapter openings into the *TeX sources. I am trying to recreate those elements with tikz but, again, I do not know how to include them in the relevant parts of the page.

I would add a minimal work example to start you with, but at the moment I do not have my sources at hand, sorry. I will possibly attach them in a second time, thanks for the understanding.

9
  • 1
    At least it's easy to avoid fancyhdr: KOMA-Script has it's own scrpage2 package if needed. If that helps with respect to familiarity is another question... :)
    – cgnieder
    Jan 18, 2013 at 23:30
  • Thanks again cgnieder! I'll have a look to it with fresh energies and I'll let you know if I managed to get the above result. Cheers! Jan 19, 2013 at 0:03
  • 1
    I agree with you that TikZ is the right way to go and, to place elements in the page you might want to have a look to the packages tikzpagenodes and background. An example in which they are used together to set different colored rules in the margin of the page is How to set colored ruled margins for different pages?. Jan 19, 2013 at 7:47
  • Ciao Claudio, thanks for pointing me out these packages... I'll definitely give them a look! Cheers! Jan 19, 2013 at 10:08
  • @StefanoBragaglia if you want people to notice that you've answerwed them add a @ in front of the user name: they get notified then.
    – cgnieder
    Jan 19, 2013 at 15:18

1 Answer 1

23

I have something that might get you started. It has still many open construction zones, though... This is how it looks:

enter image description here

It uses – as you've suspected – TikZ to draw the boxes, fill the page with gray, draw the lines… The idea is to put a tikz picture with options remember picture, overlay in the heading (with commands provided by KOMA's scrpage2) and use TikZ's current page node to position them.

To get the first page of a chapter with the gray background and only the second of two columns I'm going to use etoolbox to patch the internals of \chapter.

The start is pretty standard. We're going to use geometry for the layout instead of KOMA's typearea as it is easier to choose definite values for margins with it:

\documentclass[twocolumn]{scrbook}
\usepackage{fontspec}
\setmainfont{Linux Biolinum O}

\usepackage{polyglossia}
\setmainlanguage{italian}
% -------------------------------------------------
% page layout:
\setlength\parindent{15pt}

\usepackage[a4paper]{geometry}
\newlength\imargin
\newlength\omargin
\setlength\imargin{.7in}
\setlength\omargin{.7in}
\geometry{
  inner  = \imargin ,
  outer  = \omargin ,
  top    = 1in ,
  bottom = .7in
}

% -------------------------------------------------
% colors:
\usepackage{tikz,xcolor}
\usetikzlibrary{positioning}
\definecolor{darkred}{cmyk}{0.0,0.87,0.87,0.50}
\colorlet{mygray}{black!20}

The next part now uses scrpage2 and tikz for the header and footer. The first thing is to choose a page style, make sure that chapter pages use it, too, and clear it. Then I set up some TikZ styles which then are used when the TikZ magic happens in the header. The code uses KOMA's \ifthispageodd to draw things differently for even and odd pages:

% -------------------------------------------------
% header and footer:
\usepackage{scrpage2}
\pagestyle{scrheadings}
\renewcommand*\chapterpagestyle{scrheadings}
\clearscrheadfoot

% the page logo - needs to be improved
\newcommand*\logo{%
  \textcolor{darkred}{\scalebox{1.3}{ITALIAN} \scalebox{2}{SRD}} \\
  d20\scalebox{2}{MODERN}}

% tikz styles:    
\tikzset{
  logo/.style={
    color = mygray ,
    font  = \normalfont\sffamily\Large\bfseries ,
    inner sep = .25in ,
    align = center
  },
  page/.style={
    color  = mygray ,
    fill   = darkred ,
    font   = \normalfont\sffamily\Huge\bfseries ,
    minimum size = \omargin-.2in ,
    yshift = 2in
  },
  chapter/.style={
    color = mygray ,
    scale = 1.5 ,
    transform shape ,
    font  = \normalfont\sffamily\Huge\bfseries ,
  }
}
\ohead{
\begin{tikzpicture}[remember picture, overlay]
 % logo:
 \ifthispageodd
   {\node[below left,logo] at (current page.north east)}
   {\node[below right,logo] at (current page.north west)}
   {\logo} ;
 % page number:
 \ifthispageodd
   {\node[left,page] at (current page.east)}
   {\node[right,page] at (current page.west)}
   {\thepage} ;
 % chapter mark:
 \ifthispageodd
   {\node[anchor=north east,rotate=-90,chapter] at (current page.south east)}
   {\node[anchor=north west,rotate=90,chapter] at (current page.south west)}
   {\chaptertitle} ;
 \ifthispageodd
   {
     \draw[mygray,very thin]
       (current page.south east)++(-.6in,0)--++(0,.6\paperheight) ;
   }
   {
     \draw[mygray,very thin]
       (current page.south west)++(.6in,0)--++(0,.6\paperheight) ;
   }
\end{tikzpicture}
}

The next thing is the chapter layout which starts with the patching of the internals. The patching is twofold: setting a boolean to determine if a chapter is numbered or not and insert a \newpage at the appropriate place to let the text start in the second column. Next we abuse the koma font chapter to safe the chapter name in \chaptertitle (which has been used in the code above for the footer already) and write the chapter name in a dark red box:

% -------------------------------------------------
% chapter layout:
\usepackage{etoolbox}
\newbool{schapter}
\makeatletter
\patchcmd\@chapter
  {\ifnum \scr@osectarg}
  {\boolfalse{schapter}\ifnum \scr@osectarg}
  {}{\error}
\patchcmd\@schapter
  {\if@twocolumn}
  {\booltrue{schapter}\if@twocolumn}
  {}{\error}
\patchcmd\@chapter
  {\@topnewpage[\@makechapterhead{#2}]}
  {\@topnewpage[\@makechapterhead{#2}]\null\newpage\vspace*{1in}}
  {}{\error}
\patchcmd\@schapter
  {\@topnewpage[\@makeschapterhead{#1}]}
  {\@topnewpage[\@makeschapterhead{#1}]\null\newpage\vspace*{1in}}
  {}{\error}
\makeatother

\newcommand\savechapter[1]{\gdef\chaptertitle{#1}}
\newcommand*\chapterbox[1]{%
  \savechapter{#1}%
  \begin{tikzpicture}[remember picture, overlay]
   \fill[mygray] (current page.north west) rectangle (current page.south) ;
   \draw (current page.north) ++(0,-2in)
     node[mygray,fill=darkred,inner sep=1em,align=center,minimum width=.75\textwidth]
       (chapapp)
       {\ifbool{schapter}{}{\rlap{\Huge\chapapp\space\thechapter:}}} ;
   \node[anchor=north,mygray,fill=darkred!85,inner sep=1em,xshift=-.6in]
     at (chapapp.south)
     {\scalebox{2.5}{\bfseries\MakeUppercase{#1}\hspace*{.2in}}} ;
  \end{tikzpicture}
}
\setkomafont{chapter}{\chapterbox}

Last thing: the section layout. This is basically the code from your previous question.

% -------------------------------------------------
% section layout:
\setcounter{secnumdepth}{0}
\newcommand\sectionrule{%
  \makebox[0pt][l]{\rule[-.25ex]{\linewidth}{1pt}}}
\newcommand\sectionformat[1]{%
  \sffamily\huge\color{darkred}%
  \sectionrule
  \hfill\MakeUppercase{#1}}
\setkomafont{section}{\sectionformat}

Now let's put everything together. The code for the picture above:

\documentclass[twocolumn]{scrbook}
\usepackage{fontspec}
\setmainfont{Linux Biolinum O}

\usepackage{polyglossia}
\setmainlanguage{italian}
% -------------------------------------------------
% page layout:
\setlength\parindent{15pt}

\usepackage[a4paper]{geometry}
\newlength\imargin
\newlength\omargin
\setlength\imargin{.7in}
\setlength\omargin{.7in}
\geometry{
  inner  = \imargin ,
  outer  = \omargin ,
  top    = 1in ,
  bottom = .7in
}

% -------------------------------------------------
% colors:
\usepackage{tikz,xcolor}
\usetikzlibrary{positioning}
\definecolor{darkred}{cmyk}{0.0,0.87,0.87,0.50}
\colorlet{mygray}{black!20}

% -------------------------------------------------
% header and footer:
\usepackage{scrpage2}
\pagestyle{scrheadings}
\renewcommand*\chapterpagestyle{scrheadings}
\clearscrheadfoot

\newcommand*\logo{%
  \textcolor{darkred}{\scalebox{1.3}{ITALIAN} \scalebox{2}{SRD}} \\
  d20\scalebox{2}{MODERN}}
\tikzset{
  logo/.style={
    color = mygray ,
    font  = \normalfont\sffamily\Large\bfseries ,
    inner sep = .25in ,
    align = center
  },
  page/.style={
    color  = mygray ,
    fill   = darkred ,
    font   = \normalfont\sffamily\Huge\bfseries ,
    minimum size = \omargin-.2in ,
    yshift = 2in
  },
  chapter/.style={
    color = mygray ,
    scale = 1.5 ,
    transform shape ,
    font  = \normalfont\sffamily\Huge\bfseries ,
  }
}
\ohead{
\begin{tikzpicture}[remember picture, overlay]
 % logo:
 \ifthispageodd
   {\node[below left,logo] at (current page.north east)}
   {\node[below right,logo] at (current page.north west)}
   {\logo} ;
 % page number:
 \ifthispageodd
   {\node[left,page] at (current page.east)}
   {\node[right,page] at (current page.west)}
   {\thepage} ;
 % chapter mark:
 \ifthispageodd
   {\node[anchor=north east,rotate=-90,chapter] at (current page.south east)}
   {\node[anchor=north west,rotate=90,chapter] at (current page.south west)}
   {\chaptertitle} ;
 \ifthispageodd
   {
     \draw[mygray,very thin]
       (current page.south east)++(-.6in,0)--++(0,.6\paperheight) ;
   }
   {
     \draw[mygray,very thin]
       (current page.south west)++(.6in,0)--++(0,.6\paperheight) ;
   }
\end{tikzpicture}
}

% -------------------------------------------------
% chapter layout:
\usepackage{etoolbox}
\newbool{schapter}
\makeatletter
\patchcmd\@chapter
  {\ifnum \scr@osectarg}
  {\boolfalse{schapter}\ifnum \scr@osectarg}
  {}{\error}
\patchcmd\@schapter
  {\if@twocolumn}
  {\booltrue{schapter}\if@twocolumn}
  {}{\error}
\patchcmd\@chapter
  {\@topnewpage[\@makechapterhead{#2}]}
  {\@topnewpage[\@makechapterhead{#2}]\null\newpage\vspace*{1in}}
  {}{\error}
\patchcmd\@schapter
  {\@topnewpage[\@makeschapterhead{#1}]}
  {\@topnewpage[\@makeschapterhead{#1}]\null\newpage\vspace*{1in}}
  {}{\error}
\makeatother

\newcommand\savechapter[1]{\gdef\chaptertitle{#1}}
\newcommand*\chapterbox[1]{%
  \savechapter{#1}%
  \begin{tikzpicture}[remember picture, overlay]
   \fill[mygray] (current page.north west) rectangle (current page.south) ;
   \draw (current page.north) ++(0,-2in)
     node[mygray,fill=darkred,inner sep=1em,align=center,minimum width=.75\textwidth]
       (chapapp)
       {\ifbool{schapter}{}{\rlap{\Huge\chapapp\space\thechapter:}}} ;
   \node[anchor=north,mygray,fill=darkred!85,inner sep=1em,xshift=-.6in]
     at (chapapp.south)
     {\scalebox{2.5}{\bfseries\MakeUppercase{#1}\hspace*{.2in}}} ;
  \end{tikzpicture}
}
\setkomafont{chapter}{\chapterbox}

% -------------------------------------------------
% section layout:
\setcounter{secnumdepth}{0}
\newcommand\sectionrule{%
  \makebox[0pt][l]{\rule[-.25ex]{\linewidth}{1pt}}}
\newcommand\sectionformat[1]{%
  \sffamily\huge\color{darkred}%
  \sectionrule
  \hfill\MakeUppercase{#1}}
\setkomafont{section}{\sectionformat}

% -------------------------------------------------
\usepackage{lipsum}% dummy text

\begin{document}

\chapter*{Introduzzione}
\lipsum[1-2]

\section{Foo Bar Baz}
\lipsum[3-11]

\chapter{Personaggi}
\lipsum[1-2]

\section{Foo Bar Baz}
\lipsum[3-11]

\end{document}
5
  • Thanks so much! I have spent almost all the weekend to make experiments... with results that are not even comparable to yours! Every time I was achieving a marginal improvement on a direction, I was breaking something somewhere else... By the way, how long did it take to put together such an astonishing result?!? I am a bit busy today so I have no time to immediately try out your code, but I bet it will be the Answer to my question! Jan 21, 2013 at 15:04
  • Hard to say... I was watching snooker at the same time and was often distracted...
    – cgnieder
    Jan 21, 2013 at 16:41
  • Are you trying to annihilate my self-esteem, aren't you?!? Just kidding: I will give a look to your code as soon as possible... I am sure I will learn a lot from it! Thanks! Jan 21, 2013 at 17:13
  • No, I'm not :) What I meant to say that it coes not say much how long it took me. This depends on so many points: 1. how familiar are with the class? 2. How familiar are you with the packages involved? 3. How familiar are you with LaTeX programming? 4. Have you done something similar before? Do you know where to start and did you think it through? 5. Are you distracted (as I were)? And so on and so on...
    – cgnieder
    Jan 21, 2013 at 18:00
  • Well, don't be so modest! You gave a huge contribution! I just finished to merge your code with my additional customisations: I couldn't believe how well and vivid the document was becoming after each addition! New questions, however, were raised... Tomorrow, if I have time, I'll look for answers and if I don't find them, I'll post the question. Goodnight and thanks again! Jan 22, 2013 at 0:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .