Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm trying to use the same procedure than Customizing chapter style with tikz, for the report class and twoside printing.

However for even pages i'm having an unespected behavior (see Fig 2). While for odd pages i'm not having problems (see Fig 1).

Figure 1 Fig1

Figure 2 Fig2

I read in the documentation for titlesec one could use the extra option \titleformat{name=\chapter,page=even/odd} for even or odd pages, however when i compile a simpler version of the code the color boxes are not shown in the pdf.

\documentclass[11pt, a4paper,twoside]{report}
\usepackage{lipsum}
\usepackage[explicit]{titlesec}
\usepackage{fourier}
\usepackage{tikz}
\usepackage{epigraph}
\usepgflibrary{qrr.shapes.openrectangle}

\definecolor{mybluei}{RGB}{0,173,239}
\definecolor{myblueii}{RGB}{63,200,244}
\definecolor{myblueiii}{RGB}{199,234,253}

\tikzset{
mynode/.style={
  rounded corners=30pt,
  shape=open rectangle,
  open rectangle fill=myblueii,
  open rectangle sides=#1,
  }
}

\titleformat{name=\chapter,page=even}[display]
  {\usefont{T1}{qhv}{b}{n}\selectfont}
  {}
  {20pt}
  {%
  \begin{tikzpicture}[remember picture,overlay]
  \node[
    anchor=west,
    rectangle,
    minimum height=4cm,
    text width=\paperwidth,
    xshift=-\the\dimexpr\oddsidemargin+1in\relax,
    outer sep=0pt,
    fill=myblueiii] (titlerect) {};
  \node[
    anchor=south west,
    xshift=2cm,
    text width=\textwidth] 
    at ([yshift=5pt]titlerect.south west) {\huge #1};
  \node[
    mynode=nw,
    anchor=south east,
    fill=myblueii,
    inner xsep=1.5cm,
    outer sep=0pt,
    font=\color{white},
    minimum height=30pt] 
    at (current page.east|-titlerect.north)
     {\bfseries\MakeUppercase{\chaptertitlename}\ \thechapter};
  \end{tikzpicture}%
  }
\titleformat{name=\chapter,page=odd}[display]
  {\usefont{T1}{qhv}{b}{n}\selectfont}
  {}
  {20pt}
  {%
  \begin{tikzpicture}[remember picture,overlay]
  \node[
    anchor=west,
    rectangle,
    minimum height=4cm,
    text width=\paperwidth,
    xshift=-\the\dimexpr\oddsidemargin+1in\relax,
    outer sep=0pt,
    fill=myblueiii] (titlerect) {};
  \node[
    anchor=south west,
    xshift=2cm,
    text width=\textwidth] 
    at ([yshift=5pt]titlerect.south west) {\huge #1};
  \node[
    mynode=nw,
    anchor=south east,
    fill=myblueii,
    inner xsep=1.5cm,
    outer sep=0pt,
    font=\color{white},
    minimum height=30pt] 
    at (current page.east|-titlerect.north)
     {\bfseries\MakeUppercase{\chaptertitlename}\ \thechapter};
  \end{tikzpicture}%
  }
\titleformat{name=\chapter,numberless}[display]
  {\usefont{T1}{qhv}{b}{n}\selectfont}
  {}
  {20pt}
  {\huge #1}
\titlespacing*{\chapter}
  {0pt}{-20pt}{60pt}


\begin{document}

\chapter{Chapter odd}
\lipsum[2]
\chapter{Chapter even}
\lipsum[2]
\chapter*{Numberless chapter}

\end{document}

How can i solve this problem?.

share|improve this question

1 Answer 1

up vote 6 down vote accepted

I've noticed a similar problem to that solution, and managed to come up with the following alternative (my tikz skills is not that great):

enter image description here

\documentclass[11pt, a4paper,twoside]{report}
\usepackage{lipsum}
\usepackage[explicit]{titlesec}
\usepackage{fourier}
\usepackage{tikzpagenodes}% Loads tikz
\usepgflibrary{qrr.shapes.openrectangle}

\definecolor{mybluei}{RGB}{0,173,239}
\definecolor{myblueii}{RGB}{63,200,244}
\definecolor{myblueiii}{RGB}{199,234,253}

\tikzset{
mynode/.style = {
  rounded corners = 30pt,
  shape=open rectangle,
  open rectangle fill = myblueii,
  open rectangle sides = #1,
  }
}

\titleformat{\chapter}[display]
  {\usefont{T1}{qhv}{b}{n}\selectfont}
  {}
  {20pt}
  {%
  \begin{tikzpicture}[remember picture, overlay]
  \node[
    anchor = west,
    rectangle,
    minimum height = 4cm,
    ] 
    (titlerect) {};
  \fill[color = myblueiii] ([xshift = -1cm]current page.west|-titlerect.south) rectangle (current page.east|-titlerect.north);
  \node[
    anchor = south west,
    xshift = -1cm,
    text width = \textwidth] 
    at ([yshift = 5pt]titlerect.south west) {\huge #1};
  \node[
    mynode = nw,
    anchor = south east,
    fill = myblueii,
    inner xsep = 1.5cm,
    outer sep = 0pt,
    font = \color{white},
    minimum height = 30pt] 
    at (current page.east|-titlerect.north)
     {\bfseries\MakeUppercase{\chaptertitlename}\ \thechapter};%
  \end{tikzpicture}%
  }
\titleformat{name = \chapter, numberless}[display]
  {\usefont{T1}{qhv}{b}{n}\selectfont}
  {}
  {20pt}
  {%
  \begin{tikzpicture}[remember picture, overlay]
  \node[
    anchor = west,
    rectangle,
    minimum height = 4cm,
    ] 
    (titlerect) {};
  \fill[color = myblueiii] ([xshift = -1cm]current page.west|-titlerect.south) rectangle (current page.east|-titlerect.north);
  \node[
    anchor = south west,
    xshift = -1cm,
    text width = \textwidth] 
    at ([yshift = 5pt]titlerect.south west) {\huge #1};
  \end{tikzpicture}%
  }
\titlespacing*{\chapter}
  {0pt}{-20pt}{60pt}

\begin{document}

\chapter{Chapter odd}
\lipsum[2]
\chapter{Chapter even}
\lipsum[2]
\chapter*{Numberless chapter}

\end{document}

I'm using tikzpagenodes to tap into the page boundary when setting the coloured boxes, rather than shifting them around manually.

share|improve this answer
    
Amazing @Werner Thanks. By the way, if you upload just the Tikz package the result is the same. –  shadraws May 16 at 18:04

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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