2

I've seen multiple examples of chapter styling using TikZ, but they all use horizontal rectangles and/or lines to customize chapter page, but is it possible to do a vertical one like the one on the picture below? Does anyone kow how to do it? Thank you!

enter image description here

2
  • 1
    I'm sure there is a package for it somewhere (wallpaper comes to mind) but you can hack it with tikz's page reference functionality (pgf manual, section 17.13).
    – Huang_d
    Jun 8, 2017 at 19:35
  • Probably just a matter of changing the coordinates, can you show an example with a horizontal rectangle? Jun 11, 2017 at 15:45

1 Answer 1

2

I changed my mind about a couple of things, but this is the final result I've got:

enter image description here

The code:

\documentclass[11pt, twosides]{book}
\usepackage[a4paper, top=.5cm]{geometry}
\usepackage[myheadings]{fullpage}
\usepackage{fancyhdr}
\usepackage{lastpage}
\usepackage{graphicx, wrapfig, subcaption, setspace}
\usepackage{mathpazo}
\usepackage[T1]{fontenc}
\usepackage[font=small, labelfont=bf]{caption}
\usepackage[protrusion=true, expansion=true]{microtype}
\usepackage{sectsty}
\usepackage{url, lipsum}
\usepackage{etoolbox}
\usepackage[explicit]{titlesec}
\usepackage{epigraph}
\usepackage{tikz}
\usepackage{tikzpagenodes}
\titleformat{\chapter}[display]
  {\normalfont\huge}
  {}
  {20pt}
  {%
  \begin{tikzpicture}[remember picture,overlay]
\fill[top color=green, bottom color=blue] 
(16,-23) rectangle (18.5,7);
\node[
    anchor= east,
    xshift=1cm,
    text width=\textwidth] 
    at ([yshift=5pt]titlerect.east) {\fontsize{30}{36}\sffamily\selectfont#1};
\node[
    anchor= east,
    inner xsep=3cm,
    outer sep=0pt,
    font=\color{blue}]%,
    at ([yshift=.5cm]current page.east|-titlerect.east)
     {\fontsize{80}{86}\bfseries\thechapter};
\node[
    anchor= east,
    xshift=11.5cm,
        yshift=-11cm,
    text width=\textwidth] 
    at ([yshift=5pt]titlerect.east) {\fontsize{30}{36}\scshape\selectfont\rotatebox{90}{\color{white}#1}};
  \end{tikzpicture}%
}
\titleformat{name=\chapter,numberless}[display]
  {\normalfont\huge}
  {}
  {20pt}
  {%
  \begin{tikzpicture}[remember picture,overlay]
    \fill[top color=green, bottom color=blue] 
    (16,-25) rectangle (18.5,7);
  \node[
   anchor=west,
    rectangle,
    minimum height=4cm,
    text width=\paperwidth,
    xshift=-\the\dimexpr\oddsidemargin+1in\relax,
    outer sep=0pt] (titlerect) {};
  \node[
    anchor=south west,
    xshift=6cm,
        yshift=2cm,
    text width=\textwidth] 
   at (titlerect.south west) {\sffamily\Huge#1};
    \node[
    anchor= east,
    xshift=11.5cm,
        yshift=-11cm,
    text width=\textwidth] 
    at ([yshift=5pt]titlerect.east) {\fontsize{30}{36}\scshape\selectfont\rotatebox{90}{\color{white}#1}};
  \end{tikzpicture}%
  }[]
\titlespacing*{\chapter}
  {0pt}{-20pt}{60pt}
\titlespacing*{\chapter}
  {0pt}{-20pt}{60pt}
\titleformat{\section}[display] 
{\bfseries\normalsize}
{}
{5pt}
{\color{blue}\thesection~~ #1}
\titleformat{name=\section, numberless}[display]
{\bfseries\normalsize}
{}
{5pt}
{#1}

\titleformat{\subsection}[display]
{\itshape\normalsize}
{}
{5pt}
{\color{blue}\thesection~~ #1}

\fancypagestyle{plain}
{
   \fancyhf{}
   \fancyfoot{}
   \renewcommand{\headrulewidth}{0 mm}
}

\title{Title}
\author{Author}
\date{}
\textwidth=13cm
\begin{document}

\maketitle

\chapter{Random}

\section{Lipsum}

\lipsum[2]

\subsection{Subsection}

\lipsum[1]
\end{document}

I know it is not the prettiest solution, and there are probably much simpler ways to do it, but at least it got the job done! Hopefully it can help someone.

1
  • 2
    Your code is not compilable. There is this error: ! Package pgf Error: No shape named titlerect' is known`. Can you look at a question about it here? could some one fix tikz code?
    – AndréC
    Aug 26, 2020 at 19:22

You must log in to answer this question.

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