The chapter head is set in report.cls
by the macro \@makechapterhead
:
\def\@makechapterhead#1{%
\vspace*{50\p@}%
{\parindent \z@ \raggedright \normalfont
\ifnum \c@secnumdepth >\m@ne
\huge\bfseries \@chapapp\space \thechapter
\par\nobreak
\vskip 20\p@
\fi
\interlinepenalty\@M
\Huge \bfseries #1\par\nobreak
\vskip 40\p@
}}
We can create a "duplicate" of it, only with the creation of Chapter X
removed. Let's call this duplicate \fake@makechapterhead
:
\def\fake@makechapterhead#1{%
\vspace*{50\p@}%
{\parindent \z@ \raggedright \normalfont
\ifnum \c@secnumdepth >\m@ne
\huge\bfseries \strut%\@chapapp\space \thechapter
\par\nobreak
\vskip 20\p@
\fi
\interlinepenalty\@M
\Huge \bfseries #1\par\nobreak
\vskip 40\p@
}}
The commented part has been replaced by \strut
(in order to have an appropriate baseline correctly set.
Now we add some house-keeping and user-interface macros and you can use \newchapterhead
to create the "fake" chapter head, and \restorechapterhead
to restore the original setting:
\documentclass{report}
\makeatletter
\let\old@makechapterhead\@makechapterhead
% Taken from http://mirrors.ctan.org/macros/latex/unpacked/report.cls
\def\fake@makechapterhead#1{%
\vspace*{50\p@}%
{\parindent \z@ \raggedright \normalfont
\ifnum \c@secnumdepth >\m@ne
\huge\bfseries \strut%\@chapapp\space \thechapter
\par\nobreak
\vskip 20\p@
\fi
\interlinepenalty\@M
\Huge \bfseries #1\par\nobreak
\vskip 40\p@
}}
\newcommand{\newchapterhead}{\let\@makechapterhead\fake@makechapterhead}
\newcommand{\restorechapterhead}{\let\@makechapterhead\old@makechapterhead}
\makeatother
\begin{document}
\chapter{Hello}
\newchapterhead
\chapter{World}
\restorechapterhead
\chapter{!}
\end{document}
The above procedure keeps the same vertical location for the chapter title by merely removing the phrase Chapter X
from being printed.
An alternative approach might be to use the \chapter*
setting of a chapter. This doesn't provide the same vertical position on the chapter-page for the title, but may also be what you're after:
\documentclass{report}
\begin{document}
\chapter{Hello}
\clearpage\refstepcounter{chapter}%
\chapter*{World}
\chapter{!}
\end{document}
The issuing of a \clearpage\refstepcounter{chapter}
allows for two things:
Steps the chapter
counter to have a correct reference for sub-content in chapter World
;
Correct mark in the document if you're using hyperref
for placing a internal document hyperlink.
If you think there are more chapters containing labels only with a single figure, I would suggest to turn off resetting a figure number per chapter. This way labels will remain unique across the document.
One way to achieve the above is to use
\counterwithout*{figure}{chapter}
a starred version, so that format of \thefigure
remains the same across the document. Then, redefine the label only sparsely in those figure environments which does not require chapter numbers. I created a new environment called slfigure
for this purpose which contain the line
\renewcommand*{\thefigure}{\arabic{figure}}
Here is the example
\documentclass[openany]{book} % [openany] only for demonstration to avoid empty pages
\usepackage{graphicx}
\usepackage[Export]{adjustbox} % For \adjustboxset
\counterwithout*{figure}{chapter} % Prevents from resetting figure numbers
\adjustboxset{width=0.5\linewidth} % To avoid repetition with \inlcudegraphics[width=0.5\linewidth]{...}
% This environment redefines figure labelling, locally
\NewDocumentEnvironment{slfigure}{O{} +b}{
\begin{figure}[#1]
\renewcommand*{\thefigure}{\arabic{figure}}
#2
\end{figure}
}{}
\begin{document}
\chapter{Chapter with only one figure}
In this chapter the only Figure \ref{fig1} should be referenced as just 1, not 1.1.
\begin{slfigure}[tbh]
\centering
\includegraphics{example-image-a}
\caption{Single figure}
\label{fig1}
\end{slfigure}
\chapter{Chapter with several figures}
In this chapter, the Figures \ref{fig2.2} and \ref{fig2.3} can be referenced as intended.
\begin{figure}[tbh]
\centering
\includegraphics{example-image-b}
\caption{Figure is labeled 2.2 as intended}
\label{fig2.2}
\end{figure}
A sentence between figures
\begin{figure}[tbh]
\centering
\includegraphics{example-image-c}
\caption{Figure is labeled 2.3 as intended}
\label{fig2.3}
\end{figure}
\chapter{Chapter with only one figure}
The second chapter with a single Figure~\ref{fig:4}
\begin{slfigure}[tbh]
\centering
\includegraphics{example-image}
\caption{Single figure no. 4}
\label{fig:4}
\end{slfigure}
\end{document}
Best Answer
You could probably use hooks instead of
\chapterend
.