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.
General ⇒ a newbie header question (disappearing text)
NEW: TikZ book now 40% off at Amazon.com for a short time.
a newbie header question (disappearing text)
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.
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.
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Re: a newbie header question (disappearing text)
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.
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
a newbie header question (disappearing text)
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.
Thanks for your help!
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}
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
a newbie header question (disappearing text)
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.
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.
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}
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Re: a newbie header question (disappearing text)
Fantastic! I knew it would probably be some sort of redefinition, but had no idea how to do it. Thanks again.