Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
    
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
show 2 more comments

1 Answer 1

up vote 5 down vote accepted

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
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.