6

I wrote a small new command that makes use of \@currentlabelname and \nameref. When I have Umlauts in the labelname (the argument of \@currentlabelname) everything works fine until I use the fontenc package. Then the umlauts are not correctly escaped/transformed into the .aux-File, which then causes an inputenc error.

Here is a minimal example. Run twice to get the error! Any ideas how to make this work with fontenc?

\documentclass{scrartcl}
\usepackage[T1]{fontenc} %causes Umlauts in -aux-file and therefore an inputenc-error on the second run
\usepackage[utf8]{inputenc}
\usepackage{hyperref}

\makeatletter
\newcommand\AP[1]{%
    \subsubsection*{#1}%
    \edef\@currentlabelname{#1}%
    }
\makeatother
\begin{document}
    \AP{endgültig}
    \label{foo}
    \nameref{foo}
\end{document}
4

1 Answer 1

6

You can solve the issue by using \protected@edef instead of \edef:

\documentclass{scrartcl}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{hyperref}

\makeatletter
\newcommand\AP[1]{%
  \subsubsection*{#1}%
  \protected@edef\@currentlabelname{#1}%
}
\makeatother
\begin{document}

\AP{endgültig}\label{foo}

\nameref{foo}

\end{document}

You must log in to answer this question.

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