Generala newbie header question (disappearing text)

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
srhlefty
Posts: 3
Joined: Mon Mar 05, 2007 6:08 am

a newbie header question (disappearing text)

Post by srhlefty »

Hi everyone,
So I'm using the book class, and I've got a bunch of chapters and sections.

When I use the (default) 'twopage' option, the left page header shows the current section name and page number, and the right page header shows the current page number.

When I use the 'onepage' option, I would like to see the current section name and page number in my header, but instead all that comes out is the page number.

Is there an easy way to do it? Most of the things I have read online point to using the fancy header package, but it seems like that shouldn't be necessary here.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
Void
Posts: 11
Joined: Mon Mar 12, 2007 3:00 pm

a newbie header question (disappearing text)

Post by Void »

fancyheadings sucks in my opinion. Use KOMA-Script instead. Read the scrguide.pdf (google it) and your fine.

If there is any question left, that's not answered by reading twice the manual, feel free to ask.
No or not enough coffee, user halted.
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Re: a newbie header question (disappearing text)

Post by localghost »

Could you post a minimum example that reproduces this problem? And by the way it is not urgent to use a KOMA-Script class. The usage may be not free of similar problems.
srhlefty
Posts: 3
Joined: Mon Mar 05, 2007 6:08 am

a newbie header question (disappearing text)

Post by srhlefty »

There are two things to play around with in this example: Whether or not the doc is one sided or two-sided, and whether or not a chapter has been defined. The \chapter is there to show that the book class uses chapters as the left header, and the left header is what's displayed when using the one-sided option. My goal is to have it display the section name, which should be in the right header, instead.

Code: Select all

%\documentclass[letterpaper,10pt,twoside]{book}
\documentclass[letterpaper,10pt,oneside]{book}
\begin{document}
%\chapter{Header Test}
\section{The first section}
The text on the first page.
The book class' left header is chapter name, and the right header is section name.
With no chapters defined and using the 'oneside' option, no header information is displayed.
Therefore the 'oneside' option uses the left header information.  Is there a way to make it
show right header information instead?
\newpage
The text on the second page.
Again we see no header when using the 'oneside' option unless a chapter has been defined.
\newpage
The text on the third page.
With 'twoside' this is where we see section information, the right header.
\end{document}
Thanks for your help!
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

a newbie header question (disappearing text)

Post by localghost »

The solution is simpler than you might think. I found this example in the documentation of the fancyhdr package (Section 9 - The scoop on LaTeX's marks, p. 9ff) and it should do the trick. And as you can see, it works without fancyhdr.

Code: Select all

\documentclass[letterpaper,10pt,oneside]{book}
\usepackage{blindtext}

\renewcommand{\sectionmark}[1]{\markright{\thesection.\ #1}}     % This redefines the right column title, only for option oneside

\begin{document}
  \blinddocument
\end{document}
Unfortunately this forum does not allow color in the code environment to mark critical points, so i put a comment behind the command. The new definition should only be used with the option oneside for the documentclass. The blindtext package generates parts of text or a whole document to demonstrate effects.
srhlefty
Posts: 3
Joined: Mon Mar 05, 2007 6:08 am

Re: a newbie header question (disappearing text)

Post by srhlefty »

Fantastic! I knew it would probably be some sort of redefinition, but had no idea how to do it. Thanks again.
Post Reply