# Problem with titleformat: Don't want Chapter Style to be Applicable on Table of Contents & Bibliography

\documentclass[11pt,twoside,openany]{book}

\usepackage[svgnames,x11names]{xcolor}
\usepackage{wallpaper}
\usepackage{changepage}
\usepackage[explicit]{titlesec}
\usepackage{tikz}
\usetikzlibrary{shapes,positioning}
\usepackage{lipsum}
\usepackage{geometry}
\geometry{
paperwidth=216mm, paperheight=303mm,
left=23mm,  %% or inner=23mm
right=18mm, %% or outer=18mm
top=23mm, bottom=23mm,
footskip=7mm
}

%% Command to hold chapter illustration image
\newcommand\chapterillustration{}

%% Define how the chapter title is printed
\titleformat{\chapter}{}{}{0pt}{
%% Background image at top of page
\ThisULCornerWallPaper{1}{\chapterillustration}
%% Draw a semi-transparent rectangle across the top
\tikz[overlay,remember picture]
\fill[LightSalmon1,opacity=.7]
(current page.north west) rectangle
([yshift=-3cm] current page.north east);
%% Check if on an odd or even page
\checkoddpage\strictpagecheck
%% On odd pages, "logo" image at lower right
%% corner; Chapter number printed near spine
%% edge (near the left); chapter title printed
%% near outer edge (near the right).
\ifoddpage{
\ThisLRCornerWallPaper{.35}{fern_mo_01}
\begin{tikzpicture}[overlay,remember picture]
\node[anchor=south west,
xshift=20mm,yshift=-30mm,
font=\sffamily\bfseries\huge]
at (current page.north west)
{\chaptername\ \thechapter};
\node[fill=Sienna!80!black,text=white,
font=\Huge\bfseries,
inner ysep=12pt, inner xsep=20pt,
rounded rectangle,anchor=east,
xshift=-20mm,yshift=-30mm]
at (current page.north east) {#1};
\end{tikzpicture}
}
%% On even pages, "logo" image at lower left
%% corner; Chapter number printed near outer
%% edge (near the right); chapter title printed
%% near spine edge (near the left).
\else {
\ThisLLCornerWallPaper{.35}{fern_mo_01}
\begin{tikzpicture}[overlay,remember picture]
\node[anchor=south east,
xshift=-20mm,yshift=-30mm,
font=\sffamily\bfseries\huge]
at (current page.north east)
{\chaptername\ \thechapter};
\node[fill=Sienna!80!black,text=white,
font=\Huge\bfseries,
inner sep=12pt, inner xsep=20pt,
rounded rectangle,anchor=west,
xshift=20mm,yshift=-30mm]
at ( current page.north west) {#1};
\end{tikzpicture}
}
\fi
}
\titlespacing*{\chapter}{0pt}{0pt}{135mm}

\begin{document}
\tableofcontents

\renewcommand\chapterillustration{six-computers-chips-circuits}
\newpage
\chapter{Hello World!}

\renewcommand\chapterillustration{cherry-tomatos}
\newpage
\chapter{Whassup, Doc?}

\end{document}


Problem:

The Fancy Settings which I applied to "Chapters" comes over to Everything in the Document. => Table of Contents & Bibliography(not included in the sample code above) are now displayed as 'Chapters'.

Also, I have to disable:

%\listoffigures
%\listoftables


as enabling these sections leads to compilation error (when the Chapter Settings applies to them).

-
When I try to compile your MWE in pdflatex, I get the following error message: file ! LaTeX Error: File six-computers-chips-circuits' not found. Please consider modifying the MWE to avoid requiring this type of (unnecessary?) dependency. –  Mico Aug 25 '12 at 11:17
"six-computers-chips-circuits", "cherry-tomatos", "fern_mo_01" are images, you can rename any images in your system to these names, or you can download from this example code: liantze.googlepages.com/… –  Sandeep Singh Aug 25 '12 at 11:31

Since the table of contents comes before the numbered chapters, you could move your \titleformat and \titlespacing commands after \tableofcontents, so this won't be affected.

You could also define commands, which act like a switch: one calls \titleformat and \titlesection the fancy way, and the other calls it with default settings, which can be found in the titlesec documentation appendix. So you can switch if on and off as you like.

Here's a small example for switching styles, which can be a start for you - just changing colors:

\documentclass{book}
\usepackage{color}
\usepackage{titlesec}
\newcommand*{\fancychapterstyle}{%
\titleformat{\chapter}[display]
{\normalfont\huge\bfseries\color{blue}}{\chaptertitlename\ \thechapter}
{20pt}{\Huge\color{blue}}
\titlespacing*{\chapter}{0pt}{50pt}{40pt}
}
\newcommand*{\standardchapterstyle}{%
\titleformat{\chapter}[display]
{\normalfont\huge\bfseries}{\chaptertitlename\ \thechapter}{20pt}{\Huge}
\titlespacing*{\chapter}{0pt}{50pt}{40pt}
}
\begin{document}
\tableofcontents
\fancychapterstyle
\chapter{One}
\standardchapterstyle
\begin{thebibliography}{99}
\end{thebibliography}
\end{document}

-
I have gone through the titlesec documentation, but couln't find anything which can give me control to switch between formats. Can you please point out any specific section/example? Also, I think that these commands must be placed in preamble section only. How can I call them from middle of the document? –  Sandeep Singh Aug 25 '12 at 11:39
@SandeepSingh Define your own macro in your preamble. Within this macro, call \titleformat with any option you like. You can use your new macro within the document. –  Stefan Kottwitz Aug 25 '12 at 11:45
@SandeepSingh \titleformat and \titlespacing can be used anywhere in the document, not just in the preamble. –  Gonzalo Medina Aug 25 '12 at 13:36
@Gonzalo: Please excuse my ignorance on this. I got confused after reading some post. One point: I have placed /tableofcontents, // New Chapter Settings {Using \titleformat, Chapters ..... . Before BIBLIOGRAPHY, I want to RESTORE Default Settings Again, please give some hint on how to do this. –  Sandeep Singh Aug 25 '12 at 13:54
@SandeepSingh No problem. \standardchapterstyle as defined by Stefan in his answer allows you to restore the default settings. Copy his definition of the command in the preamble and use \standardchapterstyle` before the bibliography (as he did in his example). –  Gonzalo Medina Aug 25 '12 at 14:02
show 1 more comment