3

The code that I use for the header and footer in the article format is as follows:

\usepackage{fancyhdr}

\pagestyle{fancy}
\fancyhf{}
\rhead{}
\lhead{Project tile}
\renewcommand{\headrulewidth}{2.0pt}
\renewcommand{\footrulewidth}{1.0pt} 
\rfoot{Page \thepage}
\lfoot{\leftmark}

The problem is that this also prints the formatting that I've put to the section name to make it stand out:

\section{\LARGE{\textbf{Introduction}}}

This just increases the size, and makes the section name bold. So how do I put the current section name in the footer, without the footer name also being big and bold.

5

You're following the wrong approach. You should avoid setting sectional formatting inside the title, since this would make its way into the marks (typically used in headers/footers) and also the ToC, which is not ideal.

Instead, use something like sectsty to format your sectional fonts (see Change size of section, subsection, subsubsection, paragraph and subparagraph title):

enter image description here

\documentclass{article}

\usepackage{sectsty,fancyhdr}
\sectionfont{\LARGE\bfseries}% https://tex.stackexchange.com/q/59726/5764

\pagestyle{fancy}
\fancyhf{}
\lhead{Project tile}
\renewcommand{\headrulewidth}{2.0pt}
\renewcommand{\footrulewidth}{1.0pt} 
\rfoot{Page \thepage}
\lfoot{\leftmark}

\makeatletter
\renewcommand{\sectionmark}[1]{%
  \markboth{\ifnum \c@secnumdepth>\z@
      \thesection\hskip 1em\relax
    \fi #1}{}}
\makeatother

\begin{document}

\tableofcontents

\section{Introduction}

\end{document}

Above I also updated the \sectionmark macro to avoid inserting \MakeUppercase as part of the default construction. You can remove that if necessary.

  • Unfortunately I can't use a table of contents for the project that I'm doing, e.g. its just the section name and then the text. So how would I change the code above to do that. Also what does the code between \makeatletter and \makeaother do? – UniStuffz Nov 6 '16 at 19:45
  • @UniStuffz: You can just remove \tableofcontents. I added it just to show that the formatting of the section title doesn't transfer into the ToC. The \makeatletter...\makeatother pair allows the use of @ inside macro names - something that is typically reserved for low-level programming. See What do \makeatletter and \makeatother do? – Werner Nov 6 '16 at 19:50
  • this worked perfectly thank you, usually I stay over at maths stack exchange, but thanks for answering my first question here. – UniStuffz Nov 6 '16 at 20:28
2

If you use a KOMA-class (scrartcl and so on) you can accomplish this without fancyhdr and with scrlayer-scrpage.

\documentclass{scrartcl}

\usepackage{scrlayer-scrpage}
\usepackage{lipsum}

\setkomafont{section}{<formatting>}% changes the formatting of headlines
\KOMAoptions{%
    headsepline=2pt,
    footsepline=1pt
}

\ihead{Project title}
\chead{}% if you leave this out the pagehead will contain the sectionnames, too
\ifoot{\headmark}% the i is for inner side of the page if you use twoside and left side if you use oneside
\cfoot{}% if you leave this out the pagenumber will be in the center, too
\ofoot{Page \pagemark}
\automark[section]{section}
\pagestyle{scrheadings}

\begin{document}
\section{foo}
\lipsum[1-10]
\end{document}

You might use \cfoot or \ofoot as an alternative to \ifoot. If you want those to be in the head just use \ihead, \chead or \ohead.

EDIT: Added the head- and footsepline.

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.