I am trying to have an article class document with this requirements:
- Twoside
- Two columns with multicol except section and subsection title
- Header, footer and section title colorized according to the section number
I did it but infortunatly the bottom margins have a weird behaviour. The margin changes on even or odd page. I have absolutely no clue how to solve this… Here is my code with the problem.
\documentclass[12pt,twoside,english]{article}
\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage{ifthen}
\usepackage{multicol}
\usepackage{lipsum}
\usepackage[framemethod=TikZ]{mdframed}
\usepackage{tikz}
\usepackage{xcolor}
%\usepackage{libertine}
%\usepackage[bottom]{footmisc}
\usepackage{geometry}
\geometry{verbose,
top=1cm,
bottom=1.8cm,
left=2.2cm,
right=2.2cm}
\usepackage{setspace}
%%Define a color for each section
\definecolor{zz0}{rgb}{.1,.8,.3}
\definecolor{zz1}{rgb}{.8,.2,.2}
\definecolor{zz2}{rgb}{.7,.9,.1}
\definecolor{zz3}{rgb}{.6,.4, 0}
\definecolor{zz4}{rgb}{.5,.1,.9}
\definecolor{zz5}{rgb}{.1, 0,.8}
\definecolor{zz6}{rgb}{.7,.2,.6}
\definecolor{zz7}{rgb}{.9,.3,.8}
\definecolor{zz8}{rgb}{0 ,.4,.1}
\definecolor{zz9}{rgb}{.7,.5,.2}
\definecolor{zz10}{rgb}{.1,.6,.3}
\definecolor{zz11}{rgb}{.6,.8,.5}
\renewcommand*{\hrulefill}[2][0pt]{\leavevmode \leaders \hbox to 1pt{\rule[#1]{1pt}{#2}} \hfill \kern 0pt}
% For headers
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}%
\renewcommand{\headrulewidth}{1pt}% 2pt header rule
\renewcommand{\headrule}{\hbox to\headwidth{%
\color{zz\arabic{section}}\leaders\hrule height \headrulewidth\hfill}}
\fancyhead[LE,RO]{\raisebox{-.9\baselineskip}[0pt][0pt]{\textsc{\textsf{\leftmark}}}}
\fancyfoot[RO]{ \color{zz\arabic{section}} \hrulefill{6pt} \normalcolor \,
some random text %
\color{zz\arabic{section}} \rule{10pt}{6pt} \normalcolor \thepage}%
\fancyfoot[LE]{\thepage \, \color{zz\arabic{section}} \rule{10pt}{6pt} \normalcolor%
Some random text %
\color{zz\arabic{section}} \hrulefill{6pt}}
\renewcommand{\sectionmark}[1]{\markboth{\color{zz\arabic{section}}#1}{}}
%% Create if environment
\makeatletter
\def\ifenv#1{
\def\@tempa{#1}%
\ifx\@tempa\@currenvir
\expandafter\@firstoftwo
\else
\expandafter\@secondoftwo
\fi
}
\makeatother
%% Redefine the section
\usepackage{titlesec}
\let\oldsection\section
\renewcommand{\section}[1]{%
\ifenv{multicols}{\end{multicols}\clearpage}{\clearpage}%
\begin{multicols}{2}[\oldsection{#1}]}
%% Redefine the end of the document
\let\oldend\enddocument
\renewcommand*{\enddocument}{\ifenv{multicols}{\end{multicols}}{}\oldend}
%% Redefine the subsection
\let\oldsubsection\subsection
\renewcommand{\subsection}[1]{%
\ifenv{multicols}{\end{multicols}}{}%
\begin{multicols}{2}[\oldsubsection{#1}]}
\titleformat{\section}{\LARGE\normalfont\color{zz\arabic{section}}}{\thesection}{1em}{}
\titleformat{\subsection}{\Large\normalfont\color{zz\arabic{section}}}{\thesubsection}{1em}{}
\begin{document}
\section{Section}
\lipsum[1-2]
\subsection{Subsection}
\blindtext[4]
\section{Section}
\blindtext[2]
\subsection{Subsection}
\blindtext[2]
\section{Section}
\blindtext[2]
\subsection{Subsection}
\blindtext[2]
\section{Section}
\subsection{Subsection}
\blindtext[2]
\section{Section}
\subsection{Subsection}
\blindtext[2]
\end{document}
Thanks for your help