3

I'm still relatively with using LaTeX but I've done a lot of searching to try and fix my problem (may have not been enough).

My issue is that I am after the page number in the top right of the header on every page, the chapter # and title (i.e., "Chapter 1. Introduction") in the top left of the header on every page and the footers empty on every page.

Also trying to get roman numerals on everything from the title to the start of the chapters and normal numbering from then onwards.

The two files I have are a title page (done in the \begin{titlepage}) and the other is just a normal document done in the \chapter{}, etc.

Below is my code, any help would be appreciated as I've been trying different things for roughly a month now.

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

\usepackage{graphicx}
% using fancy heading and footing
\usepackage{fancyhdr}
% need lastpage package to print 'Page 1 of 2' in footer
\usepackage{lastpage}
\usepackage{epstopdf}
\usepackage{setspace}

\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\setlength{\parindent}{0in}
\begin{document}

\pagestyle{fancy}

\fancyhead[LE,LO]{\slshape \leftmark}
\fancyhead[RO,RE]{\thepage}
\fancyfoot{}
\newcommand{\HRule}{\rule{\linewidth}{0.5mm}}

\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\setlength{\parindent}{0in}

\input{./title_draft.tex}

\pagenumbering{roman}
\setcounter{tocdepth}{4}
\tableofcontents
\addcontentsline{toc}{chapter}{Contents}

\pagenumbering{arabic}
\input{./nom1.tex}

\end{document}
2
  • Welcome to TeX.sx! A tip: If you indent lines by 4 spaces, they'll be marked as a code sample. You can also highlight the code and click the "code" button (with "{}" on it).
    – jub0bs
    Apr 16, 2013 at 10:55
  • Many thanks for that, I was in the process of fixing it but you bet me to it.
    – JHoop
    Apr 16, 2013 at 11:05

1 Answer 1

1

I'd use the book class, which is almost the same as report when the oneside option is given. It makes easier switching the page numbering. In the example I included only the necessary package (that is, fancyhdr); kantlipsum and the definition of \achapter are just to build some text.

\documentclass[12pt,a4paper,oneside]{book}

\usepackage{fancyhdr}

\pagestyle{fancy}

\fancyhead[L]{\slshape \leftmark}
\fancyhead[R]{\thepage}
\fancyfoot{}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\setlength{\headheight}{14.5pt}

%%% The code up to the next %%% is just for the example
\usepackage{kantlipsum}
\newcommand{\achapter}{\chapter{A title}
 \kant[1]
 \section{A section}
 \subsection{A subsection}
 \subsubsection{A subsubsection}
 \kant[2-8]
 \section{A section}
 \subsection{A subsection}
 \subsubsection{A subsubsection}
 \kant[9-15]
 \section{A section}
 \subsection{A subsection}
 \subsubsection{A subsubsection}
 \kant[16-22]}
 %%%

\begin{document}
\frontmatter
\begin{titlepage}
\centering\vspace*{\fill}
\huge A title

\vfill
\end{titlepage}

\tableofcontents

\mainmatter

\achapter
\achapter
\achapter

\achapter
\achapter
\achapter

\achapter
\achapter
\achapter

\achapter
\achapter
\achapter

\end{document}
3
  • hey i've tried what you suggested changed it to book oneside. while it changes it when I run your example, if I put the code into my document, using oneside it doesn't display any header and just the default footer but if I change this to twoside (or remove oneside) the header works but there is a blank page inbetween each page.
    – JHoop
    Apr 16, 2013 at 11:42
  • @JHoop Sorry, but your problem surely depends on other settings.
    – egreg
    Apr 16, 2013 at 15:27
  • hey been meaning to reply to this earlier, when I got it working, it was my code but I managed to get it working with the report class rather than the book class. thanks a bunch
    – JHoop
    May 8, 2013 at 7:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .