2

I am writing a document in the book class. I am looking for a way to produce the following.

In one of my chapters, the sections carry a name, each of which can be summed up by only a few letters, for instance 'AA' or 'BC2'. Instead of the usual headings, I want each page to carry (in big size) the title of the section in the upper part of the page, on the left or on the right depending whether the page number is even or odd.

I have looked in the fancyhdr documentation, but I haven't found a way to produce such a result so far.

  • Can you please post the code for what you have tried so far? – JohnReed Apr 29 '12 at 22:23
  • Well, the point is that I have no such code because I have no idea how to do so. – Thomas Connor Apr 29 '12 at 22:57
  • By "upper part of the page" you mean the header? Is there enough space for the large font size you desire? And what's the problem with fancyhdr exactly? That you want this only for one particular chapter? – Christian Apr 29 '12 at 23:03
  • By upper part of the page, I mean close to the corner of the page (but I admit I want to stay a little vague on it since I am looking for a general solution instead of an answer to a particular technical problem). One of my problem with fancyhdr is for instance that I do not know how to get rid of the number of the section. The thing is that the chapter will be quite big (more than 200 pages), and I want it to be very easy to find a desire section using the big letters in the corner of the pages. – Thomas Connor Apr 30 '12 at 8:45
  • @ThomasConnor Look at my answer. It gets rid of the section numbers and it makes the section name in the header \HUGE if you want (they are \Large right now but are easy to change as desired). – JohnReed Apr 30 '12 at 15:07
5

Here is one way to put the section names in the header by redefining the header styles for one chapter. It is a little bit crude, but if you are doing it for one chapter only it is probably fine. The relevant lines of code are commented for emphasis.

The default heading style in this example can be changed as required (as can the special heading style).

Here is an example in use:

\documentclass[]{book}
\usepackage[english]{babel}
\usepackage[]{lipsum}

\usepackage{fancyhdr}
\pagestyle{fancy}

% THIS IS WHERE YOU DEFINE YOUR DEFAULT HEADER STYLE %
\def\defaultheaders{%
\fancyhead[LE,RO]{\slshape \rightmark}
\fancyhead[LO,RE]{\slshape \leftmark}
\fancyfoot[C]{\thepage}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}
\defaultheaders %SETS DEFAULT HEADERS

\chapter{chapter without special sections}
\lipsum[1-8]

\chapter{chapter with special sections}
% THESE LINES CHANGE THE HEADERS TO SHOW SECTION NAMES %
\fancyhead{}
\fancyhead[RO,LE]{\Large\rightmark} % CHANGE \Large TO SOMETHING ELSE IF DESIRED
\renewcommand{\sectionmark}[1]{\markright{#1}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\section{AA}
\lipsum[1-8]
\section{BC2}
\lipsum[1-5]

\chapter{another chapter without special sections}
\defaultheaders %RESTORES HEADERS TO NORMAL
\lipsum[1-5]

\end{document}

notes:

  • The lipsum package and \lipsum commands are only present to show filler text

edit:

  • I had originally forgotten to make the heading font larger for the special chapter, the code has now been corrected to make the section names \Large

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.
https://tex.stackexchange.com/questions/53767/customizing-headings
tex.stackexchange.com
crawl=CC-MAIN-2019-39
142377
application/http; msgtype=response
sha1:GIU26UFYFPBKAALBWJ27XACGB3IDGMIA
<urn:uuid:f807d71e-f91c-4909-9459-8df22b6a620a>
2019-09-17T14:24:45Z
151.101.129.69
text/html
sha1:4MQ7Y5NCGI4LC2NFMND3WRMPHHOI7GMP
<urn:uuid:878d7f7c-160c-45e4-a983-1c84e0951ed7>
https://tex.stackexchange.com/questions/53767/customizing-headings
response
<urn:uuid:935a09da-191b-4aa0-955f-9eadb8852873>
isPartOf: CC-MAIN-2019-39
publisher: Common Crawl
description: Wide crawl of the web for September 2019
operator: Common Crawl Admin (info@commoncrawl.org)
hostname: ip-10-67-67-8.ec2.internal
software: Apache Nutch 1.15 (modified, https://github.com/commoncrawl/nutch/)
robots: checked via crawler-commons 1.1-SNAPSHOT (https://github.com/crawler-commons/crawler-commons)
format: WARC File Format 1.1
conformsTo: http://iipc.github.io/warc-specifications/specifications/warc-format/warc-1.1/