Thes page on the picture below (from this post) has been created within \fancyhdr
package, but I need to something like this keeping incompatible \titlesec
usage and using twopage layout.
Really, I have no idea how to use tikz codes with \titlesec
interface, but to save your time, I prepared the draft. It's no much, but…
\documentclass[a4paper]{article}
\usepackage{tikz}
\usepackage{geometry}
\geometry{% Please make twoside settings
paperwidth=210mm, paperheight=297mm,
bindingoffset=0mm, asymmetric,
left=13mm, %% or inner=23mm
right=18mm, %% or outer=18mm
top=11mm, bottom=11mm,
headsep=3mm,
footskip=3mm
}
\usepackage{titletoc}
\usepackage[pagestyles]{titlesec}
\usepackage[svgnames,x11names]{xcolor}
\newpagestyle{redfancy}[]{% Please insert the settings}
\newpagestyle{bluefancy}[]{% Please insert the settings}
\begin{document}
% 1st red page
\pagestyle{redfancy} % color: Header/Footer/Margin color: Firebrick2
\sethead[][][\thesection\quad\sectiontitle]{\thesection\quad\sectiontitle}{}{}
\setfoot[\thepage][][]{}{}{\thepage}
\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}
\newpage % Blue page
\pagestyle{bluefancy} % color: Header/Footer/Margin color: DodgerBlue1
\section{Blue section}
\end{document}
Here is the sketch of desired result:
Update
According the requests of the people who nicely managed to answer this question, I'll explain what I need from titlesec
packgage.
First is the dynamical design. During TOC, intro, outro I need the more simple design, and then – fancy color design (Red page, Blue page etc).
Before, I did it this way:
%\usepackage[pagestyles]{titlesec}
\newpagestyle{tocandintro}[]{\headrule\setheadrule{0.5mm}\footrule\setfootrule{0.5mm}}
\pagestyle{tocandintro}
\sethead[Table of contents][][]{}{Table of contents}{\textsf{目次}}
\setfoot[\thepage][][ABC Project]{ABC Project}{}{\thepage}
\tableofcontents
\sethead[Intro][][]{}{}{Intro}
\setfoot[\thepage][][ABC Project]{ABC Project}{}{\thepage}
<Intro text>
\pagestyle{fancy} % And after - color fancy design
Then, I need dynamical color titles, as shown on the picture below.
Before, I did it this way:
% --- Section
\colorlet{SectionFrameColor}{blue!50}
\colorlet{SectionFillColor}{blue!20}
\colorlet{SectionFontColor}{blue!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}{}{}{}[]
% And than re-define section color...
As you see, besides decorative needs I want to change the \paragraph format.
Best Answer
You would need to tweak this and I don't recommend it because I think the use of
titlesec
is going to cause more trouble than it is worth. However, if you insist:Step 1: Initial Solution
This solution uses
tikzpagenodes
together with thebackground
package. This leaves the page style commands fromtitlesec
to just handle the content of the header. The page frame and footer content is constructed using TiKZ on the background of the page. Theeven odd rule
ensures that only the outside of the frame is filled with colour and that a 'hole' is created to contain the page content.Note that I'm unsure why you say you want two-sided settings when you do not seem to really be using them! That is, you have set things up so that the margins are the same on every page. That means the outer margin will sometimes be larger than the inner one and sometimes smaller.
Step 2: Adjusting the Inner and Outer Margins
In your sketch, however, the output is closer to this:
That makes the large margins on the inside and the small on the outside. A more usual layout would reverse that behaviour:
so that the larger margin is on the outside and the two smaller inner margins combine on a double-page spread.
Step 3: Shrink the Frame
The code above does not allow the page itself any 'breathing' room. That is, the content is right bang up against the frame. This is non-optimal. It would be better to shrink the frame a little away from the contents of the page. This can be done using the
calc
library:I've specified 2mm of shrinkage but you can adjust this as you wish. Personally, I would increase the margin sizes somewhat - I think things look much too squeezed, especially since information has to be included within this space. But if you are short of paper, this does seem to work.
Here's the resulting double-page spread (i.e. pages 2 and 3):
Step 4: Incorporate Code from Updated Question
This is the result of incorporating the additional customisation you added to your question:
I've adapted
\colourframe[]{}
so that it also configures the changes to the format for section titles, paragraph layout, headers and footers as shown in your example. The colour of the section titles etc. is based on the colour specified for the frame. As before, the optional argument specifies the background colour for the box containing the page number.Adding
asymmetric
back into the page layout forgeometry
:Note that the margins are very like those you would get if using
oneside
in this case i.e. the margins are defined for left and right as opposed to inner and outer.If you just want the larger margin on the inside, switch the values for the left and right margin rather than passing
asymmetric
. This gives you: