4

I want the chapter no. along with chapter title. Chapter No. it should be left side on top.

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

enter image description here

AndréC
  • 24,137

1 Answers1

6

The following introduces a conditional \ifstarredchapter that is turned on/off depending on the use of \chapter* or \chapter. This allows one to place the appropriate chapter label without much hassle of other titlesec internals.

Circled chapter numbers uses content from Customize circled numbers.

enter image description here

enter image description here

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

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

\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%
    \ifstarredchapter\else
      \makebox[0pt][r]{%
        \raisebox
          {1.2\baselineskip} % Distance above chapter title
          {\Huge % Chapter X font size
            Chapter~\tikzmarknode[mycircled,white]{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}

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

Comments within the \raisebox elements shows where to adjust the gap between the heading and title, as well as the font (currently set to \Huge).

Werner
  • 603,163
  • Thank u Sir for prompt reply. Yet i want to add word "Chapter" for numbered chapters while for unnumbered chapters i want same title style without word" chapter no. Thank you once again for helping me out – Muhammad Ibrar Hussain Jul 24 '19 at 12:44
  • @MuhammadIbrarHussain: I've updated the answer to address your request. – Werner Jul 24 '19 at 14:59
  • Thank u sir for update.It is wonderful. Just three things more. The vertical distance between chapter and title of the chapter should be increased.secondly the word "chapter" font should be small in size while Numeric number of chapter should be in a circle with large font size. – Muhammad Ibrar Hussain Jul 24 '19 at 15:46
  • @MuhammadIbrarHussain: See the updated answer. – Werner Jul 24 '19 at 17:37
  • Werner you beauty! Thank you for cooperation. i want only title left align and want to add an image on the upper left corner.Thank u in advance – Muhammad Ibrar Hussain Jul 24 '19 at 20:06