섹션 내 ToC의 그림과 표

섹션 내 ToC의 그림과 표

ToC에 그림 목록과 표 목록(괜찮습니다)이 포함되어 있는 레이아웃 요구 사항을 충족해야 하지만 추가적으로 PDF 책갈피에서 각 그림과 표가 나타나는 섹션 내에 표시되어야 합니다. 다음 MWE를 살펴보세요.

\documentclass[12pt]{article}
\usepackage{todonotes}
\usepackage{graphicx}
\usepackage{float}
\restylefloat{table}
\restylefloat{figure}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage[a4paper, margin=3cm, top=3cm, bottom=3cm]{geometry}
\usepackage[bookmarks=true]{hyperref}
\usepackage{bookmark}
\hypersetup{
linktocpage=true,
colorlinks=true,
linkcolor=blue,
filecolor=blue,      
urlcolor=blue,
bookmarksopen=true
}
\bookmarksetup{numbered}

\title{\begin{center}
My Title
\end{center}
} 
\date{}
\author{}

\begin{document}

\begin{titlepage}
\maketitle
\end{titlepage}

\setcounter{page}{2}

\newpage
\pdfbookmark[0]{Contents}{Contents}
\tableofcontents
\listoffigures
\listoftables

\newpage
\section{My first section}

Bla, bla bla.

\begin{figure}[H]
\caption{My first Figure}
\missingfigure[figwidth=6cm]{}
\end{figure}

\begin{table}[H]
\caption{My first Table}
\begin{tabular}{ |c|c|c| } 
 \hline
 cell1 & cell2 & cell3 \\ 
 cell4 & cell5 & cell6 \\ 
 cell7 & cell8 & cell9 \\ 
 \hline
\end{tabular}
\end{table}

\newpage
\section{My second section}

More bla, bla.

\begin{figure}[H]
\caption{My second Figure}
\missingfigure[figwidth=6cm]{}
\end{figure}

\begin{table}[H]
\caption{My second Table}
\begin{tabular}{ |c|c|c| } 
 \hline
 cell1 & cell2 & cell3 \\ 
 cell4 & cell5 & cell6 \\ 
 cell7 & cell8 & cell9 \\ 
 \hline
\end {tabular}
\end{table}

\end{document}

이는 정확히 나에게 필요한 ToC를 생성합니다.

여기에 이미지 설명을 입력하세요

그러나 다음과 같은 PDF 북마크도 생성합니다.

여기에 이미지 설명을 입력하세요

하지만 다음과 같이 보이려면 PDF 북마크가 필요합니다(코드 스타일을 사용해서 죄송합니다).

Contents
|- 1 My first Section
   |- My first figure
   |- My first table 
|- 2 My second Section
   |- My second figure
   |- My second table

어떤 아이디어가 있나요?

답변1

제가 생각하는 가장 쉬운 방법은 \caption고유한 북마크 라벨(그림이나 표의 총 개수로 생성됨)을 사용하여 북마크를 연결하고 추가하는 것 입니다.

총 숫자를 얻으려면 (음, 내 ;-)) 패키지를 사용 xassocnt하고 관련 카운터를 스테핑과 연결하십시오.

\pdfbookmark[2]{text}{label:name}그림이나 표 항목을 현재 섹션에 하위 섹션 수준으로 추가합니다 .

\texorpdfstring{tex content}{pdf content}캡션의 특정 내용에 사용할 때는 주의하세요 .\caption{\texorpdfstring{$E=mc^2}{E=mc\textsuperscript{2}}}

\documentclass[12pt]{article}
\usepackage{todonotes}
\usepackage{graphicx}
\usepackage{xassoccnt}

\newcounter{totalfigure}
\newcounter{totaltable}

\DeclareAssociatedCounters{figure}{totalfigure}
\DeclareAssociatedCounters{table}{totaltable}


\usepackage{float}
\restylefloat{table}
\restylefloat{figure}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{caption}




