# hyperref vs includepdf

\documentclass[12pt,a4paper]{mwrep}
\usepackage{polski}
\usepackage[cp1250]{inputenc}
\usepackage{pdfpages}
\renewcommand\baselinestretch{1.5}

\usepackage{etoolbox}
\patchcmd{\thebibliography}{*}{}{}{}

\makeatletter
\pretocmd{\tableofcontents}{%
\if@openright\cleardoublepage\else\clearpage\fi
\pdfbookmark[0]{\contentsname}{toc}%
}{}{}%
\makeatother

\begin{document}
%\begin{titlepage}
%\includepdf[pages=1-]{titlepage.pdf}
%\end{titlepage}
\tableofcontents
\chapter{A}
a\dots
\chapter{B}c\dots
\chapter{D}
d\dots
\chapter{E}
e\dots

\begin{thebibliography}{999}
\bibitem{bib1}Author:
\emph{Title},
Publisher, Year
\end{thebibliography}
\end{document}


Everything works good, I have nice links in pdf viewer. But when I uncomment three lines with includepdf I got errors when trying to compile. titlepage.pdf contains two pages but I don't think this is relevant.

Second question, how can I add something to bookmars (generated by hyperref)? I want to add ToC as well as first page of titlepage.pdf.

Also, adding titlepage.pdf brokes page numeration in pdf viewer (bookmarks). When I try to go to page 7, I to to page 5 instead. Can it be fixed? (I know it is the result of adding two extra pages at the beginning).

Also, hyperref changes Polish letters.
I have chapter Wstęp but in bookmarks there is Wstep.
Can it be fixed?

EDIT:
Bookmark to ToC solved.

EDIT 2:
One more thing that I need is adding included pdf's first page to bookmarks.

-
As for the Polish diacritics in pdf bookmarks: AFAIR, you can't get them, since adobe reader (or at least its older versions) displays bookmarks with a built-in font with very small repertoire of characters. So substituting "Wstep" for "Wstęp" is perfectly reasonable. (Although I'm by no means expert as far as pdf format goes - this may as well be wrong nowadays, pdf wizards please correct me if its the case!) –  mbork Jul 13 '11 at 23:22
@mbork: Yes, you're wrong. :) @Ichibann: Pass unicode option to hyperref package, but you possibly should convert your doc to UTF-8 before (and obviously change then inputenc option to utf8). –  przemoc Jul 14 '11 at 0:14
I converted my documents to utf8 in Notepad++, but now LEd wont work with them :(. It displays WstÄ™p instead of Wstęp (but compiles correctly) –  Ichibann Jul 14 '11 at 0:25
Is LEd maintained even at all now? By looking at its page it looks like it is pretty dead. Currently we are working on: adding support for Unicode and UTF-7, UTF-8, UTF-16, UTF-32 encodings,... Notepad++ isn't best tool for conversion, because it's damn easy to screw there encoding (BTW you should go w/o BOM). Also add \usepackage[T1]{fontenc} to your preamble apart from fixed inputenc setting. You may also go with T1,OT4, but it is more tricky if you use some other fonts, thus it requires switching via \fontencoding{T1}. Gain is only in a few KBs, so I suggest sticking just to T1. –  przemoc Jul 14 '11 at 0:31
I think Notepad++ didn't screw anything here. What LaTeX editor supports UTF8? –  Ichibann Jul 14 '11 at 0:33

If the "errors" are like

pdfTeX warning
(ext4): destination with the same identifier (name{page.1}) has been already used, duplicate ignored


then they are solved by saying

\begin{document}
\pagenumbering{Alph}
\begin{titlepage}
\includepdf[pages=1-]{titlepage.pdf}
\end{titlepage}
\pagenumbering{arabic}
\tableofcontents


The reason is that hyperref finds two "page 1", which is not the case if we order LaTeX to number with letters the first two pages.

-
That worked :). Can you help me with bookmark to included pdf? –  Ichibann Jul 14 '11 at 0:06
You can just add a \pdfbookmark{Title page}{} before \includepdf. –  egreg Jul 14 '11 at 7:13