1

I have two major problems with my footer in my thesis. In my whole document, my text switch on every pages - it works perfect. But when the reader came to the last two "chapters": 1) References and 2) Appendices - the system won't work.

If someone can help me, I would appreciate it much!

My preamble look like this:

        \documentclass[12pt,a4paper,twoside]{report}

        % Page layout
        \usepackage[bindingoffset=0mm]{geometry}

        % Random text
        \usepackage{lipsum}

        % Page style
        \usepackage{fancyhdr}

    % References
    \usepackage[round, colon, sort, authoryear]{natbib}

        % Defining the DEFAULT style
       \fancypagestyle{MyStyle}{%
    \fancyhead{}
    \fancyfoot{}
    \fancyfoot[RO]{\small{\leftmark} \ \ \hspace{2pt} {\vrule height 10pt width 1pt} \hspace{2pt} \ \small{\thepage}}
    \fancyfoot[LE]{\small{\thepage} \ \ \hspace{2pt} {\vrule height 10pt width 1pt} \hspace{2pt} \ \lsstyle\small{\MakeUppercase{\chaptername}}\ \thechapter}
\renewcommand{\headrulewidth}{0pt} % Remove header rule
\renewcommand{\chaptermark}[1]{\markboth{\lsstyle\uppercase{##1}}{}}
}
% Redefining the PLAIN style
\fancypagestyle{plain}{%
\fancyhead{} %Clean headers
\fancyfoot{} %Clean footers
\fancyfoot[RO]{{\vrule height 10pt width 1pt} \hspace{2pt} \ \thepage}
\fancyfoot[LE]{\thepage \ \hspace{2pt} {\vrule height 10pt width 1pt} \hspace{2pt}}
\renewcommand{\headrulewidth}{0pt} % Remove header rule
}

        \begin{document}
        \pagestyle{plain}
        ...pages in plain style...
        \pagestyle{MyStyle}
        \chapter{Introduction}
        \chaptermark*{Introduction}
        \section{First section}
        \lipsum
        \section{Second section}
        \lipsum
        \chapter{Second chapter title}
        \section{Third section}
        \lipsum
        \section{Fourth section}
        \lipsum

        \bibliography{References}
        \addcontentsline{toc}{chapter}{References}
        \chaptermark*{References}

        \bibliography{References}
        \addcontentsline{toc}{chapter}{References}
        \chaptermark*{References}

        \clearpage
        \appendix 
        \chapter*{Appendix A}
        \addcontentsline{toc}{chapter}{Appendix A}
        \chaptermark*{Appendix A}

        \end{document}

Text marked by red - is where I would like to put text in - if that make any sense?

enter image description here enter image description here

--- EDIT ---

By wonderful help by @cfr - I can now type "References" in my footers, but when it comes to my Appendix it won't let "Appendix A" be on both marks. In the first part of the thesis, I am using MyStyle - that is why three different styles are defined.

In my preamble, I added @cfr's code and into it - but I really don't know why it can't show Appendix in footer?

% Page style
\usepackage{fancyhdr}
\pagestyle{fancy}% <- !
% Defining MyStyle
\fancypagestyle{MyStyle}{%
    \fancyhead{}
    \fancyfoot{}
    \fancyfoot[RO]{\small{\leftmark} \ \ \hspace{2pt} {\vrule height 10pt width 1pt} \hspace{2pt} \ \small{\thepage}}
    \fancyfoot[LE]{\small{\thepage} \ \ \hspace{2pt} {\vrule height 10pt width 1pt} \hspace{2pt} \ \lsstyle\small{\MakeUppercase{\chaptername}}\ \thechapter}
\renewcommand{\headrulewidth}{0pt} % Remove header rule
\renewcommand{\chaptermark}[1]{\markboth{\lsstyle\uppercase{##1}}{}}
}
% Redefining the PLAIN style
\fancypagestyle{plain}{%
\fancyhead{} %Clean headers
\fancyfoot{} %Clean footers
\fancyfoot[RO]{{\vrule height 10pt width 1pt} \hspace{2pt} \ \thepage}
\fancyfoot[LE]{\thepage \ \hspace{2pt} {\vrule height 10pt width 1pt} \hspace{2pt}}
\renewcommand{\headrulewidth}{0pt} % Remove header rule
}
\fancypagestyle{ref}{%
  \fancyhf{}%
  \fancyfoot[RO]{\small\rightmark \ \ \hspace{2pt} {\vrule height 10pt width 1pt} \hspace{2pt} \ \thepage}%
  \fancyfoot[LE]{\small\thepage \ \ \hspace{2pt} {\vrule height 10pt width 1pt} \hspace{2pt} \ \leftmark}%
  \renewcommand{\headrulewidth}{0pt}% % Remove header rule
  \renewcommand{\chaptermark}[2][\chaptername~\thechapter]{\markboth{\lsstyle\MakeUppercase{##1}}{\lsstyle\uppercase{##2}}}%
}


\clearpage
\pagestyle{ref}
\bibliographystyle{apalike}
\bibliography{ref}
\addcontentsline{toc}{chapter}{References}
\markboth{\MakeUppercase{References}}{\MakeUppercase{References}}

%\restoregeometry
\clearpage
\pagestyle{ref}
\appendix 
\chapter*{Appendix A}
\addcontentsline{toc}{chapter}{Appendix A}
\chaptermark[Appendix A]{Appendix A}
\markboth{\MakeUppercase{Appendix A}}{\MakeUppercase{Appendix A}}

EDIT - ALMOST FULL PREAMBLE

\documentclass[a4paper,11pt,twoside]{report}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel} 
\usepackage{layout}
\usepackage[protrusion=true,expansion=true]{microtype} 

% Different usepackages
\usepackage[T1]{fontenc}
\usepackage[lf]{MinionPro} %% MinionPro
\usepackage{icomma}
\usepackage{setspace}
\setstretch{1.10}
\usepackage{siunitx,booktabs}
\usepackage{graphicx}

%% \usepackage{tocloft} - add if customize TOC
\renewcommand{\cftsecleader}{\cftdotfill{\cftdotsep}}
\usepackage{tabu}

% Chapter
\usepackage[pagestyles ,newparttoc, explicit]{titlesec}%
\usepackage{titletoc}
\SetTracking[no ligatures = {f}]{encoding = }{100} 
\usepackage[explicit]{titlesec}
\titleformat{name=\chapter}[display]{ \figureversion{lining}}{\lsstyle\Large\MakeUppercase\chaptername\enspace \LARGE\thechapter}{2ex}{\LARGE\bfseries#1}%\uppercase 
\titleformat{name=\chapter, numberless}{\lsstyle\LARGE}{}{0pt}{\MakeUppercase{#1}} \titlespacing{\chapter}{0pt}{2.5ex}{6ex}

\raggedbottom

% Table of Contents

\titlecontents{chapter}[0em]{\large\bfseries\protect\addvspace{15pt}}%\thecontentslabel\brlap[1.25\baselineskip]
{\textssc{\mdseries\MakeLowercase\chaptername~{\footnotesize\thecontentslabel}}\\\medskip}
{}%
{\hfill\contentspage}%

\addtocontents{toc}{\protect\thispagestyle{empty}}

% item / enumerate

\usepackage{enumitem}

% HTML code

\usepackage{listings}
\usepackage{xcolor}

\definecolor{dkgreen}{rgb}{0,0.6,0}
\definecolor{gray}{rgb}{0.5,0.5,0.5}
\definecolor{mauve}{rgb}{0.58,0,0.82}

\lstset{frame=tb,
  language=Java,
  aboveskip=3mm,
  belowskip=3mm,
  showstringspaces=false,
  columns=flexible,
  basicstyle={\small\ttfamily},
  numbers=none,
  numberstyle=\tiny\color{gray},
  keywordstyle=\color{blue},
  commentstyle=\color{dkgreen},
  stringstyle=\color{mauve},
  breaklines=true,
  breakatwhitespace=true,
  tabsize=3
}


% Figure & Table names (1, 2, 3, 4 etc.)

\usepackage{chngcntr}
\counterwithout{figure}{chapter}
\counterwithout{table}{chapter}
\counterwithout{equation}{chapter}

% More pdf-pages at same site

\usepackage{pdfpages}

% References
\usepackage[round, colon, sort, authoryear]{natbib}
\setlength{\bibsep}{0.0pt}
\setlength{\bibhang}{2em}
\bibpunct{(}{)}{;}{a}{}{}
\setcitestyle{notesep={: }}
\def\citeapos#1{\citeauthor{#1}'s (\citeyear{#1})}

% Quotes
\usepackage{csquotes}
\MakeOuterQuote{"}

% Page margins
\usepackage[left=3.5cm,right=3.5cm,top=3.4cm,bottom=3.4cm]{geometry}

% PDF background 
\usepackage{eso-pic}

% Random text
\usepackage{lipsum}

% Page style
\usepackage{fancyhdr}
\pagestyle{fancy}% <- !
% Defining MyStyle
\fancypagestyle{MyStyle}{%
    \fancyhead{}
    \fancyfoot{}
    \fancyfoot[RO]{\small{\leftmark} \ \ \hspace{2pt} {\vrule height 10pt width 1pt} \hspace{2pt} \ \small{\thepage}}
    \fancyfoot[LE]{\small{\thepage} \ \ \hspace{2pt} {\vrule height 10pt width 1pt} \hspace{2pt} \ \lsstyle\small{\MakeUppercase{\chaptername}}\ \thechapter}
\renewcommand{\headrulewidth}{0pt} % Remove header rule
\renewcommand{\chaptermark}[1]{\markboth{\lsstyle\uppercase{##1}}{}}
}
% Redefining the PLAIN style
\fancypagestyle{plain}{%
\fancyhead{} %Clean headers
\fancyfoot{} %Clean footers
\fancyfoot[RO]{{\vrule height 10pt width 1pt} \hspace{2pt} \ \thepage}
\fancyfoot[LE]{\thepage \ \hspace{2pt} {\vrule height 10pt width 1pt} \hspace{2pt}}
\renewcommand{\headrulewidth}{0pt} % Remove header rule
}
\fancypagestyle{ref}{%
  \fancyhf{}%
  \fancyfoot[RO]{\small\rightmark \ \ \hspace{2pt} {\vrule height 10pt width 1pt} \hspace{2pt} \ \thepage}%
  \fancyfoot[LE]{\small\thepage \ \ \hspace{2pt} {\vrule height 10pt width 1pt} \hspace{2pt} \ \leftmark}%
  \renewcommand{\headrulewidth}{0pt}% % Remove header rule
  \renewcommand{\chaptermark}[2][\chaptername~\thechapter]{\markboth{\lsstyle\MakeUppercase{##1}}{\lsstyle\uppercase{##2}}}%
}

% Margin
\newenvironment{changemargin}[2]{%
\begin{list}{}{%
\setlength{\topsep}{0pt}%
\setlength{\leftmargin}{#1}%
\setlength{\rightmargin}{#2}%
\setlength{\listparindent}{\parindent}%
\setlength{\itemindent}{\parindent}%
\setlength{\parsep}{\parskip}%
}%
\item[]}{\end{list}}

% Tabular
\usepackage{threeparttable}
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
\includepdfset{pagecommand=\thispagestyle{plain}}
\renewcommand{\TPTnoteSettings}{\footnotesize}
\renewcommand{\TPTnoteLabel}[1]{#1}

\usepackage{float}

% Rotate
\usepackage{pdflscape}
A. F.
  • 1,227
  • 1
  • 13
  • 21
  • 1
    There isn't any point in using \chaptermark* since you don't use that information in the headers or footers, and \renewcommand\chaptermark... isn't really doing anything either. – cfr Aug 15 '15 at 12:22
  • I see. I have now tried a lot different things without luck. Do you have any idea of what I should do? – A. F. Aug 15 '15 at 12:23
  • 1
    For the appendices, you seem to want them numbered (but with an alphabetical number) rather than unnumbered. If you use e.g. \leftmark or \rightmark in the headers, then you can set the marks explicitly and you will have some effect. Else you need some alternative mechanism which doesn't involve manipulating the marks. – cfr Aug 15 '15 at 12:26
  • It is my footer - not header. I have both tried \leftmark{References}, \rightmark{References} and \markboth{References}{} - without luck. – A. F. Aug 15 '15 at 12:30
  • 2
    You are using \leftmark but you are not using \rightmark ever in the footer configuration. But, also, what is \bibliography{References} supposed to do? This says that your .bib file is called References.bib but you don't declare a bibliography style (BibTeX) or use \printbibliography (Biblatex). How are you managing references? – cfr Aug 15 '15 at 12:36
  • I am using natbib - It was a mistake to delete it from preamble. Every second footers is the "Chapter I (.ie.)" and every other second footer is a name, that I marked by using \chaptermark*{name}. If that makes sense? – A. F. Aug 15 '15 at 12:44
  • If I could marked every footers in references and appendice with "References" or "Appendix", that would be perfect. – A. F. Aug 15 '15 at 12:44
  • 1
    I'm not really clear why you need ref as well as MyStyle. Note that \small does not take an argument. Also \addcontentsline... and \chaptermark[References]{References} should come before \bibliography{} - not after. – cfr Aug 16 '15 at 12:06
  • Hmm cfr. Can I send you my preamble? I have tried to copy/paste preamble into mine, but I guess something in my preamble block for the appendix or \chapter*{}-function. I can't see what it should be. – A. F. Aug 16 '15 at 14:14
  • 1
    You can just edit your question. But, better, is to make an MWE. You can just remove or comment stuff in the preamble until you find the source of the problem - most of it is probably irrelevant. – cfr Aug 16 '15 at 14:22
  • I have tried - and I have now excluded some of irrelevant stuff in my preamble. I can't figure out what's wrong in my preamble. – A. F. Aug 16 '15 at 15:12
  • I wouldn't use tabu unless you don't mind your document suddenly breaking at some future point. The author has promised backwards-incompatible changes and will not fix serious bugs in the meantime. I'm guessing that the titlesec/titlecontents stuff is responsible for things not working as you expect. Try commenting those out just to help with diagnosis. – cfr Aug 16 '15 at 16:21
  • You are using 2 competing packages to manage headers and footers: fancyhdr and titleps. Use one or the other - not both. – cfr Aug 16 '15 at 16:23
  • titleps is the same as titlesec? or which part are you referring to? Because the code below "Chapter" is necessary for the position of chapters on the page. – A. F. Aug 16 '15 at 16:40
  • You are passing pagestyles to titlesec, which loads titleps. This isn't bad but you should use it instead of fancyhdr, if you wish to, rather than in addition since you don't want two packages competing with each other to configure the same document elements. – cfr Aug 16 '15 at 18:56
  • @A.F. Have you eventually found a solution for this question :-) ? – MarcoG Sep 29 '15 at 07:34

2 Answers2

2

Possibly this might be a helpful beginning which I've expanded a bit in light of the additional information about your bibliography. Note that I had to expand your example considerably in order to reproduce this as yours did not provide the resources required. Also, I had to invent a definition for \lsstyle.

This customises the footers as requested, as far as I can tell. \leftmark and \rightmark are used for this and \chaptermark is redefined to accept an optional argument which is used to specify the second mark for unnumbered chapters.

Note that \chaptermark*{Introduction} sets * as the mark and then prints Introduction in the body of the document. This is probably not what you want. I've therefore removed or modified these commands.

The \clearpage -> add to contents and set marks -> print bibliography works fine, as far as I can tell. Note that the bibliography is created as a \chapter by default so you don't need to do anything to special.

It would make more sense to have LaTeX number the appendices but it certainly works this way - just more manual markup than is required, so you have to be careful things stay consistent.

Note that the \section commands also set marks in both your original example and this one - I'm not clear if you want that or not.

\begin{filecontents*}{refs.bib}
@book{bk1,
  author    =   {Aardvark, A. N.},
  year      =   1978,
  title     =   {Favourite Yards and Parks},
  publisher =   {Varks 'R Us},
  address   =   {Here, There and Everywhere, Planet Earth, Solar System, Milky Way Galaxy, This Universe}}
@book{bk2,
  author    =   {Aardvark, A. N.},
  year      =   1978,
  title     =   {Favourite Yards and Parks},
  publisher =   {Varks 'R Us},
  address   =   {Here, There and Everywhere, Planet Earth, Solar System, Milky Way Galaxy, This Universe}}
@book{bk3,
  author    =   {Aardvark, A. N.},
  year      =   1978,
  title     =   {Favourite Yards and Parks},
  publisher =   {Varks 'R Us},
  address   =   {Here, There and Everywhere, Planet Earth, Solar System, Milky Way Galaxy, This Universe}}
@book{bk4,
  author    =   {Aardvark, A. N.},
  year      =   1978,
  title     =   {Favourite Yards and Parks},
  publisher =   {Varks 'R Us},
  address   =   {Here, There and Everywhere, Planet Earth, Solar System, Milky Way Galaxy, This Universe}}
@book{bk5,
  author    =   {Aardvark, A. N.},
  year      =   1978,
  title     =   {Favourite Yards and Parks},
  publisher =   {Varks 'R Us},
  address   =   {Here, There and Everywhere, Planet Earth, Solar System, Milky Way Galaxy, This Universe}}
@book{bk6,
  author    =   {Aardvark, A. N.},
  year      =   1978,
  title     =   {Favourite Yards and Parks},
  publisher =   {Varks 'R Us},
  address   =   {Here, There and Everywhere, Planet Earth, Solar System, Milky Way Galaxy, This Universe}}
@book{bk7,
  author    =   {Aardvark, A. N.},
  year      =   1978,
  title     =   {Favourite Yards and Parks},
  publisher =   {Varks 'R Us},
  address   =   {Here, There and Everywhere, Planet Earth, Solar System, Milky Way Galaxy, This Universe}}
@book{bk8,
  author    =   {Aardvark, A. N.},
  year      =   1978,
  title     =   {Favourite Yards and Parks},
  publisher =   {Varks 'R Us},
  address   =   {Here, There and Everywhere, Planet Earth, Solar System, Milky Way Galaxy, This Universe}}
@book{bk9,
  author    =   {Aardvark, A. N.},
  year      =   1978,
  title     =   {Favourite Yards and Parks},
  publisher =   {Varks 'R Us},
  address   =   {Here, There and Everywhere, Planet Earth, Solar System, Milky Way Galaxy, This Universe}}
@book{bk10,
  author    =   {Aardvark, A. N.},
  year      =   1978,
  title     =   {Favourite Yards and Parks},
  publisher =   {Varks 'R Us},
  address   =   {Here, There and Everywhere, Planet Earth, Solar System, Milky Way Galaxy, This Universe}}
@book{bk11,
  author    =   {Aardvark, A. N.},
  year      =   1978,
  title     =   {Favourite Yards and Parks},
  publisher =   {Varks 'R Us},
  address   =   {Here, There and Everywhere, Planet Earth, Solar System, Milky Way Galaxy, This Universe}}
@book{bk12,
  author    =   {Aardvark, A. N.},
  year      =   1978,
  title     =   {Favourite Yards and Parks},
  publisher =   {Varks 'R Us},
  address   =   {Here, There and Everywhere, Planet Earth, Solar System, Milky Way Galaxy, This Universe}}
\end{filecontents*}
\documentclass[12pt,a4paper,twoside]{report}
% Page layout
\usepackage[bindingoffset=0mm]{geometry}

% Random text
\usepackage{lipsum}

% Page style
\usepackage{fancyhdr}

% References
\usepackage[round, colon, sort, authoryear]{natbib}

\DeclareRobustCommand\lsstyle{\normalfont}

% Defining the DEFAULT style
\fancypagestyle{MyStyle}{%
  \fancyhf{}%
  \fancyfoot[RO]{\small\rightmark \ \ \hspace{2pt} {\vrule height 10pt width 1pt} \hspace{2pt} \ \thepage}%
  \fancyfoot[LE]{\small\thepage \ \ \hspace{2pt} {\vrule height 10pt width 1pt} \hspace{2pt} \ \leftmark}%
  \renewcommand{\headrulewidth}{0pt}% % Remove header rule
  \renewcommand{\chaptermark}[2][\chaptername~\thechapter]{\markboth{\lsstyle\MakeUppercase{##1}}{\lsstyle\uppercase{##2}}}%
}
% Redefining the PLAIN style
\fancypagestyle{plain}{%
  \fancyhead{}% %Clean headers
  \fancyfoot{}% %Clean footers
  \fancyfoot[RO]{{\vrule height 10pt width 1pt} \hspace{2pt} \ \thepage}%
  \fancyfoot[LE]{\thepage \ \hspace{2pt} {\vrule height 10pt width 1pt} \hspace{2pt}}%
  \renewcommand{\headrulewidth}{0pt}% % Remove header rule
}

\begin{document}
\pagestyle{plain}
...pages in plain style...
\tableofcontents
\clearpage
\pagestyle{MyStyle}
\chapter{Introduction}
\section{First section}
\lipsum
\section{Second section}
\lipsum
\chapter{Second chapter title}
\section{Third section}
\lipsum
\section{Fourth section}
\lipsum

\nocite{*}
\clearpage
\renewcommand*\bibname{References}
\addcontentsline{toc}{chapter}{References}
\bibliographystyle{plainnat}
\bibliography{refs}

\clearpage
\appendix
\chapter*{Appendix A}
\addcontentsline{toc}{chapter}{Appendix A}
\chaptermark[Appendix A]{Appendix A}
\lipsum\lipsum
\end{document}

marks for thesis

EDIT EDIT

Here's the same example with a minimised and modified version of your updated preamble. That is, I minimised the code required to reproduce the issue (more-or-less - might not be entirely minimal) and then corrected it to avoid the problems reported.

The key changes are as follows:

  • don't define ref pagestyle as this is not needed since \chaptermark is redefined in my earlier code to accommodate both the style for the body of the thesis and the references and appendices;

  • don't pass pagestyles to titlesec and load titlesec only once - if starting over, it would be better to keep titleps and drop fancyhdr, but since the code is already customised for your needs, this seems like unnecessary work.

Hence:

\documentclass[a4paper,11pt,twoside]{report}
\usepackage[left=3.5cm,right=3.5cm,top=3.4cm,bottom=3.4cm]{geometry}
\usepackage{lipsum}
\usepackage[T1]{fontenc}
\usepackage[lf]{MinionPro} %% MinionPro
\usepackage[protrusion=true,expansion=true]{microtype}
\SetTracking[no ligatures = {f}]{encoding = }{100}

% Chapter
\usepackage[newparttoc, explicit]{titlesec}%
\usepackage{titletoc}
\titleformat{name=\chapter}[display]{\figureversion{lining}}{\lsstyle\Large\MakeUppercase\chaptername\enspace \LARGE\thechapter}{2ex}{\LARGE\bfseries#1}%\uppercase
\titleformat{name=\chapter, numberless}{\lsstyle\LARGE}{}{0pt}{\MakeUppercase{#1}} \titlespacing{\chapter}{0pt}{2.5ex}{6ex}

% Table of Contents
\titlecontents{chapter}[0em]{\large\bfseries\protect\addvspace{15pt}}%\thecontentslabel\brlap[1.25\baselineskip]
{\textssc{\mdseries\MakeLowercase\chaptername~{\footnotesize\thecontentslabel}}\\\medskip}
{}%
{\hfill\contentspage}%
\addtocontents{toc}{\protect\thispagestyle{empty}}

% References
\usepackage[round, colon, sort, authoryear]{natbib}
\setlength{\bibsep}{0.0pt}
\setlength{\bibhang}{2em}
\bibpunct{(}{)}{;}{a}{}{}
\setcitestyle{notesep={: }}
\def\citeapos#1{\citeauthor{#1}'s (\citeyear{#1})}

% Page style
\usepackage{fancyhdr}
% Defining the DEFAULT style
\fancypagestyle{MyStyle}{%
  \fancyhf{}%
  \fancyfoot[RO]{\small\rightmark \ \ \hspace{2pt} {\vrule height 10pt width 1pt} \hspace{2pt} \ \thepage}%
  \fancyfoot[LE]{\small\thepage \ \ \hspace{2pt} {\vrule height 10pt width 1pt} \hspace{2pt} \ \leftmark}%
  \renewcommand{\headrulewidth}{0pt}% % Remove header rule
  \renewcommand{\chaptermark}[2][\chaptername~\thechapter]{\markboth{\lsstyle\MakeUppercase{##1}}{\lsstyle\uppercase{##2}}}%
}
% Redefining the PLAIN style
\fancypagestyle{plain}{%
  \fancyhf{}% %Clean headers, footers
  \fancyfoot[RO]{{\vrule height 10pt width 1pt} \hspace{2pt} \ \thepage}%
  \fancyfoot[LE]{\thepage \ \hspace{2pt} {\vrule height 10pt width 1pt} \hspace{2pt}}%
  \renewcommand{\headrulewidth}{0pt}% % Remove header rule
}

\begin{document}
\pagestyle{plain}
...pages in plain style...
\tableofcontents
\clearpage
\pagestyle{MyStyle}
\chapter{Introduction}
\section{First section}
\lipsum
\section{Second section}
\lipsum
\chapter{Second chapter title}
\section{Third section}
\lipsum
\section{Fourth section}
\lipsum

\nocite{*}
\clearpage
\renewcommand*\bibname{References}
\addcontentsline{toc}{chapter}{References}
\bibliographystyle{plainnat}
\bibliography{refs}

\clearpage
\appendix
\chapter*{Appendix A}
\addcontentsline{toc}{chapter}{Appendix A}
\chaptermark[Appendix A]{Appendix A}
\lipsum\lipsum
\end{document}

adapted preamble with MWE based on OP's update

cfr
  • 198,882
  • I am using BibTeX - more precisely \usepackage{natbib}. Is that information enough? Hmm. I have now updated my preamble - my MyStyle - but that doesn't work. It should be similar to yours? or? – A. F. Aug 15 '15 at 13:05
  • Is the difference this line: \renewcommand{\chaptermark}[1]{\markboth{\MakeUppercase{\chaptername}\ \thechapter}{\uppercase{##1}}} } – A. F. Aug 15 '15 at 13:09
  • 1
    @A.F. That and the fact that I then use \rightmark in the definition of the footer, as well as \leftmark. This should work for the appendix, at least. The bibliography is a bit different because you need to control what happens as the bibliography is printed and not just what happens after that (assuming you have more than one page of references). – cfr Aug 15 '15 at 13:36
  • 1
    @A.F. You could just say \clearpage\markboth{References}{References} and then \bibliography... etc. – cfr Aug 15 '15 at 13:37
  • I have several pages in the bibliography, yes. Is it possible to make the both marks in footer "References"? Or is it difficult? – A. F. Aug 15 '15 at 13:38
  • I have now updated my preamble - and defining "MyStyle" and "PLAIN" style. I have tried to compare your suggestion with mine, but it won't show appendix and references. Is there a manual way of creating these footers afterwards? – A. F. Aug 15 '15 at 13:48
  • @A.F. Before implementing clea's answer into your document, copy the whole code, write it to file afFooterTest.bib and compile, see if it works. If it does, start comparing line by line with your own document. – Johannes_B Aug 15 '15 at 14:20
  • Dear Johannes_B. I have tried. It won't work with my bibliography. – A. F. Aug 15 '15 at 14:22
  • My question is, whether is is possible to create two pagestyles in the same document? and whether it is possiblee to make appendix and bibliography as a chapter? – A. F. Aug 15 '15 at 14:31
  • 2
    @A.F. Please see edit. If you want to ping somebody, use th @ symbol followed by the user name. The appendix and references are typeset as chapters by default - you don't need to do anything special to get this - report.cls just does it that way. You can use as many page styles as you wish. Standard classes support three by default (empty, plain, headings) but you can create additional ones (e.g. MyStyle) and redefine existing ones (e.g. plain) as you do here. – cfr Aug 15 '15 at 21:08
  • @cfr - By using your updated code, my "References" works, but it won't show my Appendix A in footer. I have been using your example and it works perfect with the references. I have updated my question for showing you my preamble and text. I really can't see, what I am doing wrong here. – A. F. Aug 16 '15 at 06:48
  • Sorry for not using @ - @cfr – A. F. Aug 16 '15 at 06:49
  • 1
    @A.F. I really meant for Johannes_B. I actually get pinged anyway because you're commenting on an answer which is mine. (The system is horribly opaque and fails to mention any of this, of course.) – cfr Aug 16 '15 at 11:53
  • 1
    @A.F. If you compile just the code I've posted with nothing else and no changes, does it work? Because, as you can see, I get the appendix showing up just fine in the footer. – cfr Aug 16 '15 at 11:55
  • 1
    @Johannes_B I think you meant a .tex file rather than a .bib? – cfr Aug 16 '15 at 11:56
  • Oh, sure. I meant testing your code as is in a separate tex file. @A.F. We (well, cfr) need to know if the example works on your machine as it works for us. – Johannes_B Aug 16 '15 at 12:09
  • @A.F. See edit above. – cfr Aug 16 '15 at 19:50
0

Since this question uses the code from a previous answer of mine and the OP still does not have a code that is working in his document, I'll give it a try.

First of all I don't fully understand your preamble (e.g. as @Cfr stated, there's no definition of \lsstyle), therefore I'll base my answer on your initial code.

In my previous answer (Page numbers incl. text (different side)) I defined a default pagestyle for the whole document and redefined the plain for the sake of consistency. For the References, and Appendices, I did the same. This could be not the best way, or could be even superfluous, but in this way one can easily find all the document's styles in the same place.

The code that produces the desired output is:

\documentclass[12pt,a4paper,twoside]{report}

% Page layout
\usepackage[bindingoffset=0mm]{geometry}

% Random text
\usepackage{lipsum}

% Page style
\usepackage{fancyhdr}

% Defining the DEFAULT style
\fancypagestyle{MyStyle}{%
\fancyhead{} %Clean headers
\fancyfoot{} %Clean footers
\fancyfoot[RO]{\leftmark \ {\vrule height 13pt width 1pt}  \thepage}
\fancyfoot[LE]{\thepage \ {\vrule height 13pt width 1pt} \MakeUppercase{\chaptername}\ \thechapter}
\renewcommand{\headrulewidth}{0pt} % Remove header rule
\renewcommand{\chaptermark}[1]{\markboth{\uppercase{##1}}{}}
}
% Redefining the PLAIN style
\fancypagestyle{plain}{%
\fancyhead{} %Clean headers
\fancyfoot{} %Clean footers
\fancyfoot[RO]{{\vrule height 13pt width 1pt} \ \thepage}
\fancyfoot[LE]{\thepage \ {\vrule height 13pt width 1pt}}
\renewcommand{\headrulewidth}{0pt} % Remove header rule
}
% Defining the REFERENCES style
\fancypagestyle{Ref}{%
\fancyhead{} %Clean headers
\fancyfoot{} %Clean footers
\fancyfoot[RO]{\uppercase{References} \ {\vrule height 13pt width 1pt}  \thepage}
\fancyfoot[LE]{\thepage \ {\vrule height 13pt width 1pt} \ \uppercase{References}}
\renewcommand{\headrulewidth}{0pt} % Remove header rule
}
% Defining the APPENDIX style
\fancypagestyle{App}{%
\fancyhead{} %Clean headers
\fancyfoot{} %Clean footers
\fancyfoot[RO]{\uppercase{Appendix A} \ {\vrule height 13pt width 1pt}  \thepage}
\fancyfoot[LE]{\thepage \ {\vrule height 13pt width 1pt} \ \uppercase{Appendix A}}
\renewcommand{\headrulewidth}{0pt} % Remove header rule
}

\begin{document}

\pagestyle{plain}
...pages in plain style...
\pagestyle{MyStyle}
\chapter{Introduction}
\chaptermark{Introduction}
\section{First section}
\lipsum
\section{Second section}
\lipsum
\chapter{Second chapter title}
\section{Third section}
\lipsum
\section{Fourth section}
\lipsum
\clearpage

\pagestyle{Ref}
\chapter*{References}
\addcontentsline{toc}{chapter}{References}
\lipsum  %...your bibliography goes here


\clearpage
\appendix
\pagestyle{App}
\chapter*{Appendix A}
\addcontentsline{toc}{chapter}{Appendix A}

\lipsum
\end{document}

However, I have some remarks:

  • using \chapter*{} for the references is fine, since they are not a proper chapter and, above all, you'll use it only once (usually);
  • on the contrary, the Appendix is a chapter, i.e. usually it has its own title, and probably you'll have more than one appendix; in this case, the code above won't work, since the footer will be "APPENDIX A" even in Appendix B, and so on.

Of course, these are only my opinions, since if you have only one appendix the code will work fine. However, if this is not the case, you may want to use this code:

\documentclass[12pt,a4paper,twoside]{report}

% Page layout
\usepackage[bindingoffset=0mm]{geometry}

% Random text
\usepackage{lipsum}

% Page style
\usepackage{fancyhdr}

% Defining the DEFAULT style
\fancypagestyle{MyStyle}{%
\fancyhead{} %Clean headers
\fancyfoot{} %Clean footers
\fancyfoot[RO]{\leftmark \ {\vrule height 13pt width 1pt}  \thepage}
\fancyfoot[LE]{\thepage \ {\vrule height 13pt width 1pt} \MakeUppercase{\chaptername}\ \thechapter}
\renewcommand{\headrulewidth}{0pt} % Remove header rule
\renewcommand{\chaptermark}[1]{\markboth{\uppercase{##1}}{}}
}
% Redefining the PLAIN style
\fancypagestyle{plain}{%
\fancyhead{} %Clean headers
\fancyfoot{} %Clean footers
\fancyfoot[RO]{{\vrule height 13pt width 1pt} \ \thepage}
\fancyfoot[LE]{\thepage \ {\vrule height 13pt width 1pt}}
\renewcommand{\headrulewidth}{0pt} % Remove header rule
}
% Defining the REFERENCES style
\fancypagestyle{Ref}{%
\fancyhead{} %Clean headers
\fancyfoot{} %Clean footers
\fancyfoot[RO]{\uppercase{References} \ {\vrule height 13pt width 1pt}  \thepage}
\fancyfoot[LE]{\thepage \ {\vrule height 13pt width 1pt} \ \uppercase{References}}
\renewcommand{\headrulewidth}{0pt} % Remove header rule
}
% Defining the APPENDIX style
\fancypagestyle{App}{%
\fancyhead{} %Clean headers
\fancyfoot{} %Clean footers
\fancyfoot[RO]{\leftmark \ {\vrule height 13pt width 1pt}  \thepage}
\fancyfoot[LE]{\thepage \ {\vrule height 13pt width 1pt} \MakeUppercase{\chaptername}\ \thechapter}
\renewcommand{\chaptername}{Appendix}
\renewcommand{\headrulewidth}{0pt} % Remove header rule
\renewcommand{\chaptermark}[1]{\markboth{\uppercase{##1}}{}}
}

\begin{document}

\pagestyle{plain}
...pages in plain style...
\pagestyle{MyStyle}
\chapter{Introduction}
\chaptermark{Introduction}
\section{First section}
\lipsum
\section{Second section}
\lipsum
\chapter{Second chapter title}
\section{Third section}
\lipsum
\section{Fourth section}
\lipsum
\clearpage

\pagestyle{Ref}
\chapter*{References}
\addcontentsline{toc}{chapter}{References}
\lipsum  %...your bibliography goes here


\cleardoublepage
\pagestyle{App}
\appendix
\chapter{First appendix title}
\lipsum

\chapter{Second appendix title}
\lipsum

\end{document}

You could try the code you like in your document with your full preamble and see if it works fine.

MarcoG
  • 1,437