\makeatletter
\AtBeginDocument{%
\let\caption@@caption\caption
\RenewDocumentCommand{\caption}{som}{%
  \IfBooleanTF{#1}{%
    \caption@@caption{#3}%
  }{%
    \IfValueTF{#2}{%
      \caption@@caption[#2]{#3}%
      \pdfbookmark[2]{#2}{\@captype:\number\value{total\@cap@type}}%
    }{%
      \phantomsection
      \caption@@caption{#3}%
      \pdfbookmark[2]{#3}{\@captype:\number\value{total\@captype}}%
    }%
  }%
}
}


\usepackage[a4paper, margin=3cm, top=3cm, bottom=3cm]{geometry}
\usepackage[bookmarks=true]{hyperref}
\usepackage{bookmark}
\hypersetup{
  linktocpage=true,
  colorlinks=true,
  linkcolor=blue,
  filecolor=blue,      
  urlcolor=blue,
  bookmarksopen=true
}

%\captionsetup[figure]{format=bookmarksfig}
%\captionsetup[table]{format=bookmarkstab}


\bookmarksetup{numbered}

\title{\begin{center}
    My Title
\end{center}
} 
\date{}
\author{}

\begin{document}

\begin{titlepage}
\maketitle
\end{titlepage}

\setcounter{page}{2}

\newpage
\pdfbookmark[0]{Contents}{Contents}
\tableofcontents
\listoffigures
\listoftables

\newpage
\section{My first section}

Bla, bla bla.

\begin{figure}[H]
\caption{My first Figure}
\missingfigure[figwidth=6cm]{}
\end{figure}

\begin{table}[H]
\caption{My first Table}
\begin{tabular}{ |c|c|c| } 
 \hline
 cell1 & cell2 & cell3 \\ 
 cell4 & cell5 & cell6 \\ 
 cell7 & cell8 & cell9 \\ 
 \hline
\end{tabular}
\end{table}

\newpage
\section{My second section}

More bla, bla.

\begin{figure}[H]
\caption{My second Figure}
\missingfigure[figwidth=6cm]{}
\end{figure}

\begin{table}[H]
\caption{My second Table}
\begin{tabular}{ |c|c|c| } 
 \hline
 cell1 & cell2 & cell3 \\ 
 cell4 & cell5 & cell6 \\ 
 cell7 & cell8 & cell9 \\ 
 \hline
\end {tabular}
\end{table}

\end{document}

여기에 이미지 설명을 입력하세요

업데이트

이는 사용하지 않고 xassoccnt간단한 확인만으로 \@captype해당 \total...카운터를 증가시킵니다.

\currentpdfbookmark섹션 수준을 관리하는 데 사용됩니다 .

\documentclass[12pt]{article}
\usepackage{todonotes}
\usepackage{graphicx}


\newcounter{totalfigure}
\newcounter{totaltable}

%\usepackage{xassoccnt}
%\DeclareAssociatedCounters{figure}{totalfigure}
%\DeclareAssociatedCounters{table}{totaltable}


\usepackage{float}
\restylefloat{table}
\restylefloat{figure}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{caption}


\usepackage{xparse}


\makeatletter
\AtBeginDocument{%
  \let\caption@@caption\caption


\RenewDocumentCommand{\caption}{som}{%
  %checking which caption type is here and stepping the relevant total counter
  \def\temp@@a{figure}
  \def\temp@@b{table}
  \ifx\@captype\temp@@a 
  \stepcounter{total\@captype}%
  \fi
  \ifx\@captype\temp@@b 
  \stepcounter{total\@captype}%
  \fi
  \IfBooleanTF{#1}{%
    \caption@@caption{#3}%
  }{%
    \IfValueTF{#2}{%
      \phantomsection
      \caption@@caption[#2]{#3}%
      \currentpdfbookmark{#2}{\@captype:\number\value{total\@cap@type}}%
    }{%
      \phantomsection
      \caption@@caption{#3}%
      \currentpdfbookmark{#3}{\@captype:\number\value{total\@captype}}%
    }%
  }%
}
}
\makeatother


\usepackage[a4paper, margin=3cm, top=3cm, bottom=3cm]{geometry}
\usepackage[bookmarks=true]{hyperref}
\usepackage{bookmark}
\hypersetup{
  linktocpage=true,
  colorlinks=true,
  linkcolor=blue,
  filecolor=blue,      
  urlcolor=blue,
  bookmarksopen=true
}



\bookmarksetup{numbered}

\title{%
  \begin{center}
    My Title
  \end{center}
} 
\date{}
\author{}

\begin{document}

\begin{titlepage}
\maketitle
\end{titlepage}

\setcounter{page}{2}%

\newpage
\pdfbookmark[0]{Contents}{Contents}
\tableofcontents
\listoffigures
\listoftables

\newpage
\section{My first section}

Bla, bla bla.

\begin{figure}[H]
\caption{My first Figure}
\missingfigure[figwidth=6cm]{}
\end{figure}

\begin{table}[H]
\caption{My first Table}
\begin{tabular}{ |c|c|c| } 
 \hline
 cell1 & cell2 & cell3 \\ 
 cell4 & cell5 & cell6 \\ 
 cell7 & cell8 & cell9 \\ 
 \hline
\end{tabular}
\end{table}

\newpage
\section{My second section}

More bla, bla.

\begin{figure}[H]
\caption{My second Figure}
\missingfigure[figwidth=6cm]{}
\end{figure}

\begin{table}[H]
\caption{My second Table}
\begin{tabular}{ |c|c|c| } 
 \hline
 cell1 & cell2 & cell3 \\ 
 cell4 & cell5 & cell6 \\ 
 cell7 & cell8 & cell9 \\ 
 \hline
\end {tabular}
\end{table}

\subsection{Foo subsection}

\begin{figure}[H]
\caption{My third Figure}
\missingfigure[figwidth=6cm]{}
\end{figure}

\begin{table}[H]
\caption{My third Table}
\begin{tabular}{ |c|c|c| } 
 \hline
 cell1 & cell2 & cell3 \\ 
 cell4 & cell5 & cell6 \\ 
 cell7 & cell8 & cell9 \\ 
 \hline
\end {tabular}
\end{table}


\subsubsection{Foo subsubsection}


\begin{figure}[H]
\caption{My fourth Figure}
\missingfigure[figwidth=6cm]{}
\end{figure}

\begin{table}[H]
\caption{My fourth Table}
\begin{tabular}{ |c|c|c| } 
 \hline
 cell1 & cell2 & cell3 \\ 
 cell4 & cell5 & cell6 \\ 
 cell7 & cell8 & cell9 \\ 
 \hline
\end {tabular}
\end{table}

\clearpage

\section{Yet another section}



\begin{figure}[H]
\caption{My sixth Figure}
\missingfigure[figwidth=6cm]{}
\end{figure}

\begin{table}[H]
\caption{My sixth Table}
\begin{tabular}{ |c|c|c| } 
 \hline
 cell1 & cell2 & cell3 \\ 
 cell4 & cell5 & cell6 \\ 
 cell7 & cell8 & cell9 \\ 
 \hline
\end {tabular}
\end{table}

\subsection{Foo subsection}

\begin{figure}[H]
\caption{My seventh Figure}
\missingfigure[figwidth=6cm]{}
\end{figure}

\begin{table}[H]
\caption{My seventh Table}
\begin{tabular}{ |c|c|c| } 
 \hline
 cell1 & cell2 & cell3 \\ 
 cell4 & cell5 & cell6 \\ 
 cell7 & cell8 & cell9 \\ 
 \hline
\end {tabular}
\end{table}


\subsubsection{Foo subsubsection}


\begin{figure}[H]
\caption{My eighth Figure}
\missingfigure[figwidth=6cm]{}
\end{figure}

\begin{table}[H]
\caption{My eighth Table}
\begin{tabular}{ |c|c|c| } 
 \hline
 cell1 & cell2 & cell3 \\ 
 cell4 & cell5 & cell6 \\ 
 cell7 & cell8 & cell9 \\ 
 \hline
\end {tabular}
\end{table}


\end{document}

다음 업데이트: 그림 등 숫자 포함

\documentclass[12pt]{article}
\usepackage{todonotes}
\usepackage{graphicx}


\newcounter{totalfigure}
\newcounter{totaltable}

%\usepackage{xassoccnt}
%\DeclareAssociatedCounters{figure}{totalfigure}
%\DeclareAssociatedCounters{table}{totaltable}


\usepackage{float}
\restylefloat{table}
\restylefloat{figure}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{caption}


\usepackage{xparse}


\makeatletter
\AtBeginDocument{%
  \let\caption@@caption\caption

\newcommand{\generatebookmark}[1]{%
  \belowpdfbookmark{\csname \@captype name\endcsname\ \csname the\@captype\endcsname: #1}{\@captype:\number\value{total\@captype}}%
}


\RenewDocumentCommand{\caption}{som}{%
  %checking which caption type is here and stepping the relevant total counter
  \def\temp@@a{figure}
  \def\temp@@b{table}
  \ifx\@captype\temp@@a 
  \stepcounter{total\@captype}%
  \fi
  \ifx\@captype\temp@@b 
  \stepcounter{total\@captype}%
  \fi
  \IfBooleanTF{#1}{%
    \caption@@caption{#3}%
  }{%
    \IfValueTF{#2}{%
      \phantomsection
      \caption@@caption[#2]{#3}%
      \generatebookmark{#2}%
    }{%
      \phantomsection
      \caption@@caption{#3}%
      \generatebookmark{#3}%
    }%
  }%
}
}
\makeatother


\usepackage[a4paper, margin=3cm, top=3cm, bottom=3cm]{geometry}
\usepackage[bookmarks=true]{hyperref}
\usepackage{bookmark}
\hypersetup{
  linktocpage=true,
  colorlinks=true,
  linkcolor=blue,
  filecolor=blue,      
  urlcolor=blue,
  bookmarksopen=true
}



\bookmarksetup{numbered}

\title{%
  \begin{center}
    My Title
  \end{center}
} 
\date{}
\author{}

\begin{document}

\begin{titlepage}
\maketitle
\end{titlepage}

\setcounter{page}{2}%

\newpage
\pdfbookmark[0]{Contents}{Contents}
\tableofcontents
\listoffigures
\listoftables

\newpage
\section{My first section}

Bla, bla bla.

\begin{figure}[H]
\caption{My first Figure}
\missingfigure[figwidth=6cm]{}
\end{figure}

\begin{table}[H]
\caption{My first Table}
\begin{tabular}{ |c|c|c| } 
 \hline
 cell1 & cell2 & cell3 \\ 
 cell4 & cell5 & cell6 \\ 
 cell7 & cell8 & cell9 \\ 
 \hline
\end{tabular}
\end{table}

\newpage
\section{My second section}

More bla, bla.

\begin{figure}[H]
\caption{My second Figure}
\missingfigure[figwidth=6cm]{}
\end{figure}

\begin{table}[H]
\caption{My second Table}
\begin{tabular}{ |c|c|c| } 
 \hline
 cell1 & cell2 & cell3 \\ 
 cell4 & cell5 & cell6 \\ 
 cell7 & cell8 & cell9 \\ 
 \hline
\end {tabular}
\end{table}

\subsection{Foo subsection}

\begin{figure}[H]
\caption{My third Figure}
\missingfigure[figwidth=6cm]{}
\end{figure}

\begin{table}[H]
\caption{My third Table}
\begin{tabular}{ |c|c|c| } 
 \hline
 cell1 & cell2 & cell3 \\ 
 cell4 & cell5 & cell6 \\ 
 cell7 & cell8 & cell9 \\ 
 \hline
\end {tabular}
\end{table}


\subsubsection{Foo subsubsection}


\begin{figure}[H]
\caption{My fourth Figure}
\missingfigure[figwidth=6cm]{}
\end{figure}

\begin{table}[H]
\caption{My fourth Table}
\begin{tabular}{ |c|c|c| } 
 \hline
 cell1 & cell2 & cell3 \\ 
 cell4 & cell5 & cell6 \\ 
 cell7 & cell8 & cell9 \\ 
 \hline
\end {tabular}
\end{table}

\clearpage

\section{Yet another section}



\begin{figure}[H]
\caption{My sixth Figure}
\missingfigure[figwidth=6cm]{}
\end{figure}

\begin{table}[H]
\caption{My sixth Table}
\begin{tabular}{ |c|c|c| } 
 \hline
 cell1 & cell2 & cell3 \\ 
 cell4 & cell5 & cell6 \\ 
 cell7 & cell8 & cell9 \\ 
 \hline
\end {tabular}
\end{table}

\subsection{Foo subsection}

\begin{figure}[H]
\caption{My seventh Figure}
\missingfigure[figwidth=6cm]{}
\end{figure}

\begin{table}[H]
\caption{My seventh Table}
\begin{tabular}{ |c|c|c| } 
 \hline
 cell1 & cell2 & cell3 \\ 
 cell4 & cell5 & cell6 \\ 
 cell7 & cell8 & cell9 \\ 
 \hline
\end {tabular}
\end{table}


\subsubsection{Foo subsubsection}


\begin{figure}[H]
\caption{My eighth Figure}
\missingfigure[figwidth=6cm]{}
\end{figure}

\begin{table}[H]
\caption{My eighth Table}
\begin{tabular}{ |c|c|c| } 
 \hline
 cell1 & cell2 & cell3 \\ 
 cell4 & cell5 & cell6 \\ 
 cell7 & cell8 & cell9 \\ 
 \hline
\end {tabular}
\end{table}


\end{document}

여기에 이미지 설명을 입력하세요

관련 정보