# Why does a float with the [H] option not appear in as a bookmark

In the image/code below, why does Figure 1.1 does not appear in the bookmarks?All other figures appear as normal, but the figure in Chapter 1 does not appear?

Figure 1.1 is the only figure that uses [H]. I am required to use this float specification. My code is based on this question: Custom bookmark list of figures and tables

How can I make Figure 1.1 appear in the bookmarks?

\documentclass{book}
\usepackage{caption}
\usepackage{etoolbox}
\usepackage{float}

\usepackage{bookmark}
\usepackage{tcolorbox}

\makeatletter
\newcommand{\listoffiguresbookmarks}{%
\pdfbookmark[0]{\listfigurename}{listoffiguresbookmark}
\bookmarksetup{level=1}
\@starttoc{lofb}
}
\newcommand{\listoftablesbookmarks}{%
\pdfbookmark[0]{\listtablename}{listoftablesbookmark}
\bookmarksetup{level=1}
\@starttoc{lotb}
}

\makeatother

%%% Generate bookmarks for all figures and tables
\makeatletter

\pretocmd\endfigure{%
\protect{%
\bookmark[
rellevel=1,
keeplevel,
dest=\@currentHref,
]{Figure \thefigure: \@currentlabelname}}}%
}{}{\errmessage{Patching \noexpand\endfigure failed}}
\pretocmd\endtable{%
\protect{%
\bookmark[
rellevel=1,
keeplevel,
dest=\@currentHref,
]{Table \thetable: \@currentlabelname}}}%
}{}{\errmessage{Patching \noexpand\endtable failed}}

\makeatother

\AtEndDocument{%
\listoffiguresbookmarks
\listoftablesbookmarks
}

\begin{document}

\tableofcontents
\chapter*{Dedicatory}
to all my family
\chapter*{Abstract}
hello world

\chapter{ETAPA}
\label{cap:experimental}
this intro

\section{Exp}
this Exp SECTION

\subsection{Descriptión}
description subSection

\begin{figure}[H]
\centering
\caption{F1}
\label{label1}
\end{figure}

this image

\chapter{chapter}
hellow
\section{Introduction}
In this example several keywords\index{keywords} will be
used which are important and deserve to appear in

\begin{table}[ht]
\begin{tabular}{cc}
1&2\\
\end{tabular}
\caption[Table caption text]{This is a table with a very long caption text
and it would be nice to use the short caption in the bookmark}
\label{table 1}
\end{table}

\subsection{subsection}
Terms like generate\index{generate} and some\index{others}
will also show up. Terms in the index can also be
nested \index{Index!nested}

\begin{figure}[ht]
\centering
\caption{Caption.}
\label{label2}
\end{figure}

\clearpage

\section{Second section}
This second section\index{section} may include some special

hello1
\begin{figure}[ht]
\centering
\rule{6cm}{3cm}
\caption{Figure caption text}
\label{figura 1}
\end{figure}
word, and expand the ones already used\index{keywords!used}.

\end{document}


You can use the following, more condensed version that taps into \caption.

\documentclass{book}

\usepackage{caption,xparse}
\usepackage{float}

\usepackage{hyperref}
\hypersetup{
bookmarksopen
}

\usepackage{bookmark}
\usepackage{tcolorbox}

\makeatletter
\newcommand{\listoffiguresbookmarks}{%
\pdfbookmark[0]{\listfigurename}{listoffiguresbookmark}
\bookmarksetup{level=1}
\@starttoc{lofb}
}
\newcommand{\listoftablesbookmarks}{%
\pdfbookmark[0]{\listtablename}{listoftablesbookmark}
\bookmarksetup{level=1}
\@starttoc{lotb}
}

\makeatother

%%% Generate bookmarks for all figures and tables

\makeatletter

% Update \caption at start of document to avoid conflict with caption package
\AtBeginDocument{
% Store \caption in \oldcaption
\let\oldcaption\caption
% Update \caption to take optional and mandatory argument (like before)
\RenewDocumentCommand{\caption}{o m}{%
\IfValueTF{#1}
{\oldcaption[#1]{#2}}% \caption[.]{..}
{\oldcaption{#2}}% \caption{..}
% - \@captype contains the name of the float (figure or table)
% - \csname ext@\@captype\endcsname will contain lof/lot for figures/tables
% - \csname fnum@\@captype\endcsname contains
%     \figurename~\thefigure for figure, or
%     \tablename~\thetable for table
\protect\bookmark[
rellevel=1,
keeplevel,
dest=\@currentHref
]{\csname fnum@\@captype\endcsname: \@currentlabelname}%
}%
}%
}
\makeatletter

\AtEndDocument{%
\listoffiguresbookmarks
\listoftablesbookmarks
}

\begin{document}

\tableofcontents

\chapter*{Dedicatory}
to all my family

\chapter*{Abstract}
hello world

\chapter{ETAPA}
this intro

\section{Exp}
this Exp SECTION

\subsection{Descriptión}
description subSection

\begin{figure}[H]
\centering
\caption{F1}
\end{figure}

this image

\chapter{chapter}
hellow

\section{Introduction}
In this example several keywords will be
used which are important and deserve to appear in

\begin{table}[ht]
\begin{tabular}{cc}
1    &   2
\end{tabular}
\caption[Table caption text]
{This is a table with a very long caption text and it would be nice to use the short caption in the bookmark}
\end{table}

\subsection{subsection}
Terms like generate and some will also show up. Terms in the index can also be nested

\begin{figure}[ht]
\centering
\caption{Caption.}
\end{figure}

\clearpage

\section{Second section}
This second section may include some special

hello1

\begin{figure}[ht]
\centering
\rule{6cm}{3cm}
\caption{Figure caption text}
\end{figure}

word, and expand the ones already used.

\end{document}

• what is the changes? thanks, Can you explain me a little, what should I increase? What should I delete? – x-rw Feb 26 '19 at 2:48
• @x-rw: I've added some reference in the code to the addition. – Werner Feb 26 '19 at 3:20
• you answer disable the clicks of my table of contents, how can I solve it? – x-rw Feb 26 '19 at 4:18
• before you could click and it was positioned in the title where you clicked, but now the event does not work click in the table of contents, please help me please – x-rw Feb 26 '19 at 4:21
• @x-rw: I've removed some of your ToC-related option you included with loading hyperref. Only the page is hyperlinked. It just seemed odd for you to load the package with certain options, and then immediately after that use \hypersetup{...} to add more settings. So I just removed them altogether. It didn't form part of the question though. – Werner Feb 26 '19 at 4:32