Categories

See More
Popular Forum

MBA (4887) B.Tech (1769) Engineering (1486) Class 12 (1030) Study Abroad (1004) Computer Science and Engineering (988) Business Management Studies (865) BBA (846) Diploma (746) CAT (651) B.Com (648) B.Sc (643) JEE Mains (618) Mechanical Engineering (574) Exam (525) India (462) Career (452) All Time Q&A (439) Mass Communication (427) BCA (417) Science (384) Computers & IT (Non-Engg) (383) Medicine & Health Sciences (381) Hotel Management (373) Civil Engineering (353) MCA (349) Tuteehub Top Questions (348) Distance (340) Colleges in India (334)
See More

\let vs hyperrref

Course Queries Syllabus Queries

Max. 2000 characters
Replies

usr_profile.png

User

( 4 months ago )

 

In the following sample from my custom syllabus class, I am getting a new error since updating my TeXLive 2015 distribution to the most recent release today. The error is TeX capacity exceeded.

As far as I can tell the error is the result of an interaction between the \let, the \addcontentslinecommand, and the hyperref package. If I define \term as a regular \newcommand, or if I omit the \addcontentsline, then it works with hyperref.

Why can't I use a \let command inside \addcontentsline with hyperref?

\documentclass{article}
\usepackage{xparse}

\newcounter{Week}
\newcommand{\WeekLabel}{Week \theWeek\quad}
\DeclareDocumentCommand{\Week}{o m}{%                                                                                                                                                          
  \stepcounter{Week}
  \def\ThisWeek{\WeekLabel #2}
  \subsection*{\ThisWeek}
  \addcontentsline{toc}{subsection}{\ThisWeek}%                                                                                                                                                
}

\newcommand{\term}[1]{\emph{#1}} % no error                                                                                                                                                    
%\let\term\emph % produces error with hyperref, why?                                                                                                                                           

\usepackage{hyperref}

\begin{document}

\section*{Syllabus}
\tableofcontents

\section{Eighteenth-Century Opera}

\Week[11/09]{Italian \term{opera seria}}

\Week[11/15]{Italian \term{opera buffa}}

\end{document}

usr_profile.png

User

( 4 months ago )

The title in \addcontentsline is also used in the bookmarks. There, the text should be expandable. \emph cannot be used for this reason. Also fonts cannot be changed inside bookmarks strings. Package hyperref redefines \emph inside the bookmarks. But it does not see \emph anymore, when \term is defined via \let.

The easiest solution is using \newcommand as in the question, a little optimized:

\newcommand{\term}{\emph}

Otherwise, \term needs to be redefined inside bookmarks:

\usepackage{hyperref}
\pdfstringdefDisableCommands{\let\term\relax}

what's your interest


forum_ban8_5d8c5fd7cf6f7.gif