Page LayoutHow to cut off the line in the header, under the number pag

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
ffarr
Posts: 28
Joined: Sat Apr 23, 2011 6:00 pm

How to cut off the line in the header, under the number pag

Post by ffarr »

First of all, thank you for the great support you're giving me. This community rocks.

I need to cut off the line in the header, under the page number and the title of the chapter. So, what I want to see is just like this:

[Page number] [Chapter title]

And not:

[Page number] [Chapter title]

Is it possible?

Here's my code:

Code: Select all

\documentclass[11pt,a4paper,twoside,italian]{book}
\usepackage[T1]{fontenc}
\usepackage[italian]{babel}
\usepackage[latin1]{inputenc}
\usepackage[%
      papersize={120mm,195mm},
      left=18mm,
      right=18mm,
      bottom=20mm,
      top=25mm,
      headheight=14pt,
      includehead,
      nofoot,
    ]{geometry}
\usepackage{babel}
\usepackage[raggedright,pagestyles]{titlesec}% Add “clearempty” option if you need to get rid of headers/footers on empty pages
\usepackage{blindtext}
\usepackage{color}

\titleformat{\chapter}{\normalfont\large\bfseries}{}{0pt}{\Large}[\thispagestyle{plain}]
%%% Page styles

\makeatletter

\newpagestyle{toc}{% Create a page style for TOC
   \let\ps@plain\ps@empty% Redefine plain style which is automatically applied to the first page of TOC; put “empty”, or “main”, or any other page style you like
   \sethead[][][]{}{}{}
}

\newpagestyle{chapter}{% Create a page style for the first page of a chapter
   \setfoot[][\thepage][]{}{\thepage}{}
}

\newpagestyle{main}{%
   \let\ps@plain\ps@chapter% Activate page style for the first page of a chapter
   \sethead[\thepage][][\chaptertitle]{\chaptertitle}{}{\thepage}
   \headrule
}

\makeatother

\begin{document}
Many thanks!

Recommended reading 2024:

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

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

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Stefan Kottwitz
Site Admin
Posts: 10330
Joined: Mon Mar 10, 2008 9:44 pm

How to cut off the line in the header, under the number pag

Post by Stefan Kottwitz »

Hi,

you could use the fancyhdr package. It offers some ways for customizing headers and footers, also regarding the line below the header.

For example:

Code: Select all

\usepackage{fancyhdr}
\pagestyle{fancy}
\renewcommand{\headrulewidth}{0pt}% that's removing the footer line
\renewcommand{\footrulewidth}{0pt}% that's removing the header line
Stefan
LaTeX.org admin
User avatar
Stefan Kottwitz
Site Admin
Posts: 10330
Joined: Mon Mar 10, 2008 9:44 pm

How to cut off the line in the header, under the number pag

Post by Stefan Kottwitz »

Now I see your page style definition:

Code: Select all

\newpagestyle{main}{%
   \let\ps@plain\ps@chapter% Activate page style for the first page of a chapter
   \sethead[\thepage][][\chaptertitle]{\chaptertitle}{}{\thepage}
   \headrule
}
Perhaps simply remove that \headrule command.

Stefan
LaTeX.org admin
ffarr
Posts: 28
Joined: Sat Apr 23, 2011 6:00 pm

How to cut off the line in the header, under the number pag

Post by ffarr »

Stefan_K wrote:
Perhaps simply remove that \headrule command.
Great! That was the solution.

Now they tell me that the chaptertitle in the header needs to be in a different font, or at least smaller than the text of the book...

Is it possible?
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

How to cut off the line in the header, under the number pag

Post by localghost »

ffarr wrote:[…] Now they tell me that the chaptertitle in the header needs to be in a different font, or at least smaller than the text of the book. […]
The titlesec manual suggest something like this.

Code: Select all

\newpagestyle{main}[\small]{%
  \sethead[\thepage][][\chaptertitle]{\chaptertitle}{}{\thepage}
}
\assignpagestyle{chapter}{empty}
The optional argument can take every font related command.


Thorsten
Post Reply