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}
\hypersetup{colorlinks, linkcolor=blue!80,filecolor=Orange,urlcolor=red!60,citecolor=magenta,
linktoc=all,
hypertexnames=false,
unicode=true,
bookmarksnumbered=false,
pdfmenubar=true,%
pdftoolbar=true
}
\newcommand{\chapterlinkname}{}
\newcommand{\setchapterlinkname}[1]{\renewcommand{\chapterlinkname}{#1}}
\newcommand{\chapterlink}[1]{\setchapterlinkname{lnk:chap#1}\hypertarget{\chapterlinkname}{}}
\newcommand{\Chapter}[2]{\newpage\chapterlink{#2} \chapter{#1}}
\newcommand{\sectionlinkname}{}
\newcommand{\setsectionlinkname}[1]{\renewcommand{\sectionlinkname}{#1}}
\newcommand{\sectionlink}[1]{\setsectionlinkname{\chapterlinkname:sec#1}\hypertarget{\sectionlinkname}{}}
\newcommand{\Section}[2]{\sectionlink{#2}\section{#1}}
\newcommand{\seclink}{}
\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{\sectionmark}[1]{\markright{\sectionlinkname,##1}}
\fancyhead[LO,RE]{\mystrsplit{\rightmark}{,}{\seclink}{\secname} \hyperlink{\chapterlinkname}{\bfseries\leftmark} : \hyperlink{\seclink}{\bfseries\secname}}
\fancyhead[LE,RO]{\bfseries\thepage}
\renewcommand{\headrulewidth}{0.5pt}
\renewcommand{\footrulewidth}{0pt}
\addtolength{\headheight}{2.5pt}
\fancypagestyle{plain}{\fancyhead{}\renewcommand{\headrulewidth}{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.