6

One section of my article is a table. Because of space limitation, I cannot put section title in the same page as the table. On the other hand, I want my section title appear in pdf bookmarks. How can I define a hidden section name and make sure that it is going to appear in toc and more importantly in pdf bookmarks. By the way, I don't want to make my table smaller.

I tried the solution suggested in make section headings invisible and it doesn't work.

N Nik
  • 3,669
  • 2
    It would be helpful if you showed how the answer at the linked question does not work by composing a fully compilable MWE including \documentclass and the appropriate packages that sets up the problem. While solving problems is fun, setting them up is not. Then those trying to help can simply cut and paste your MWE and get started on solving problem. – Peter Grill Nov 05 '12 at 05:47
  • I used \pdfbookmark[n]{}{} and it worked. Thanks a lot for your comment. – N Nik Nov 05 '12 at 06:08
  • 1
    Excellent. It would be helpful if you posted an answer explaining that as it would be helpful to others that have the same problem in the future. Self-answers are welcome. Ideal would be if you posted a complete compilable example. – Peter Grill Nov 05 '12 at 06:10
  • You are absolutely right and I apologize I forgot to answer your question. I checked my document again. And here is the answer. Both solutions work. Either the one suggested in the above link or using \pdfbookmark. My mistake was that I wasn't entering these commands at the right place in the document. Sorry for posting a redundant question. Please feel free to remove this it. – N Nik Nov 05 '12 at 06:24
  • 1
    Again that can still be useful to others. I am sure you are not the last person to make this mistake so adding that as an answer would be a good idea. Actually it might even help you in the future -- I often refer to a lot of my earlier questions (and answers) as I need the same info and forgot exactly how it was solved previously. – Peter Grill Nov 05 '12 at 06:32
  • True, so here is the situation: my page was basically a big table and I didn't have the luxury of entering a section name. However, I wanted the section name to appear in pdf bookmark. and my mistake: I was entering the \pdfbookmark (or the piece of code you can find in the above link) before \begin{table} and strangly the pdf file bookmark was linked to a very different page. I copied \pdfbookmark after \begin{table} and it solved all the problems. Thanks – N Nik Nov 05 '12 at 06:34
  • Sorry if I was not clear, I did not mean to imply to add a comment, but rather provide a self answer by filling out the portion below and explaining what went wrong and how you fixed it. – Peter Grill Nov 05 '12 at 06:37

1 Answers1

3

my page was basically a big table and I didn't have the luxury of entering a section name. However, I wanted the section name to appear in pdf bookmark.

\documentclass[12pt]{article}
\usepackage{url}
\usepackage[pdftex]{hyperref} %% comes last
\hypersetup{ 
pdftitle={}, 
pdfauthor={},
bookmarks=true, bookmarksopen=true, pdftoolbar=true, 
pdffitwindow=false,
colorlinks=false,
linkcolor=red, 
citecolor=red,
filecolor=magenta,
urlcolor=black }
\usepackage{bookmark}

\begin{document}    
\newpage%

% LOCATION A

\begin{table}[htb] \centering
% LOCATION B

Possible solution 1:

\newcommand\invisiblesection[1]{%
  \refstepcounter{section}%
  \addcontentsline{toc}{section}{\protect\numberline{\thesection}#1}%
  \sectionmark{#1}}
enter chapter title here
\invisiblesection{text you want to appear in pdf file}

Possible solution 2:

\pdfbookmark[1]{title}{comment}

My mistake: I tried each of these solutions in Location A.
Consequence: strangly the pdf file bookmark was linked to a very different page.

Solution: Try them at Location B

N Nik
  • 3,669