Page Layout ⇒ fancyhdr | Problem with Sections in Header
-
- Posts: 5
- Joined: Tue Feb 14, 2012 6:43 pm
fancyhdr | Problem with Sections in Header
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
fancyhdr | Problem with Sections in Header
Best regards and welcome to the board
Thorsten
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
-
- Posts: 5
- Joined: Tue Feb 14, 2012 6:43 pm
fancyhdr | Problem with Sections in Header
Here is the code. I think the problem lies in the re-definition of the section, but I have no idea how to solve it. In the header on the last page, it doesn't say "Short title of sec" but puts a dot in front of it so it reads ". Short title of sec". Any help is much appreciated
Code: Select all
\documentclass{book}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhead[RO,LE]{\leftmark}
\fancyhead[RE,LO]{\rightmark}
\fancyfoot[LE,RO]{\thepage}
\fancyfoot[RE,LO]{}
\cfoot{}
\renewcommand\thesection{\hspace{-1em}}
\begin{document}
\begin{titlepage}
\Huge {\bf The Title}
\end{titlepage}
\setcounter{tocdepth}{2}
\tableofcontents
\chapter{One}
\section[Short title of sec]{Long title of section}
And here there is some text, which should be long enough to fill an entire page, hence I repeat it several times. And here there is some text, which should be long enough to fill an entire page, hence I repeat it several times.And here there is some text, which should be long enough to fill an entire page, hence I repeat it several times.And here there is some text, which should be long enough to fill an entire page, hence I repeat it several times.And here there is some text, which should be long enough to fill an entire page, hence I repeat it several times.And here there is some text, which should be long enough to fill an entire page, hence I repeat it several times.And here there is some text, which should be long enough to fill an entire page, hence I repeat it several times.And here there is some text, which should be long enough to fill an entire page, hence I repeat it several times.And here there is some text, which should be long enough to fill an entire page, hence I repeat it several times.And here there is some text, which should be long enough to fill an entire page, hence I repeat it several times.And here there is some text, which should be long enough to fill an entire page, hence I repeat it several times.And here there is some text, which should be long enough to fill an entire page, hence I repeat it several times.And here there is some text, which should be long enough to fill an entire page, hence I repeat it several times.And here there is some text, which should be long enough to fill an entire page, hence I repeat it several times.And here there is some text, which should be long enough to fill an entire page, hence I repeat it several times.And here there is some text, which should be long enough to fill an entire page, hence I repeat it several times.
\end{document}
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
fancyhdr | Problem with Sections in Header
Code: Select all
\renewcommand{\thesection}{\hspace{-1em}}
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
-
- Posts: 5
- Joined: Tue Feb 14, 2012 6:43 pm
Re: fancyhdr | Problem with Sections in Header
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Re: fancyhdr | Problem with Sections in Header
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
-
- Posts: 5
- Joined: Tue Feb 14, 2012 6:43 pm
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
fancyhdr | Problem with Sections in Header
Code: Select all
\documentclass{book}
\usepackage{fancyhdr}
\usepackage{lipsum}
\fancyhf{}
\fancyhead[RO,LE]{\leftmark}
\fancyhead[RE,LO]{\rightmark}
\fancyfoot[LE,RO]{\thepage}
\pagestyle{fancy}
\setcounter{secnumdepth}{0} % default value 2 for »book« class
\setcounter{tocdepth}{2}
\begin{document}
\tableofcontents
\chapter{One}
\section[Short title of Section]{Long title of Section}
\lipsum
\end{document}
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
-
- Posts: 5
- Joined: Tue Feb 14, 2012 6:43 pm