2

I try to add numbering at the bottom of each page, using the code shown below. But I found that the page number appears in the header, with the Outline of Proposed Research, rather than at the bottom of each page. How to edit it?

\documentclass[12pt]{article}
\usepackage[margin=0.75in]{geometry}
\usepackage{mathptmx}

\pagestyle{headings} \markboth{}{ Outline of Proposed Research}

\setcounter{secnumdepth}{0} \pagenumbering{arabic} \setlength{\parindent}{0pt} \linespread{1.0}

\begin{document} ... \end{document}

Mico
  • 506,678
Hermi
  • 231
  • 1
  • 6
  • 2
    Take a look at e.g. fandyhdr. – cfr Sep 20 '23 at 05:19
  • 1
    \pagestyle{plain} also puts the page number at the bottom of the page, but no headers. Actually, you don't need any packages to create your own page style (such as \ps@myheader) – John Kormylo Sep 20 '23 at 13:01

3 Answers3

3

As @cfr has suggested in a comment, you should take a look at the fancyhdr package and its user macros.

The following code

\documentclass[12pt]{article}
\usepackage[margin=0.75in]{geometry}
\usepackage{mathptmx}

\usepackage{fancyhdr} % First, define desired elements of the 'fancy' page style: \fancyhead[R]{Outline of Proposed Research} % top-right \renewcommand{\headrule}{} % no header rule \fancyfoot[C]{\thepage} % bottom-center \pagestyle{fancy} % Second, switch to this 'fancy' page style

\usepackage{lipsum} % filler text

\begin{document} \lipsum[1-14] % 2 pages of filler text \end{document}

produces the output shown below. Note that I've highlighted the running header ("Outline of Proposed Research") at the upper right and the page numbers at bottom-center. You're obviously free to adjust the placement of these document elements to suit your needs.

enter image description here

Mico
  • 506,678
3

There are several packages to configure the page header and footer. Mico has already shown an example using fancyhdr. Here one with scrlayer-scrpage:

\documentclass[12pt]{article}
\usepackage[margin=0.75in]{geometry}
\usepackage{mathptmx}

\usepackage[manualmark,pagestyleset=KOMA-Script]{scrlayer-scrpage} \markright{Outline of Proposed Research}% set the \rightmark to "Outline of Proposed Research"

\setcounter{secnumdepth}{0} %\pagenumbering{arabic}% default and therefore not needed %\setlength{\parindent}{0pt}% not recommended → https://sourceforge.net/p/koma-script/wiki-en/HowTo_NoParIndent/ … \usepackage{parskip}% … is the better solution to not indent the first line of a paragraph %\linespread{1.0}% default and therefore not needed

\usepackage{mwe}

\begin{document} \blinddocument \end{document}

scrlayer-scrpage solution with centered manual header and centered page number in the footer

Note: \markright does not set the right mark of the page header, but the right part of the standard LaTeX mark originally (e.g. with page style myheadings or headings of the standard classes) supposed to be used for right (odd) pages. On single-sided documents, this mark is by default used for odd and even pages. See a LaTeX introduction or the KOMA-Script manual for more information about \markright and \markboth. See the KOMA-Script manual also for information about \markdouble, which could be used here instead of \markright and which could be useful for double-sided documents (e.g., if using class option twoside).

In your case only the two lines

\usepackage[manualmark,pagestyleset=KOMA-Script]{scrlayer-scrpage}
\markright{Outline of Proposed Research}

are needed, because it seems, that the predefined page style set KOMA-Script already shows the wanted result with a head mark in the middle of the page header and pagination in the middle of the footer. In other cases, more configuration could be needed.

Using titleps would also be possible:

\documentclass[12pt]{article}
\usepackage[margin=0.75in]{geometry}
\usepackage{mathptmx}

\usepackage{titleps} \newpagestyle{outline}{ \sethead{}{Outline of Proposed Research}{}% header {left}{center}{right} \setfoot{}{\thepage}{}% footer {left}{center}{right} } \pagestyle{outline}

\setcounter{secnumdepth}{0} %\pagenumbering{arabic}% default and therefore not needed %\setlength{\parindent}{0pt}% not recommended → https://sourceforge.net/p/koma-script/wiki-en/HowTo_NoParIndent/ … \usepackage{parskip}% … is the better solution to not indent the first line of a paragraph %\linespread{1.0}% default and therefore not needed

\usepackage{mwe}

\begin{document} \blinddocument \end{document}

The result is the same as shown above.

cabohah
  • 11,455
1

Just another solution for the record: One could also use kernel macros to style the header and the footer. I created a new pagestyle hermisheading which is loaded as usual with \pagestyle{hermisheading} and produces the wanted output.

The shown code is very simple and overrides many other macros (\sectionmark,\@mkboth) to force the declared headings on every page. Thus, I do not recommend using it, its just an example. The packages proposed by @cabohah and @Mico offer much more sophisticated and understandable solutions.

But maybe the kernel code gives a better insight and supports understanding how these things work in the background (where they are much more elaborated: the code for pagestyle headings has nearly four times as many lines).

\documentclass[12pt]{article}
\usepackage[margin=0.75in]{geometry}

\makeatletter \if@twoside \def\ps@hermisheading{% \def@evenhead{\hfil\slshape\leftmark\hfil}% \def@oddhead{\hfil\slshape\rightmark\hfil}% \def@evenfoot{\hfil\thepage\hfil}% \def@oddfoot{\hfil\thepage\hfil}% } \else \def\ps@hermisheading{% \def@oddhead{\hfil\slshape\rightmark\hfil}% \def@oddfoot{\hfil\thepage\hfil}% } \fi \makeatother

\pagestyle{hermisheading}

\markboth{Outline of Proposed Research}{Outline of Proposed Research} % just in case you want to use it with a twosided document

\setcounter{secnumdepth}{0}

\setlength{\parindent}{0pt} \linespread{1.0}

\usepackage{blindtext}

\begin{document}

\tableofcontents

\blinddocument

\end{document}

lukeflo
  • 1,555