1

I need to insert a very large figure which will occupy the whole page, so I need to remove the heading of the page where the figure is. I do this with code:

\documentclass[a4paper,12pt,twoside]{book}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage{lipsum}
\usepackage{graphicx}

\pagestyle{headings}

\begin{document} \chapter{Sample Chapter} \section{New section}

\lipsum{1-6} \begin{figure}[p] \thispagestyle{empty} \caption{hello} \end{figure}• \lipsum{2-5}

\end{document}

The result is that the page where the figure is has the heading but one of the pages before the page of the figure doesn't have the heading. It removes the wrong heading of the page. How should I resolve the problem?

enter image description here enter image description here

Y. zeng
  • 1,885
  • 2
    See https://tex.stackexchange.com/questions/427572/remove-header-footer-on-page-with-large-figure/427655?r=SearchResults&s=6%7C0.0000#427655 and https://tex.stackexchange.com/questions/644359/removing-page-numbering-on-the-continued-float-two-page-figures-in-overleaf/644423?r=SearchResults&s=1%7C0.0000#644423 – John Kormylo May 23 '22 at 14:25
  • 1
    @JohnKormylo The second link can resolve this problem. Thanks a lot. – Y. zeng May 24 '22 at 00:38
  • @JohnKormylo How did you know so much about LeTeX? Which book of LaTeX made you so magic? – Y. zeng May 24 '22 at 00:43
  • The TeXbook by Knuth, source2e.pdf (from CTAN), occasional .sty files and lots of experimentation. – John Kormylo May 24 '22 at 03:14
  • @JohnKormylo Is this one: https://theswissbay.ch/pdf/Gentoomen%20Library/Extra/D._Knuth-The_TeXbook.pdf – Y. zeng May 24 '22 at 05:50
  • @JohnKormylo May you send me the right book's link? – Y. zeng May 25 '22 at 01:13
  • @JohnKormylo How about this one https://bthc-my.sharepoint.com/:b:/g/personal/mr_iem_im/EZZZsslas4FHuZl25PdqjQoB4ID2wBWRoeEsjHYg-9MV2Q?e=dT5r3D – Y. zeng May 25 '22 at 01:24
  • @JohnKormylo So, should I need to read this book first? And what should I read second? – Y. zeng May 26 '22 at 00:31
  • @JohnKormylo If I didn't read this book, can't I read cls file clearly? Am I right? – Y. zeng May 26 '22 at 07:11
  • @JohnKormylo So, what books should I read after that one? – Y. zeng May 26 '22 at 14:37
  • There are many books on LaTeX (how to use). i have a couple but rarely refer to them. This is a rather long discussion and off topic, so I will be deleting most of my comments. – John Kormylo May 26 '22 at 14:41

2 Answers2

1

Your figure is typeset on a "page of floats", and unfortunately, LaTeX uses the headers/footers definition of the previous "normal" page for these.

However, fancyhdr has a special command for detecting that we are on a page of floats, and then we can make the header conditional on this. In the following example I use the headings option that fancyhdr has (in version 4 and later) to duplicate the headings style. I then redefine the headers so that they will be empty on all float pages.

\documentclass[a4paper,12pt,twoside]{book}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage{lipsum}
\usepackage{graphicx}
\usepackage[headings]{fancyhdr} % at least version 4

\pagestyle{headings} \renewcommand{\headrule}{} % eliminate the line under the header \fancyhead[LE,RO]{\iffloatpage{}{\thepage}} \fancyhead[RE]{\iffloatpage{}{\slshape\leftmark}} \fancyhead[LO]{\iffloatpage{}{\slshape\rightmark}}

\begin{document} \chapter{Sample Chapter} \section{New section}

\lipsum{1-6} \begin{figure}[p] \thispagestyle{empty} \caption{hello} \end{figure} \lipsum{2-5}

\end{document}

Now if you want to suppress the headers only on one page, you can use a different test: just check the page number. In order not to have to guess the page number, or look at the printed copy, you can use a label. The refcount package has a command \getpagerefnumber to get the numerical vale of the page number of the label, that can be used in numerical comparisons.

I have put the label of the special page in a macro, so that you can repeat the process for later pages if so required.

\documentclass[a4paper,12pt,twoside]{book}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage{lipsum}
\usepackage{graphicx}
\usepackage[headings]{fancyhdr} % at least version 4
\usepackage{refcount}
\usepackage{ifthen}

\newcommand{\whichlabel}{specialfig} % \checkpage{value on special page}{value on other pages} \newcommand{\checkpage}[2]{% \ifthenelse{\thepage=\getpagerefnumber{\whichlabel}}{#1}{#2}% } \renewcommand{\headrule}{} % eliminate the line under the header % Don't print headers on the special page. % If you later want to do the same on another page, just give it a new \label % and \renewcommand{\whichlabel}{new label} \fancypagestyle{headings}{ \fancyhead[LE,RO]{\checkpage{}{\thepage}} \fancyhead[RE]{\checkpage{}{\slshape\leftmark}} \fancyhead[LO]{\checkpage{}{\slshape\rightmark}} } \pagestyle{headings}

\begin{document} \chapter{Sample Chapter} \section{New section} ref on page~\pageref{specialfig}.

\lipsum[1-6]

\begin{figure}[p] \caption{hello without headers}\label{specialfig} \fbox{\rule{0.9\textwidth}{0pt}\rule{0pt}{0.9\textheight}} \end{figure} \lipsum[7] \begin{figure}[p] \caption{hello with headers} \fbox{\rule{0.9\textwidth}{0pt}\rule{0pt}{0.9\textheight}} \end{figure} \lipsum[2-5] \end{document}

  • Hm, image is push to the end of document, second and last page use empty page style. If I change placement option to !ht figure is on third page, but empty page style is activated on the second page. It works correctly if figure is inserted after third page after chapter title. – Zarko May 23 '22 at 10:50
  • Hello. Thanks for your reply. But the heading style can't be changed as it is designed by the editor of the journal. How can I resolve this problem without changing the default heading, just make the heading disappeared here? – Y. zeng May 23 '22 at 10:50
  • If the heading style is designed by the editor and if you are not allowed to change it, then the problem probably can't be changed. But if you are allowed to use fancyhdr, you can use it to emulate the used style, and use my solution to suppress it on the figure page. – Pieter van Oostrum May 23 '22 at 19:17
  • Okay. I just want to modify this page. From your answer, it seems to change every figure with [p], which is beyond my need. Is there a way to just remove this page's heading? – Y. zeng May 24 '22 at 00:14
  • I have added an example, where only one page has the headers suppressed. – Pieter van Oostrum May 24 '22 at 22:30
0

I think you first has to go to create a new page, than set the pagestyle to empty with the command \thispagestyle{empty} that you already used and then insert the figure with the placement command here like this \begin{figure}[!h].

In my opinion the "clean" way would be to declare a new page environment for that and then insert the image directly in that env.

deniz
  • 1