As addressed in Temporarily change font encoding with fontenc, I need to switch to T1 encoding to get certain T1 glyphs. This compiles fine with hyperref:
\documentclass{article}
\usepackage[T1, OT1]{fontenc}
\usepackage{hyperref}
\begin{document}
Har{\fontencoding{T1}\selectfont{\dh}}arson
\end{document}
As addressed in \renewcommand and \newcommand for accented letters, I'm redefining some T1 macros in my preamble. In this case, however, hyperref seems to insist that the encoding is still in OT1 (it compiles fine without hyperref).
\documentclass{article}
\usepackage[T1, OT1]{fontenc}
\renewcommand{\dh}{\fontencoding{T1}\selectfont{\symbol{240}}}
\usepackage{hyperref}
\begin{document}
Har{\dh}arson
\end{document}
LaTeX Error: Command \dh unavailable in encoding OT1.
What is going on here ... ?
EDIT:
It turns out that it works fine if the macro is redefined after hyperref is loaded:
\documentclass{article}
\usepackage[T1, OT1]{fontenc}
\usepackage{hyperref}
\renewcommand{\dh}{\fontencoding{T1}\selectfont{\symbol{240}}}
\begin{document}
Har{\dh}arson
\end{document}
So this now begs the question why hyperref causes this behavior.
\DeclareTextSymbolDefault! :) – Sverre Sep 06 '13 at 11:43\DeclareTextSymbolDefault{\aa}{T1}. Then I get aTeX capacity exceeded, sorry [grouping levels=255].error. – Sverre Sep 06 '13 at 11:52\aais not an "encoding dependent" command; it just expands to\r{a}and it's\rto be encoding dependent. – egreg Sep 06 '13 at 12:16\DeclareTextCompositeCommand{\r}{OT1}{a}{{\fontencoding{T1}\selectfont\aa}}? – Sverre Sep 06 '13 at 12:20\aawould work also for bookmarks. – egreg Sep 06 '13 at 12:33