2

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[pdftex, bookmarksnumbered,  pagebackref, colorlinks=true, citecolor=Blue, linkcolor=DarkBlue!30!Black, urlcolor=Black,bookmarksopen]{hyperref}
\hypersetup{colorlinks,
  linkcolor=blue,
  linktoc=page}

\usepackage{bookmark}
\usepackage{copyrightbox} 
\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{%
\addtocontents{lofb}{%
  \protect{%
    \bookmark[
    rellevel=1,
    keeplevel,
    dest=\@currentHref,
    ]{Figure \thefigure: \@currentlabelname}}}%
}{}{\errmessage{Patching \noexpand\endfigure failed}}
\pretocmd\endtable{%
\addtocontents{lotb}{%
  \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} 
            \copyrightbox[b]{\tcbox{\includegraphics[scale=0.9]{example-image-a}}}{source: na.}
        \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}
 Header & Header \\
 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} 
            \copyrightbox[b]{\tcbox{\includegraphics[width=3cm]{example-image-a}}}{fuente:fuente1}
    \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}

enter image description here

0
1

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

enter image description here

\documentclass{book}

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

\usepackage{hyperref}
\hypersetup{
  colorlinks,
  linkcolor=blue,
  linktoc=page,
  bookmarksopen
}

\usepackage{bookmark}
\usepackage{copyrightbox} 
\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{..}
    % \addtocontents{<file>}{<stuff>}
    % - \@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
    \addtocontents{\csname ext@\@captype\endcsname b}{%
      \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}
  \copyrightbox[b]{\tcbox{\includegraphics[scale=0.9]{example-image-a}}}{source: na.}
\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}
    Header & Header \\
      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.}
  \copyrightbox[b]{\tcbox{\includegraphics[width=3cm]{example-image-a}}}{fuente:fuente1}
\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}
5
  • 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
  • 1
    @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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.