LaTeX in a Minute: Multiple Page Styles

Published: 26 November 2022
on channel: Maths Partner
4,919
67

\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{lipsum}

\usepackage[top=4cm,bottom=2cm,left=2cm,right=2cm,headheight=2cm,footskip=1cm,marginparwidth=2cm]{geometry}
\usepackage[dvipsnames]{xcolor}

\usepackage{fancyhdr}
\usepackage{tikz}
\usepackage{tikzpagenodes}


%first custom template layout
\newcommand{\myfirststyle}{%
\begin{tikzpicture}[remember picture, overlay]

%top border
\fill[fill=DarkOrchid](current page.north west) rectangle ([yshift=-15mm]current page.north east);

\fill[fill=Thistle]([yshift=-17mm]current page.north west) rectangle ([yshift=-30mm]current page.north east);

%page box
\draw[lightgray, fill=Rhodamine, fill opacity=0.05, line width=1mm, rounded corners=3mm] ([xshift=-5mm,yshift=5mm]current page text area.north west) rectangle ([xshift=5mm,yshift=-5mm]current page text area.south east);

%bottom box
\fill[fill=DarkOrchid](current page.south west) rectangle ([yshift=10mm]current page.south east);

%page circle
\draw[white,fill=TealBlue,line width=2mm] ([xshift=-5mm,yshift=25mm]current page text area.north east) circle (1);


%page number text
\node[anchor=center] at ([xshift=-5mm,yshift=25mm]current page text area.north east) {\Huge\bfseries\sffamily\color{white}{\thepage}};

%title text
\node[anchor=west] at ([yshift=32mm]current page text area.north west) {\Huge\bfseries\sffamily\color{white}{This is my first style}};

%subtitle text
\node[anchor=west] at ([xshift=10mm,yshift=16mm]current page text area.north west) {\Large\bfseries\sffamily\color{white}{Here is my subtitle}};

%footer text
\node[anchor=center] at ([yshift=-15mm]current page text area.south) {\large\bfseries\sffamily\color{white}{Here is my footer}};

\end{tikzpicture}
}%


%second custom template layout
\newcommand{\mysecondstyle}{%
\begin{tikzpicture}[remember picture, overlay]

%top border
\fill[fill=MidnightBlue](current page.north west) rectangle ([yshift=-15mm]current page.north east);

\fill[fill=BlueGreen]([yshift=-17mm]current page.north west) rectangle ([yshift=-30mm]current page.north east);

%page box
\draw[lightgray, fill=RoyalBlue, fill opacity=0.05, line width=1mm, rounded corners=3mm] ([xshift=-5mm,yshift=5mm]current page text area.north west) rectangle ([xshift=5mm,yshift=-5mm]current page text area.south east);

%bottom box
\fill[fill=MidnightBlue](current page.south west) rectangle ([yshift=10mm]current page.south east);

%page circle
\draw[white,fill=Tan,line width=2mm] ([xshift=-5mm,yshift=25mm]current page text area.north east) circle (1);


%page number text
\node[anchor=center] at ([xshift=-5mm,yshift=25mm]current page text area.north east) {\Huge\bfseries\sffamily\color{white}{\thepage}};

%title text
\node[anchor=west] at ([yshift=32mm]current page text area.north west) {\Huge\bfseries\sffamily\color{white}{This is my second style}};

%subtitle text
\node[anchor=west] at ([xshift=10mm,yshift=16mm]current page text area.north west) {\Large\bfseries\sffamily\color{white}{Here is my subtitle}};

%footer text
\node[anchor=center] at ([yshift=-15mm]current page text area.south) {\large\bfseries\sffamily\color{white}{Here is my footer}};

\end{tikzpicture}
}%



%create page style
\fancypagestyle{MyFirstStyle}{%
\fancyhf{}
\fancyhead[C]{\myfirststyle}
\renewcommand{\headrulewidth}{0pt}
}%


%create page style
\fancypagestyle{MySecondStyle}{%
\fancyhf{}
\fancyhead[C]{\mysecondstyle}
\renewcommand{\headrulewidth}{0pt}
}%


%load page style
\pagestyle{MyFirstStyle}


\begin{document}

%First page
\lipsum[1-6]

%Second page
\newpage

\thispagestyle{MySecondStyle}

\lipsum[1-6]

%Third page
\newpage

\lipsum[1-6]

\end{document}


Watch video LaTeX in a Minute: Multiple Page Styles online without registration, duration hours minute second in high quality. This video was added by user Maths Partner 26 November 2022, don't forget to share it with your friends and acquaintances, it has been viewed on our site 4,919 once and liked it 67 people.