0

In the code given below, I wanted to have the chapter names show up instead of the numbers just for the first two chapters. This code is building from the code found here.

I am writing a "Problem" for chapter 1, and the "Solution" for chapter 2. So I wanted to have "Problem" appear on the chapter header where the number 1 is for the first chapter, and then "Solution" show up where the number 2 is for the second chapter. For the List of Tables, List of Figures etc., and all the other chapters in the appendix, I wanted to leave the headers as it is currently. Can you help me modify the code so that just the first two chapters show the names in place of the numbers like this for chapter 1:

enter image description here

Here is the code:

\documentclass{book}
\usepackage{tikz}
\usepackage{fourier}
\usepackage[explicit,calcwidth]{titlesec}
\usepackage{lipsum}

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

\renewcommand\thechapter{\arabic{chapter}}

\newcommand\chapnumfont{%
  \fontsize{380}{130}\color{myblueii}\selectfont%
}

\newcommand\chapnamefont{%
  \normalfont\color{white}\scshape\small\bfseries
}

\titleformat{\chapter}
  {\normalfont\huge\filleft}
  {}
  {0pt}
  {%
  \begin{tikzpicture}[remember picture,overlay]
  \fill[myblueiii]
    (current page.north west) rectangle ([yshift=-13cm]current page.north east);
  \node[
      fill=mybluei,
      text width=2\paperwidth,
      rounded corners=6cm,
      text depth=18cm,
      anchor=center,
      inner sep=0pt] at (current page.north east) (chaptop)
    {\thechapter};%
    {};
  \node[
      anchor=south east,
      inner sep=0pt,
      outer sep=0pt] (chapnum) at ([xshift=-20pt]chaptop.south)
    {\chapnumfont\thechapter};
    {};
  \node[
      anchor=south,
      inner sep=0pt] (chapname) at ([yshift=2pt]chapnum.south)
  {};
  \node[
      anchor=north east,
      align=right,
      inner xsep=0pt] at ([yshift=-0.5cm]chapname.east|-chapnum.south)
  {\parbox{.7\textwidth}{\raggedleft#1}};
  \end{tikzpicture}%
  }

\titleformat{name=\chapter,numberless}
  {\normalfont\huge\filleft}
  {}
  {0pt}
  {\begin{tikzpicture}[remember picture,overlay]
  \fill[myblueiii]
    (current page.north west) rectangle ([yshift=-13cm]current page.north east);
  \node[
      fill=mybluei,
      text width=2\paperwidth,
      rounded corners=6cm,
      text depth=18cm,
      anchor=center,
      inner sep=0pt] at (current page.north east) (chaptop)
    {};%
  \node[
      anchor=south east,minimum width=2in,
      inner sep=0pt,
      outer sep=0pt] (chapnum) at ([xshift=-20pt]chaptop.south)
    {};
  \node[
      anchor=south,
      inner sep=0pt] (chapname) at ([yshift=2pt]chapnum.south)
  {};
  \node[
      anchor=north east,
      align=right,
      inner xsep=0pt] at ([yshift=-0.5cm]chapname.east|-chapnum.south)
  {\parbox{.7\textwidth}{\raggedleft#1}};
  \end{tikzpicture}%
  }

\begin{document}

\chapter{Problem}

\lipsum[1]
\section{Problem Statement 1}
\lipsum[1]

\chapter{Solution}
\section{Solution Statement 1}
\lipsum[1]
\section{Solution Statement 2}
\lipsum[1]

\renewcommand{\chaptername}{Appendix}
\renewcommand{\leftmark}{\sffamily\normalsize\bfseries       
\appendixname~\thechapter}
\appendix
\chapter{References}

\end{document} 
  • 1
    You can use titleformat later again, but that time without specifying the number. – Johannes_B Mar 28 '16 at 8:02
  • @Johannes_B, Thanks for your input. Can you guide me as to where I will have to make that change? – Joe Mar 28 '16 at 8:36
  • Right where you want the change to happen, that is just before the first chapter that should be treated differently. – Johannes_B Mar 28 '16 at 8:43
  • @Johannes_B, how do you get the chapter name to show up instead of "Chapter"? Like say "Problem", then "Solution"? I changed line 42 to {\chapnumfont \chaptername}, but "Chapter" showed up in the heading. Thanks. – Joe Mar 28 '16 at 14:52
  • \chaptername is used to translate "Chapter" into other languages, not to hold the chapter title. IIRC, the chapter title is not stored anywhere except in the aux file. – John Kormylo Mar 28 '16 at 16:29
2

The point at which the chapter text starts seems to be fixed at about 4cm below the top of the text area. I adjusted \fontsize and 1.5\titleheight to taste, so feel free to adjust them too.

Note: The curved shape is achieved by creating a box with rounded corners of which only the lower left quadrant is on the paper.

\documentclass{book}
\usepackage{tikz}
\usepackage{fourier}
\usepackage[explicit,calcwidth]{titlesec}
\usepackage{lipsum}

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

\newlength{\titleheight}
\setlength{\titleheight}{\dimexpr 1in+\topmargin+\headheight+\headsep+4cm}

\titleformat{\chapter}{}{}{0pt}{%
  \begin{tikzpicture}[remember picture,overlay]
  \fill[myblueiii]
    (current page.north west) rectangle ([yshift=-\titleheight]current page.north east);
  \node[
      fill=mybluei,
      text width=2\paperwidth,
      rounded corners=6cm,
      text height=1.5\titleheight,
      anchor=center,
      inner sep=0pt] at (current page.north east) (chaptop) {};
  \node[above left, inner xsep=0pt] at (chaptop.south)
    {\fontsize{90}{90}\color{white}\scshape\bfseries #1};
  \end{tikzpicture}%
  }

\begin{document}

\chapter{Problem}

\lipsum[1]
\section{Problem Statement 1}
\lipsum[1]

\chapter{Solution}
\section{Solution Statement 1}
\lipsum[1]
\section{Solution Statement 2}
\lipsum[1]

\appendix
\chapter{Appendix}
\lipsum[1]
\chapter{References}
\lipsum[1]
\end{document}

\end{document} 

\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.