0

This is my first time posting to this site so I apologize for any and all mistakes on my part.

I am trying to write a document using the tufte-book document class. Specifically, I am using the overleaf template given here https://www.overleaf.com/latex/templates/a-tufte-style-book-with-vdqi-title-and-contents-page/xqkjxvmrhmmp (this is a link to an overleaf page).

I would like to use this template because of the way it formats the table of contents [TOC]. Yet, I noticed that the TOC is not clickable. I know that the package hyperref is by far the recommended choice for making the TOC clickable (as suggested by this post How can I make a clickable Table of Contents? and many others). However, the comments on lines 19-21 of this overleaf template, unfortunately, specifically say that hyperref cannot be used lest the TOC's formatting breaks down. The following line (number 22) looks like this \documentclass[nohyper,nobib]{tufte-book}.

So, I would like to ask if there is any (reasonably implementable) way to make a clickable TOC in the tufte-book class that does not use the hyperref package (while still maintaining this formatting of the TOC)? Or maybe there is a way of getting the TOC to be clickable with hyperref while avoiding any issues with the tufte-book class?

Thank you for your time and help!


EDIT: Example included

I realize it was unreasonable to not include a shortened example. What follows is all of the preamble code that I believe is required for the formatting of the title page and TOC. (This has been exactly copy-pasted from the overleaf template, with all unnecessary packages/code removed).

%% Unfortunately for the contents to contain
%% the "Parts" lines successfully, hyperref
%% needs to be disabled.
\documentclass[nohyper,nobib]{tufte-book}

% Book metadata \title{A Tufte-Style Book} \date{The edition number} \author[The Tufte-LaTeX Developers (with modifications)]{The Tufte-LaTeX\ Developers (with modifications)} \publisher{Publisher of This Book}

%%%% Kevin Godny's code for title page and contents from https://groups.google.com/forum/#!topic/tufte-latex/ujdzrktC1BQ \makeatletter \renewcommand{\maketitlepage}{% \begingroup% \setlength{\parindent}{0pt}

{\fontsize{24}{24}\selectfont\textit{@author}\par}

\vspace{1.75in}{\fontsize{36}{54}\selectfont@title\par}

\vspace{0.5in}{\fontsize{14}{14}\selectfont\textsf{\smallcaps{@date}}\par}

\vfill{\fontsize{14}{14}\selectfont\textit{@publisher}\par}

\thispagestyle{empty} \endgroup } \makeatother

\titlecontents{part}% [0pt]% distance from left margin {\addvspace{0.25\baselineskip}}% above (global formatting of entry) {\allcaps{Part~\thecontentslabel}\allcaps}% before w/ label (label = ``Part I'') {\allcaps{Part~\thecontentslabel}\allcaps}% before w/o label {}% filler and page (leaders and page num) [\vspace*{0.5\baselineskip}]% after

\titlecontents{chapter}% [4em]% distance from left margin {}% above (global formatting of entry) {\contentslabel{2em}\textit}% before w/ label (label = ``Chapter 1'') {\hspace{0em}\textit}% before w/o label {\qquad\thecontentspage}% filler and page (leaders and page num) [\vspace*{0.5\baselineskip}]% after %%%% End additional code by Kevin Godby

A minimal example of the document body would be as follows (my own code).

\begin{document}
%%% LAYOUT
\frontmatter
\maketitle
\tableofcontents
\cleardoublepage
\mainmatter

%%% PART 1 \part{Example 1} \chapter{Ex 1 Ch 1} Testing. \chapter{Ex 1 Ch 2} Testing.

%%% PART 2 \part{Example 2} \chapter{Ex 2 Ch 1} Testing. \chapter{Ex 2 Ch 2} Testing. \end{document}

The TOC would then look like this while also being unclickable.

Example TOC Picture

Adding the hyperref package to the preamble leads to many compiling errors. Changing line 4 in the preamble example above to \documentclass{tufte-book} also leads to many errors. (Maybe I should note that only removing the code nobib in line 4, so that it becomes \documentclass[nohyper]{tufte-book}, does not lead to any errors. So it seems nohyper is required but not nobib.)


EDIT2: Showing errors

Based off of the comments, this may be a compiler-specific issue. I am using a university service that says "Powered by ShareLatex 2016" and looks almost identical to overleaf. (Please let me know how to provide further specifications if needed).

Upon removing the nohyper option from the code above, the table of contents looks like this.

glitched TOC

So the lines indicating Part I and Part II have changed. I should note that the chapters (Ex 1 Ch1, Ex 2 Ch 2, ... ) become clickable links to the correct pages. However, the lines for Part I and Part II are not clickable.

Some of the errors are

Undefined control sequence. output.toc, line 1

error example 1

Missing control sequence inserted. output.toc, line 1

error example 2

Undefined control sequence. output.toc, line 4

error example 3

Extra \endgroup. output.toc, line 52

error example 4

Package ifplatform Warning: shell escape is disabled, so I can only detect \ifwindows.

None of these errors seem to occur when using overleaf. Unfortunately, for this project, I have to use the university-provided service.

If there are better ways of showing the errors, please let me know.

stowo
  • 101
  • 1
    You need hyperref for the links. I can't tell you if can adapt your template, as you didn't provide a small example here and I won't debug a template from an external site. – Ulrike Fischer Jan 21 '24 at 10:05
  • @UlrikeFischer Thank you for the suggestion; I apologize for the lack of an example. I have edited the question to include one now. – stowo Jan 21 '24 at 15:45
  • @stowo If I puzzle your code fragments into one document, I can remove the nohyper option without problem. The toc becomes clickable and it compiles without errors. What errors do you get without the nohyper option? – samcarter_is_at_topanswers.xyz Jan 21 '24 at 16:19
  • @samcarter_is_at_topanswers.xyz wow, so I have put the same code into overleaf and it compiles smoothly just as you said. I was originally using a university owned latex service that says it is "powered by ShareLatex 2016" (and it looks almost exactly like overleaf). In that compiler, when removing the nohyper option, I got 16 errors. Most of them say "undefined control sequence", "missing control sequence inserted", "extra \endgroup" and they all cite of "output.toc" lines 1, 4 or 52. I dont know how to access the "ouput.toc" file. I think it gets automatically deleted by the compiler – stowo Jan 21 '24 at 16:47
  • @samcarter_is_at_topanswers.xyz I apologize, if there is a better way to share the errors, please let me know. I am happy to edit the post again and include pictures. Maybe I should also note the last error says "Package ifplatform Warning: shell escape is disabled, so I can only detect \ifwindows." – stowo Jan 21 '24 at 16:48
  • I have now edited the post to show the errors which occur. I completely understand if this issue is too dependent on the compiler and cannot be reasonably answered by this site. – stowo Jan 21 '24 at 17:08
  • @stowo The problem is probably the outdated latex version from sharelatex 2016. – samcarter_is_at_topanswers.xyz Jan 21 '24 at 19:17

0 Answers0