0

The MWE is the tstextbook template: https://www.typesetters.se/latex-textbook-template/

Inserting \usepackage{hyperref} in the preamble of the file tstextbook.tex results in error message like so:

./tstextbook.mtc1:1: Argument of \contentsline has an extra }

I understand that the reason for the error is because hyperref redefines \contentsline to take four arguments instead of three as referenced here: Hyperref in toc without page number

If I modify the file tstextbook.mtc1 and make the first line to equal below:

{\reset@font\mtcSfont\mtc@string\contentsline{section}{\noexpand \leavevmode \numberline {1.1}First Section}{\reset@font\mtcSfont 2}{}}

... then the new error is

./tstextbook.mtc1:2: Argument of \contentsline has an extra }

So the solution seems fairly clear, in that the extra brackets need to be inserted. However, I am still struggling with how/where the .mtc files are auto-generated. Manually changing the .mtc files myself is not a permanent fix since the template somehow creates the .mtc files automatically.

Bonus points if you can provide a working solution that uses the tstextbook template and hyperlinks the TOC to appropriate pages within the doc, but am happy to post another follow-up question later once the first one here just regarding including the package is resolved.

1
  • 1
    Try to delete the auxiliary files and then recompile. If it still breaks: this is a template from a commercial site. So I suggest that you ask their support to debug the template. Commented Jan 3, 2021 at 19:48

1 Answer 1

0

To be able to compile tstextbook.tex I only made the following changes to the tstextbook.cls to replace two images.

line 50 contents={\includegraphics[width=\paperwidth,height=\paperheight]{example-image-A}}}

line 353 \marginpar{\vspace{-3mm}\includegraphics[width=1.0cm]{example-image}}}

Then I addded, before \begin{document} a basic hyperref setup plus bookmark

\PassOptionsToPackage{hyphens}{url}
\usepackage[bookmarks=true,  
pdfpagelabels=true % 
]{hyperref}


\hypersetup{%
    bookmarksnumbered=true,     
    bookmarksopen=true,         
    bookmarksopenlevel=3,   
    colorlinks, 
    breaklinks,
    linkcolor=blue,
    citecolor=blue,
    urlcolor=green, 
    filecolor=black,
    linktocpage=true, 
} 

\RequirePackage{bookmark} % more modern management for bookmarks en pdf

After the compilation I found the hyperlinks working properly, to pages in the main TOC and in the individual TOC of the chapters. (color blue)

Also the bookmarks in the pdf.

a

b

I did not make changes of any kind to any mtc file.

2
  • Excellent, thanks! The cls image changes are not need, just the preamble works! BTW what motivated the pic change recommendation? curious
    – dj_a
    Commented Jan 3, 2021 at 21:45
  • Because I only downloaded the .tex and .cls files. I didn't want to waste time checking a .zip file from an unknown source. I did it later and it was fine. Commented Jan 4, 2021 at 13:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .