This question is extention for other my question Replacing \fancyhdr with \titlesec in complicated design documents.
Really, I work with Japanese and according this advice, for me XeLaTeX with bxjsclasses is optimal. When I have try the solution from prevous answer, I got output represented on the picture below.
The geometry package settings must define same parameters, as before, but frame position is invalid with bxjsarticle.
First, just for test you may compile below MWE with PDFLaTeX. When test with XeLaTeX, replace \documentclass[a4paper,twoside]{article} with \documentclass[a4paper,twoside]{bxjsarticle}. If you have not got this class, you can obtain it here.
\documentclass[a4paper,twoside]{article}
\usepackage[svgnames,x11names]{xcolor}% you need this before tikz to avoid an option clash
\usepackage{tikz,tikzpagenodes}
\usetikzlibrary{calc}
\usepackage{geometry}
\geometry{% Please make twoside settings
bindingoffset=0mm,
left=13mm, %% or inner=23mm
right=18mm, %% or outer=18mm
top=11mm, bottom=11mm,
headsep=3mm,
footskip=3mm
}
\usepackage{titletoc}
\usepackage[pagestyles]{titlesec}
\usepackage{background}
\newcommand{\colourframe}[2][white]{%
\clearpage
\backgroundsetup{%
angle=0,
scale=1,
opacity=1,
contents={%
\begin{tikzpicture}[remember picture, overlay]
\path [fill=#2, even odd rule]
(current page.south west) rectangle (current page.north east)
($(current page text area.south west) - (2mm,2mm)$) rectangle ($(current page text area.north east) + (2mm,2mm)$)
;
\node [fill=#1, draw=black, anchor=north, text=black, inner xsep=5mm, inner ysep=1.5mm, yshift=-1mm] at ($(current page text area.south) - (0,2mm)$) {\thepage};
\end{tikzpicture}},
position=current page.south west,
nodeanchor=south west
}%
\pagestyle{colourfancy}%
\sethead[][][\thesection\quad\sectiontitle]{\thesection\quad\sectiontitle}{}{}%
\setfoot[][][]{}{}{}%
\colorlet{SectionFrameColor}{#2!50}%
\colorlet{SectionFillColor}{#2!20}%
\colorlet{SectionFontColor}{#2!80}%
\titleformat{\section}[hang]{%
\Large\sffamily\color{SectionFontColor}%
}{%
\begin{tikzpicture}
[
baseline={([yshift=-.8ex]current bounding box.center)},
]
\node [thick, draw=SectionFrameColor, fill=SectionFillColor, rectangle, rounded corners, text=white] {\thesection};
\end{tikzpicture}%
}{12pt}{}[{\titlerule[1pt]}]%
\titleformat{\paragraph}[hang]{\bfseries}{}{}{}[]}
\newpagestyle{colourfancy}[]{}
\newpagestyle{tocandintro}[]{\headrule\setheadrule{0.5mm}\footrule\setfootrule{0.5mm}}
\backgroundsetup{%
contents={},
}
\begin{document}
\pagestyle{tocandintro}
\sethead[Table of contents][][]{}{Table of contents}{\textsf{Table of contents}}
\setfoot[\thepage][][ABC Project]{ABC Project}{}{\thepage}
\tableofcontents
\clearpage% uncomment if you don't want to have Intro in the header of the final contents page
\sethead[Intro][][]{}{}{Intro}
Intro text
\colourframe[orange]{red}
\section{First Red section}
\subsection{Red A}
\subsubsection{Red AA}
\subsubsection{Red AB}
\newpage
% 2nd red page
\section{Second Red section}
\subsection{Red B}
\subsubsection{Red BA}
\subsubsection{Red BB}
\colourframe[cyan]{blue}
\section{Blue section}
\end{document}
Please do not draw attention to strange TOC: I can repair it myself.
xelatexhas some problems. Trylualatexinstead. It works. – Oct 21 '14 at 09:36