I am trying to create a header that consist of chaptername and sectionname (chaptername:sectionname) both of them a hyperlink to chapter and section respectively. I am using Hungarian language so there are many accented word, and - as I gathered - hyperref do not support accented links and after all, section names can be the same in different chapters so I need to get some unique names. So I generate a unique ASCII section name (see \Section) and in \sectionmark I concatenated it with the name of the section and in \fancyhead I try to separate them again and using them in a \hyperlink command, but so far I failed. Here is the brief (not working) code example:

\documentclass[pdftex,a4paper,12pt,oneside]{book}%

\usepackage[latin2]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[magyar]{babel}
\usepackage{fancyhdr}
\usepackage{xstring}
\usepackage{hyperref}
\usepackage{bookmark}

hypertexnames=false,
unicode=true,
bookmarksnumbered=false,
pdftoolbar=true
}

\newcommand{\secname}{}
\newcommand{\mystrsplit}[4]{
\renewcommand{#3}{\StrBefore{#1}{#2}}
\renewcommand{#4}{\StrBehind{#1}{#2}}
}

%------------------

\begin{document}

\pagestyle{fancy}
\fancyhf{}
\renewcommand{\chaptermark}[1]{\markboth{##1}{}}

\renewcommand{\footrulewidth}{0pt}

\Chapter{Állóképek}{Allokepek}

\Section{Tükörkép}{Tukorkep}

\newpage

\Section{Sírkőgyártó}{Sirkogyarto}

\end{document}


I am using MiKTeX 2.9 with TeXnicCenter.

-
possible duplicate of Nested macros and hyperlink problem – Marco Daniel Apr 15 '12 at 9:14
see at: (tex.stackexchange.com/questions/51770/…) – pmks Apr 16 '12 at 7:18

The following example first fixes a compatibility problem between hyperref and magyar. Both redefine \refstepcounter. Then \@currentHref is available that contains the name of the anchor used in hyperref's \refstepcounter. Then the titles of the chapters or sections do not need to be used as target or label name.

\documentclass[pdftex,a4paper,12pt,oneside]{book}%

\usepackage[latin2]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{xcolor}
\usepackage{fancyhdr}

\usepackage[magyar]{babel}
% magyar.ldf redefines \refstepcounter in \extrasmagyar
% and overwrites hyperref's definition.
% The following hacks work around this by
% restoring hyperref's definition that will
% then call magyar.ldf's version.
\begingroup
\extrasmagyar
\global\let\MagyarRefstepcounter\refstepcounter
\endgroup
\let\refstepcounter\MagyarRefstepcounter
\usepackage{hyperref}
\let\HyperrefRefstepcounter\refstepcounter
\let\refstepcounter\HyperrefRefstepcounter
}
\usepackage{bookmark}

urlcolor=red!60,citecolor=magenta,
hypertexnames=false,
unicode=true,
bookmarksnumbered=false,
pdftoolbar=true
}

\begin{document}

\pagestyle{fancy}
\fancyhf{}

% \@currentHref contains the anchor name
\makeatletter
\renewcommand{\chaptermark}[1]{%
}
\renewcommand{\sectionmark}[1]{%
}

\renewcommand{\footrulewidth}{0pt}