# How to make invisible section header noticeable in the TOC?

I used a nice solution from http://tex.stackexchange.com/a/68296/7435 to insert invisible section headers. However, my sections contain floats alone and invisible sectioning doesn't work properly. E.g., it sets all chapter's sections as having the same page in the TOC.

What could I put in the section to keep it visually clean (floats alone) and make the section appear in the TOC with the correct page number?

I have a common preamble:

\documentclass[english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{babel}
\usepackage[unicode=true,pdfusetitle,
bookmarks=true,bookmarksnumbered=true,bookmarksopen=true,bookmarksopenlevel=3,
{hyperref}

\makeatletter
\newcommand\invisiblesection[1]{%
\refstepcounter{section}%
\sectionmark{#1}}

\makeatother


And two bodies.

One appears in the TOC:

\begin{document}
\tableofcontents{}\clearpage{}

\invisiblesection{One}

Line One.

\clearpage{}

\invisiblesection{Two}

Line Two.
\end{document}


The other one doesn't:

\begin{document}
\tableofcontents{}\clearpage{}

\invisiblesection{One}

\begin{figure}

\caption{\protect\includegraphics{logo}}

\end{figure}

\clearpage{}

\invisiblesection{Two}
\end{document}

-
You don't have a float placement specifier. Your floats are probably placed after your invisible sections therefore they ARE on the same page. To avoid this, use float placement specifiers (like [h!]) or load the placeins package and apply FloatBarriers. (To enhance the figure placement you might need to use resizebox from the graphicx package.) –  masu Dec 14 '13 at 19:53

In the former case there is some text where to anchor the "invisible" section. In the latter there isn't...

A way to circumvent this issue, if you really don't want to insert any text in the invisible section, is to insert a "phantom" text in its definition:

\makeatletter
\newcommand\invisiblesection[1]{%
\refstepcounter{section}%
\sectionmark{#1}\phantom{}}
\makeatother


MWE:

\documentclass[english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{babel}
\usepackage[unicode=true,pdfusetitle,
bookmarks=true,bookmarksnumbered=true,bookmarksopen=true,bookmarksopenlevel=3,
{hyperref}
\usepackage[demo]{graphicx}

\makeatletter
\newcommand\invisiblesection[1]{%
\refstepcounter{section}%
\sectionmark{#1}\phantom{}}
\makeatother

\begin{document}
\tableofcontents{}\clearpage{}

\invisiblesection{One}

\begin{figure}

\caption{\protect\includegraphics{logo}}

\end{figure}

\clearpage{}

\invisiblesection{Two}
\end{document}


Output (ToC):

-