Hi,
I am currently trying to use my school's thesis document class, however it will not work with the hyperref package. I have contacted the graduate school, but no clue if I'll get any help from them... Anyways, I have attached a minimum code example below that uses their document class and macros file. It will compile great until you add the hyperref package. The error has to do with the \contentsline command... Any help figuring out why this is breaking it would be greatly appreciated!! Thanks!
Document Classes ⇒ hyperref | Issue with custom Document Class
-
- Posts: 9
- Joined: Mon Oct 18, 2010 11:52 pm
hyperref | Issue with custom Document Class
- Attachments
-
- mythesis.tex
- (1.85 KiB) Downloaded 433 times
-
- macros.tex
- (865 Bytes) Downloaded 424 times
-
- thesis.cls
- (40.64 KiB) Downloaded 595 times
NEW: TikZ book now 40% off at Amazon.com for a short time.
hyperref | Issue with custom Document Class
The problem comes from the \addtocontents commands included in thesis.sty. They write \contentsline commands in the toc, lof and lot files. But this command has an extra argument when hyperref is loaded. Hence, when LaTeX reads the auxiliary files, it detects that such an argument is missing, hence the error.
The solution is simple: search for \addtocontents in thesis.cls and replace each {\protect\relax}} by {\protect\relax}{}}. You should have the lines:
and also
Note the extra pair of braces at the end of every \addtocontents. It has no effect if hyperref is not loaded, but it provides the extra argument for \contentsline, otherwise.
If the above code works, contact your school in order to improve thesis.cls.
I also suggest you to treat your macros file as a package. To this end, rename macros.tex to macros.sty, add the line at the top of macros.sty, delete \input macros.tex in the source file and write \usepackage{macros} instead (in the preamble, before \begin{document}).
The solution is simple: search for \addtocontents in thesis.cls and replace each {\protect\relax}} by {\protect\relax}{}}. You should have the lines:
Code: Select all
\addtocontents{lof}{\protect\contentsline {part}
{\protect\figurenameToC}{\protect\relax}{}}
\addtocontents{lot}{\protect\contentsline {part}
{\protect\tablenameToC}{\protect\relax}{}}
\addtocontents{toc}{\protect\contentsline {part}
{\protect\chapternameToC}{\protect\relax}{}}
Code: Select all
\addtocontents{toc}{\protect\contentsline {part}
{\protect\appendixnameToC}{\protect\relax}{}}
If the above code works, contact your school in order to improve thesis.cls.
I also suggest you to treat your macros file as a package. To this end, rename macros.tex to macros.sty, add the line
Code: Select all
\RequirePackage{macros}
The CTAN lion is an artwork by Duane Bibby. Courtesy of www.ctan.org.
hyperref | Issue with custom Document Class
I have the same error with the
Hopeful regards
--schremmer
book
class and I don't think I want to change that. So, might there be some other way?Hopeful regards
--schremmer
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
hyperref | Issue with custom Document Class
For an adequate problem description and in order to prevent other from guesswork kindly prepare a self-contained and minimal example that clearly reproduces the undesired behaviour.schremmer wrote:I have the same error with thebook
class and I don't think I want to change that. So, might there be some other way? […]
Thorsten
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10