# How to create sections and section titles but prevent them from showing up in the output?

I'm wondering if it's possible to create section and section titles but prevent them from showing up in the output. Below an example. Although I need the section for the numbering op my tables and figures I don't want the title in my ouput

\appendix \section{the first appendix}

• If you need the numbers only, you can use \stepcounter{section}. This will increase the relevant section number, but do you want to have the section titles in the ToC anyway? – user31729 Jan 9 '16 at 13:03
• I think, it's better to use \refstepcounter{section} – user31729 Jan 9 '16 at 13:13

Either one uses \refstepcounter{section} directly each time or \fakesection command that does \refstepcounter{section} or redefines \section to do effectively nothing apart from \refstepcounter{section}.

In my point of view, it's better to redefine \section to provide the possibility of using the same code later on when section titles and toc entries are needed.

I've done this here by appending the redefinition code to the \appendix command, i.e. it's redefined only after \appendix has been used.

Why \refstepcounter and not just \stepcounter?

Assume, that the (non-existent) appendix section should be referenced by a \label command → this would only work with \refstepcounter{section} and not with \stepcounter only!

\documentclass{article}

\usepackage{graphicx}
\usepackage{xpatch}

\makeatletter
\let\latex@@section\section
\xapptocmd{\appendix}{%
\renewcommand{\section}[2][]{%
\refstepcounter{section}%
}
\renewcommand{\thefigure}{\thesection.\arabic{figure}}
}{}{}
\makeatother

\begin{document}
\tableofcontents
\section{A real section}

\clearpage
\appendix

\section{A dummy section}

\begin{figure}
\includegraphics[scale=2]{beeduck}
\caption{ A figure in a dummy section}
\end{figure}

\end{document}