1

I am writing the thesis. I want to add page number in right side of page header and in left side of header i want to write the chapter name. I use the following commands but it does not work.

   \documentclass[letterpaper,12pt,titlepage,oneside,final]{article}
    \usepackage{fancyhdr}
    \fancyhead{}  % Clears all page headers and footers

    \pagestyle{fancy}
    \lhead{}
    \rhead{\thepage}
    \cfoot{center of the footer!}
    \renewcommand{\headrulewidth}{0.4pt}
    \renewcommand{\footrulewidth}{0.4pt}

\begin{document}   
     \lhead{\emph{chapter1}}
        \input{chapter1/introduction}
        \lhead{\emph{chapter1}}
        \input{chapter2/name}
        \lhead{\emph{chapter3}}
        \input{chapter3/name2}
        \lhead{\emph{chapter3}}
        \input{chapter4/name3}
     \end{document} 
  • 2
    your question is unrelated to texstudio or ubuntu (tex works the same way whichever editor you use to write the source file) so I have removed the tags (but left the title) – David Carlisle Jul 14 '17 at 19:52
  • 2
    it is hard to answer your question as there are many "thesis" styles and you give no indication of yours so no one can run your example (which also inputs files we do not have) but all the \lhead within the document should be removed, the \chapter will be setting a mark to put the chapter name in the head automatically. – David Carlisle Jul 14 '17 at 19:55
  • Using lhead so often is rubbish, your \chapter calls should update the header. On the other hand, article does not provide chapters. – Johannes_B Aug 12 '17 at 10:12
1

If i understand the question correctly, the following is what you are looking for.

\documentclass[letterpaper,12pt,titlepage,oneside,final]{report}
\usepackage{fancyhdr}
\usepackage{blindtext}
\fancyhead{}  % Clears all page headers and footers

\setlength{\headheight}{15pt}
\pagestyle{fancy}
\fancyhead[r]{\thepage}
\fancyhead[l]{\fancyplain{\fancy}{\slshape\leftmark}}
\fancyfoot[c]{center of the footer!}
\fancypagestyle{plain}{%
\fancyhf{} % clear all header and footer fields
\fancyhead[r]{\thepage}
\fancyfoot[c]{center of the footer}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}

\renewcommand{\chaptermark}[1]{\markboth{\itshape\chaptername~\thechapter}{}}
\begin{document}   
\chapter{Wombat}
\blindtext[5]
\section{tabmow}
\blindtext[5]
\chapter{Capybara}
\blindtext[5]
\section{arabypac}
\blindtext[5]
\chapter*{Mara}
\markboth{Mara}{}
\blindtext[5]
\section{aram}
\blindtext[5]
\end{document} 
1

Something like this does what you want I think.

enter image description here

\documentclass[oneside]{report}
\usepackage{fancyhdr}
\pagestyle{fancy}
\lhead{\leftmark}
\rhead{\thepage}

\begin{document}

\chapter{Aaaaa}
\section{fooo}
zzzz
\clearpage
\section{fooooo}
zzzz

\chapter{Bbbbb}
\section{fooo}
zzzz
\clearpage
\section{baaaar}
zzzz


\end{document}
  • Your code does not work – sam Jul 14 '17 at 20:46
  • My thesis display page number on bottom of page. This code does not work – sam Jul 14 '17 at 20:48
  • 3
    @sam yes my code does work, did you try the document that I posted? It makes the page heading shown in the image. If your document is doing something else then some code you have not shown is setting the page head and foot after the settings that I suggest, but as you have not provided any example document or shown any code it is hard to help more than show a working example, as above. – David Carlisle Jul 14 '17 at 21:02
  • It's work in windows latex. But does not work in ubuntu texstudio. And windows latex not supported some packages. – sam Jul 16 '17 at 20:26
  • @sam No. tex works and produces identical output in windows and linux, the editor you use to write the source (texstudio or emacs or notepad or..) makes no difference whatsoever. It may be you have an old distribution (but neither report nor fancyhdr has changed in ways that affect this since last century. Add \listfiles to your document, and compare the package versions on windows and linux. – David Carlisle Jul 16 '17 at 20:34

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.