Page LayoutHow to suppress page numbers for several pages

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
Singularity
Posts: 156
Joined: Sat Jan 22, 2011 9:55 pm

How to suppress page numbers for several pages

Post by Singularity »

How do I suppress page numbers on pages with long code listings on them?

I am using the listings package to print a few long program listings. I want to suppress the page numbers for all pages during the listing, except the last page of each listing.

I can suppress the page numbers with \thispagestyle{empty}. But that only works on the first page of the listing. The listing spans several pages, and the page number is printed after the first page. How do I turn it off altogether during the listing, but have the page numbers reappear starting with the last page of the listing?

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: 10324
Joined: Mon Mar 10, 2008 9:44 pm

How to suppress page numbers for several pages

Post by Stefan Kottwitz »

You can write \pagestyle{empty} before you start the listings, and \pagestyle{headings} (or your original style name) to reactivate page number display later when the listing ended.

Stefan
LaTeX.org admin
Post Reply