pdflatex returns on below document
\documentclass[a4paper]{article}
\usepackage{hyperref}
\let\code\texttt
\begin{document}
\section{\texttt{first}}
\section{\code{second}}
\end{document}
following error:
! Argument of \@sect has an extra }.
<inserted text>
\par
l.6 \section{\code{second}}
I like semantic command naming, thus I use my own short commands instead of \texttt and such, Moreover, unless I introduce some new parts in them, I prefer to use \let, which is more efficient than \def/\newcommand (which works fine in this case).
Question
Why hyperref doesn't like commands set via \let in section titles?
Supplementary question
If there is anything wrong with
\let\code\texttt
then how it should be fixed?
\protectfor macros inside\sectionetc. macros. I might know this and just don't use it to keep the example minimal. – Martin Scharrer♦ Jul 3 '11 at 16:38