0

In document class "report", in some particular pages, I would like to have two kinds of headers. I want that the header for the odd pages is as follows:

Title1 ................................................. Page number

and accordingly, the header for the even pages as follows:

Page number ............................................ Title2

I should to explain that title 1 is related to the "name of my report" and title 2 is fixed and is independent of the chapter name. In the following, I have mentioned my work:

\documentclass[11pt,a5paper,twoside]{report}
\usepackage{amsthm}
\usepackage{amssymb}
\usepackage{mathtools}
\usepackage[top=25mm, bottom=25mm, left=20mm, right=20mm]{geometry}
\usepackage{tikz}
\usepackage{graphicx}
\usepackage{framed}
%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{indentfirst}
\usepackage{emptypage}
\usepackage{titlesec}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[colorlinks=true,linkcolor=Blue,urlcolor=Blue,citecolor=Blue]{hyperref}
\usepackage{algorithm,algcompatible}
\usepackage[textfont={small},labelfont={rm,small},format=hang,labelsep=quad,justification={centering},aboveskip=1pt,belowskip=1pt]{caption}
\usepackage{subcaption}
\usepackage[nottoc]{tocbibind}
\usepackage{tocloft}
\usepackage{times}
\usepackage{cite}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\titleformat{\chapter}[display]
{}{}{1ex}{\bfseries\fontsize{15}{16}\selectfont}[]
\renewcommand{\cftchapleader}{\cftdotfill{\cftdotsep}} % for chapters
\begin{document}
\pagenumbering{alph}
\tableofcontents
\cleardoublepage
\pagestyle{plain}
\pagenumbering{arabic}
This is my work.
\end{document} 

How can I do it?

Thank you

  • 2
    Define a page style (with fancyhdr or titleps) and apply it. – Bernard Jan 17 '18 at 22:37
  • @ Bernard , Unfortunately, I do not know how can I do it. Can you please help me? – Farid Jan 17 '18 at 22:39
  • 1
    We can, but please post a minimal compilable example, with the relevant part of your preamble. – Bernard Jan 17 '18 at 22:41
  • @Bernard , I edited my question. Thank you so much. – Farid Jan 17 '18 at 22:47
  • What would be these titles (1 and 2)? I suppose, not pre-deined, but depending on the chapter or section titles? And for which kind of pages should it be used? – Bernard Jan 17 '18 at 23:18
2

Here is a simple solution with titleps, which is loaded with the pagestyles option of titlesec. Likewise, the  clearempty option replaces loading the emptypage package.

Note the first page of chapters (if any) still have the plain page style (page number centred in the footer). This can be modified, either adding a command in \titleformat{\chapter} or re-defining the plain page style with \renewpagestyle{plain}.

I took the opportunity to simplify the options for geometry. Some other remarks: hyperref should be loaded as the last package, with very few exceptions (most notably cleveref should be loaded afterwards). Also, if you have maths in your document (I suppose so, since you load mathtools), you should use a maths font which fits times – I loaded newtxmath for that, which is based on the Times-clone TeX Gyre Termes, ad I'd recommend, if you're allowed to replace times, to load also newtxtext, to have true small caps and some other delicacies.

\documentclass[11pt,a5paper,twoside, dvipsnames]{report}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsthm}
\usepackage{amssymb}
\usepackage{mathtools}
\usepackage[vmargin=25mm, hmargin=20mm]{geometry}
\usepackage{tikz}
\usepackage{graphicx}
\usepackage{framed}
%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{indentfirst}
\usepackage{emptypage}
\usepackage[pagestyles, clearempty]{titlesec}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{algorithm,algcompatible}
\usepackage[textfont={small},labelfont={rm,small},format=hang,labelsep=quad,justification={centering},aboveskip=1pt,belowskip=1pt]{caption}
\usepackage{subcaption}
\usepackage[nottoc]{tocbibind}
\usepackage{tocloft}
\usepackage{times, newtxmath}
\usepackage{cite}
\usepackage[colorlinks=true,linkcolor=Blue,urlcolor=Blue,citecolor=Blue]{hyperref}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[toc]{blindtext} %for demonstrating purposes
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\titleformat{\chapter}[display]
{}{}{1ex}{\bfseries\fontsize{15}{16}\selectfont}[]
\renewcommand{\cftchapleader}{\cftdotfill{\cftdotsep}} % for chapters

\newpagestyle{myps}{%
\sethead[][\thepage\enspace\dotfill\enspace Title 2][]{}{Title 1\enspace\dotfill\enspace\thepage}{}
\setfoot{}{}{}
}%

\begin{document}

\pagenumbering{alph}
\tableofcontents
\cleardoublepage
\pagestyle{myps}
\pagenumbering{arabic}

\chapter{A First Chapter}
\Blindtext[5][2]
\chapter{A Second Chapter}
\Blindtext[2][5]

\end{document} 

enter image description here enter image description here

1

If I understand your question, The following is an elementary answer:

\documentclass[11pt,a5paper,twoside]{report}
\usepackage{lipsum}
\usepackage{amsthm}
\usepackage{amssymb}
\usepackage{mathtools}
\usepackage[top=25mm, bottom=25mm, left=20mm, right=20mm]{geometry}
\usepackage{tikz}
\usepackage{graphicx}
\usepackage{framed}
%%%%%%%%%%%%%%%%%%%%%%%%%%
    \usepackage{indentfirst}
\usepackage{emptypage}
\usepackage{titlesec}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[colorlinks=true,linkcolor=Blue,urlcolor=Blue,citecolor=Blue]        {hyperref}
\usepackage{algorithm,algcompatible}
\usepackage[textfont={small},labelfont=        {rm,small},format=hang,labelsep=quad,justification=    {centering},aboveskip=1pt,belowskip=1pt]{caption}
\usepackage{subcaption}
\usepackage[nottoc]{tocbibind}
\usepackage{tocloft}
\usepackage{times}
\usepackage{cite}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{fancyhdr}
\pagestyle{fancy}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\fancyhf{}
\fancyhead[LO]{\small  \leftmark \ \hrulefill\ \thepage}
\fancyhead[RE]{\small  \thepage \ \hrulefill\ \rightmark}
\fancypagestyle{plain}{%
\fancyhead{} 
}
\renewcommand{\headrulewidth}{0pt}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\titleformat{\chapter}[display]
{}{}{1ex}{\bfseries\fontsize{15}{16}\selectfont}[]
\renewcommand{\cftchapleader}{\cftdotfill{\cftdotsep}} % for chapters
\begin{document}
\pagenumbering{alph}
\tableofcontents
\cleardoublepage
%\pagestyle{plain}
\pagenumbering{arabic}
\lipsum[3-56]
\end{document} 

enter image description here

You can use \dotfill command instead of \hrulefill for dotted header.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.