I am trying to set up a multi-file document where I use \input to add different .tex files to my main document. Each .tex file is in its own directory/folder. I have also created a .sty file which contains the preamble packages and code to set the style. When I compile the document, the style is inconsistent - the header and footer appears on some pages but not all.
When I compile with all of the code in a single document, the result is fine.
Can someone tell me how to fix this so that all my pages have the same header and footer format?
I attach the following MWE and images:
Main document
\documentclass[12pt,a4paper]{report}
\usepackage{graphicx}
% put all the other packages here:
\usepackage{My_style_package}
\usepackage{hyperref}
\begin{document}
%TITLE PAGE AND ABSTRACT
\input{./Title_and_abstract/Title_and_abstract.tex}
%\tableofcontents
%\listoffigures
%\listoftables
%\input{./Intro/Introduction_v0.1.tex}
\input{./Methods/Methods.tex}
%\maketitle
%\input{./tex/intro.tex}
%\input{./tex/main_part.tex}
%\input{./tex/conclusions.tex}
%\appendix
%\input{./tex/myappendix.tex}
% Bibliography:
%\clearpage
%\input{./tex/mybibliography.tex}
\end{document}
My style file
\ProvidesPackage{My_style_package}
\usepackage{color}
\usepackage{graphicx, epstopdf}
\usepackage{etoolbox}%This package combined with the \pathcmd rewrites the standard style for 'Chapter' to allow the fancy horizontal and vertical lines.
\patchcmd{\chapter}{\thispagestyle{plain}}{\thispagestyle{mystyle}}{}{}
\graphicspath{{"C:/Users/User/Documents/LaTex_issues/Test_for_linking_docs_from_differrent_folders/Visuals/"}}
\usepackage{gensymb}
\usepackage{times}
\usepackage{adjustbox}
\usepackage{tabulary}
\usepackage{tabularx}
\usepackage{longtable}
\usepackage{booktabs,caption, makecell}
\usepackage{pdflscape,afterpage,caption}
\usepackage[british]{babel}
\usepackage[backend=bibtex, citestyle=ieee, bibstyle=ieee]{biblatex}
\usepackage[section]{placeins}%Allows you to permanently fix figures.
\addbibresource{library}
\usepackage{titleps}%fancy page borders?
\usepackage[left=2.8cm, right=2.8cm, top=3.5cm, bottom=3.5cm]{geometry}
%\usepackage{caption}
\captionsetup[figure]{font=scriptsize,labelfont=scriptsize}
\usepackage{microtype}
\usepackage{setspace}
\usepackage{amsmath}
\usepackage{datetime}
\newdate{date}{28}{02}{2018}
\date{\displaydate{date}}
\onehalfspacing
\sloppy%Makes sure that none of the text exceeds text width. Useful if have long chemical words.
\newpagestyle{mystyle}{%
\widenhead[\marginparwidth][0pt]{0pt}{\marginparwidth}
\headrule
\sethead[~\color{black}\enspace][][]{}{}{\color{black}\enspace}
\setfoot[{\makebox[\marginparwidth][r]{\thepage~}\smash{\rule[-20ex]{0.6pt}{22ex}}}][][]{}{}{\smash{\rule[-20ex]{0.6pt}{22ex}}\makebox[\marginparwidth][l]{~\thepage}
}
}%This part creates the fancy top (horizontal) and bottom (verticle) lines that you see from the 'Abstrct' page onwards.
\renewcommand\chapter{\if@openright\cleardoublepage\else\clearpage\fi
\thispagestyle{mystyle}
\global\@topnum\z@
\@afterindentfalse
\secdef\@chapter\@schapter}
Example of linked input file - 1
%----------------------------------------------------------------------------------------
% TITLE PAGE
%----------------------------------------------------------------------------------------
\begin{titlepage} % Suppresses displaying the page number on the title page and the subsequent page counts as page 1
\newcommand{\HRule}{\rule{\linewidth}{0.5mm}} % Defines a new command for horizontal lines, change thickness here
\center % Centre everything on the page
%------------------------------------------------
% Headings
%------------------------------------------------
\textsc{\LARGE TEST TITLE}\\[1.5cm] % Main heading such as the name of your university/college
\textsc{\Large TEST NAME}\\[0.5cm] % Major heading such as course name
%\textsc{\large Minor Heading}\\[0.5cm] % Minor heading such as course title
%------------------------------------------------
% Title
%------------------------------------------------
\HRule\\[0.4cm]
{\huge\bfseries TITLE OF WORK}\\[0.4cm] % Title of your document
\HRule\\[1.5cm]
%------------------------------------------------
% Author(s)
%------------------------------------------------
%\begin{minipage}{0.4\textwidth}
%\begin{flushleft}
%\large
%\textit{Author}\\
%Firstname\textsc{surname} % Your name
%\end{flushleft}
%\end{minipage}
~
%\begin{minipage}{0.4\textwidth}
%\begin{flushright}
%\large
%\textit{Supervisor}\\
%Supervisor name \textsc{Surname} % Supervisor's name
%\end{flushright}
%\end{minipage}
% If you don't want a supervisor, uncomment the two lines below and comment the code above
{\large{NAME}}\\
\textsc{IDENTIFICATION} % Your name
%------------------------------------------------
% Date
%------------------------------------------------
\vfill\vfill\vfill % Position the date 3/4 down the remaining page
{\large\today} % Date, change the \today to a set date if you want to be precise
%------------------------------------------------
% Logo
%------------------------------------------------
%\vfill\vfill
%\includegraphics[width=0.2\textwidth]{placeholder.jpg}\\[1cm] % Include a department/university logo - this will require the graphicx package
%----------------------------------------------------------------------------------------
\vfill % Push the date up 1/4 of the remaining page
\end{titlepage}
\pagenumbering{roman}
\subsection*{\hfil Abstract\hfil}
\newpage
\tableofcontents
\newpage
\addcontentsline{toc}{section}{List of figures}
\listoffigures
\newpage
\addcontentsline{toc}{section}{List of tables}
\listoftables
\newpage
\addcontentsline{toc}{section}{Abbreviations}
\section*{Abbreviations}
%\begin{table}
% \setlength\tabcolsep{60pt}
% \centering
%\small
% your table
%\hspace*{-18mm}%
%\vspace{-5.5mm}%
\begin{longtable}{l l}
\toprule
{Abbreviation}&{Explanation}\\[0.5 ex]
\midrule
Acronym & Explanation \\
Acronym & Explanation \\
Acronym & Explanation \\
Acronym & Explanation \\
Acronym & Explanation \\
Acronym & Explanation \\
Acronym & Explanation \\
Acronym & Explanation \\
Acronym & Explanation \\
Acronym & Explanation \\
Acronym & Explanation \\
Acronym & Explanation \\
Acronym & Explanation \\
Acronym & Explanation \\
Acronym & Explanation \\
Acronym & Explanation \\
Acronym & Explanation \\
Acronym & Explanation \\
Acronym & Explanation \\
Acronym & Explanation \\
Acronym & Explanation \\
Acronym & Explanation \\
Acronym & Explanation \\
Acronym & Explanation \\
Acronym & Explanation \\
Acronym & Explanation \\
Acronym & Explanation \\
Acronym & Explanation \\
Acronym & Explanation \\
Acronym & Explanation \\
Acronym & Explanation \\
Acronym & Explanation \\
Acronym & Explanation \\
Acronym & Explanation \\
Acronym & Explanation \\
Acronym & Explanation \\
\bottomrule
\end{longtable}%
\hspace*{-12mm}%
\vspace{50mm}
\label{table:abbreviations}
%\end{table}
\newpage
Example of linked input file - 2
Save time in Word with new buttons that show up where you need them. To change the way a picture fits in your document, click it and a button for layout options appears next to it. When you work on a table, click where you want to add a row or a column, and then click the plus sign.
Reading is easier, too, in the new Reading view. You can collapse parts of the document and focus on the text you want. If you need to stop reading before you reach the end, Word remembers where you left off - even on another device.
\begin{figure}[h!]
\centering
\includegraphics[width=0.5\textwidth]{Testimage}%Since we have identified the graohic location we just need the file name.
\caption{Test image}
\end{figure}


\renewcommand\chapter{\if@openright\cleardoublepage\else\clearpage\fi \thispagestyle{mystyle} \global\@topnum\z@ \@afterindentfalse \secdef\@chapter\@schapter}but the problem remains. Replacing\section*{Abbreviations}with\chapter*{Abbreviations}fixes the first page of the table but not the second one. Does the\chapterpagestyle need to be completely rewritten? What I want to do is use the default page style seen in thearticledocument class and put it in myreportdocument class. Thanks. – Kevin May 17 '18 at 13:59