Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have some scanned pdf documents which I want to put together in a latex file and structure them with sections which appear only in the TOC. This has the advantage, that I can jump to the page using hyperref.

However with this code only text is added to the toc, but I would like them to be numbered as if I had written a normal \section.

\phantomsection\addcontentsline{toc}{chapter}{SI-System}
\includepdf[pages=1-3,pagecommand={\thispagestyle{plain}}]{02-SI.pdf}
share|improve this question
add comment

2 Answers 2

up vote 9 down vote accepted

You can use the addtotoc option for the \includepdf command; this option has the syntax

addtotoc={<page number>,<section>,<level>,<heading>,<label>}

where <page number> is the page number of the inserted document that will be linked to from the ToC, <section> is the LaTeX sectioning name (e.g., section, subsection,...), <level> denotes depth of section (e.g., 1 for section level, 2 for subsection level,...), <heading> is the title inserted in the table of contents, and <label> is the name of the label which can be referred to with \ref and \pageref.

With your current approach you can use \numberline to add the number of the corresponding sectional unit to the ToC; for example, you can say something like:

\phantomsection\addcontentsline{toc}{chapter}{\protect\numberline{\thechapter}SI-System}

Here's an example or the use of addtotoc option (kindly provided by Marco Daniel):

\RequirePackage{filecontents}
\begin{filecontents}{\jobname-a5.tex}
\documentclass[english,paper=a5]{scrartcl}
\usepackage{geometry}
\usepackage{babel,blindtext}
\begin{document}
\Blinddocument
\end{document}
\end{filecontents}

\documentclass{scrartcl}
\immediate\write18{pdflatex \jobname-a5.tex}
\usepackage{pdfpages,lipsum}
\includepdfset{frame,noautoscale}
\setlength{\fboxrule}{5pt}

\begin{document}
\tableofcontents
\section{foo}
\lipsum[1]
\includepdf[pages=-,addtotoc={1,section,1,Eintrag im Inhaltsverzeichnis,mylabel}]{\jobname-a5}
\end{document}

save the file as, for example, test.tex and run it using

pdflatex --shell-escape test
share|improve this answer
    
addtotoc does not work for me because I do not know the pagenumber and \protect\numberline{\thechapter} adds a number, but that is always 0, since there is nothing which could change it. –  Matthias Pospiech Dec 15 '11 at 18:36
    
@MatthiasPospiech: but you can always use 1 for <page number>; this way, the first page of the included document will be linked from the ToC. –  Gonzalo Medina Dec 15 '11 at 20:09
    
Ok, now I understand the meaning of the 'number' –  Matthias Pospiech Dec 15 '11 at 20:41
add comment

I solved it now by defining the numbering myself:

\renewcommand{\chapter}[1]{
  \setcounter{section}{0}
  \addtocounter{chapter}{1}
  \phantomsection\addcontentsline{toc}{chapter}
    {\protect\numberline{\thechapter}#1}
}

\renewcommand{\section}[1]{
  \addtocounter{section}{1}
  \phantomsection\addcontentsline{toc}{section}
    {\protect\numberline{\thesection}#1}
}

and using these redefined chapter and section commands.

share|improve this answer
    
Please delete you answer. Such hack isn't a qualified answer. –  Marco Daniel Dec 15 '11 at 18:53
    
Then please provide something better. The other answer does not provide any numbering and all I did was to extent that approach by numbering the sections automatically. –  Matthias Pospiech Dec 15 '11 at 19:00
    
I will provide an example which uses the command addtotoc. –  Marco Daniel Dec 15 '11 at 19:18
    
The page number of addtotoc is the number of the page which will be linked. –  Marco Daniel Dec 15 '11 at 19:23
    
@MarcoDaniel: I add > 50 pdfs, all with different page counts. The number must be inserted automatically, otherwise the addtotoc is no option for me. –  Matthias Pospiech Dec 15 '11 at 20:00
show 2 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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