1

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} 
5
  • 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} 
1
\documentclass[12pt]{report}
\usepackage[titles]{tocloft}
\renewcommand{\cftdot}{\hfill}
\usepackage[most]{tcolorbox}


\newtcbox{\chapternumberbox}[1][]{%
  colback=mybluei!50!black,
  colupper={white},
  fontupper={\bfseries\large},
  valign=center,
  size=small,
  nobeforeafter,
  equal height group=chaptertoc,
  #1,
}




\newtcolorbox{chapternamebox}[1][]{%
  enhanced jigsaw,
  valign=center,
  interior style={left color={white!30!myblueii},right color={white!90!myblueii}},
  colframe={gray},
  boxrule={1pt},
  colupper={black},
  size=small,
  fontupper={\bfseries\large},
  nobeforeafter,
  equal height group=chaptertoc,
  #1,
}

% A wrapper command
\newcommand{\mychapternamebox}[3][]{%
  \begin{chapternamebox}[#1]
    #2\hfill#3%
  \end{chapternamebox}%
}


\usepackage{xpatch}

\makeatletter
\xpatchcmd{\@chapter}{%
  \addcontentsline{toc}{chapter}%
  {\protect\numberline{\thechapter}#1}%
}{%
  \addtocontents{toc}{\protect\cftpagenumbersoff{chapter}}
  \addcontentsline{toc}{chapter}{\protect\chapternumberbox{\protect\chaptername{} \thechapter}\protect\mychapternamebox[width={12cm}]{#1}{\thepage}}%%
  \addtocontents{toc}{\protect\cftpagenumberson{chapter}}%
}{}{}
\makeatother


\usepackage{tikz}
\usepackage{fourier}
\usepackage[explicit,calcwidth]{titlesec}
\usepackage{lipsum}
\usepackage[a4paper,bindingoffset=0.5in,%
            left=1in,right=1in,top=1in,bottom=1in,%
            footskip=.50in]{geometry}
\definecolor{mybluei}{RGB}{0,173,239}
\definecolor{myblueii}{RGB}{63,200,244}
\definecolor{myblueiii}{RGB}{199,234,253}
\usepackage{calc}
\usepackage[explicit,calcwidth]{titlesec}
\newlength{\titleheight}
\setlength{\titleheight}{\dimexpr 1in+\topmargin+\headheight+\headsep+4cm}

\usetikzlibrary{tikzmark}
\tikzset{
  mycircled/.style = {circle,draw,inner sep=.25em,line width=.25em}
}

\titleformat{\chapter}{}{}{0pt}{%
  \begin{tikzpicture}[remember picture,overlay]
  \fill[myblueii!40]
    (current page.north west) rectangle ([yshift=-\titleheight]current page.north east);
  \node[
      fill=myblueii,
      text width=2\paperwidth,
      rounded corners=6cm,
      text height=1.5\titleheight,
      anchor=center,
      inner sep=2pt] at (current page.north east) (chaptop) {};
  \node[above left, inner xsep=2pt] at (chaptop.south)
    {\fontsize{30}{40}\color{white}\rmfamily\bfseries #1%
    \ifstarredchapter\else
      \makebox[40pt][r]{%
        \raisebox
          {2\baselineskip} % Distance above chapter title
          {\Huge % Chapter X font size
            Chapter~\tikzmarknode[mycircled,white,text=white, font=\Huge]{C-\thechapter}{\thechapter}}}%
    \fi};
  \end{tikzpicture}%
  }

\makeatletter
\newif\ifstarredchapter
\let\old@chapter\@chapter
\renewcommand{\@chapter}{\starredchapterfalse\old@chapter}
\let\old@schapter\@schapter
\renewcommand{\@schapter}{\starredchaptertrue\old@schapter}

\makeatother



\begin{document}
\tableofcontents
\listoffigures
\listoftables
\chapter*{Intro}

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

enter image description here

3
  • Welcome to TeX.SE! Can you please explain in your own words what you did change in the code to get the shown image/result? Giving only an code can not be useful to an reader, because you can not be sure s/he saw the changed code and can interpret that changings correctly. Please explain your changings to make things clear .... – Mensch Jul 26 '19 at 20:39
  • Hello, also, your code does not compile. What engine are you using? XeLaTex? – Joe Jul 30 '19 at 4:14
  • @ Joe. I m using MikTex 2.9 alongwith Texmaker – ibrar hussain Jul 30 '19 at 10:14

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.