I have a tex file which is like this :
\cleardoublepage
\phantomsection
\includepdf[pages=-,addtotoc={ 1,section,1, 200_project_title: , p1,
1,subsection,1,Section A - Project Identification, p2,
1,subsection,1,Section C - Basic or Applied Research,p3,
3,subsection,1,Section D - Additional project information,p4
}]{fixed_2010_2.pdf}
pdflatex fails to compile wherever there is undercore in section title
e.g 200_project_title:
It would be great if someone help me fine out a better way to pass section title without escaping those underscore and possibility handling other special characters which might mess up with compilation
thanks
EDIT: using
\begingroup \catcode'\_=12 \tableofcontents \endgroup
EDIT: using
in preamble : \usepackage[T1]{fontenc}
and for table of contents
\begingroup \catcode'\_=12 \tableofcontents \endgroup
Working one after you kind suggestions and answers:
This working now for me (do not know any hazards yet) thank you for all your suggestions:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{pdfpages}
\usepackage[
pdfpagelabels=true,
pdftitle={Report Title},
pdfauthor={sakhunzai},
]{hyperref}
\usepackage[T1]{fontenc}
\hypersetup{
colorlinks=true,
linkcolor=blue
}
\begin{document}
\catcode`\_=12
\cleardoublepage
\pdfbookmark{\contentsname}{toc}
\pagenumbering{roman}
\tableofcontents
\cleardoublepage
\phantomsection
\includepdf[pages=-,addtotoc={ 1,section,1, 200_project_title: , p1,
1,subsection,1,Section A - Project Identification, p2,
1,subsection,1,Section C - Basic or Applied Research,p3,
3,subsection,1,Section D - Additional project information,p4
}]{fixed_2010_2.pdf}
\end{document}
Best Answer
If you want to avoid using
\_
for underscore you need to make it an ordinary character and use a font encoding that supports it so addto the preamble and then include the table of contents file the includes underscores with
If for some reason you are committed to
OT1
fonts and still want to avoid quoting_
then you could instead use