[Tex/LaTex] How to structure the table of contents with arabic and roman numbers

linksnumberingtable of contents

What I want to achieve is, that the first few sections and included page numbers of my document should be in roman and the rest of the document in arabic numbers.

Like this:

I ….

II ….

1 ….

2 ….

3 ….

Now this works fine, the page numbers and sections are numbered as I want them to. But I have the following problem: if I click the first section of my "arabic section" in the table of contents it jumps to the first "roman section". This happens for the amount of "roman sections". If I click on the third "arabic section" it's fine.

I just want a jump to the right section, if I click it in the table of contents.

This is what I have:

 \documentclass[12pt, a4paper, ngerman, oneside, bibtotoc, liststotoc, bibtotocnumbered, toctotoc]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\newcommand{\sectionnumbering}[1]{% 
  \setcounter{section}{0}% 
    \renewcommand{\thesection}{\csname #1\endcsname{section}}}

\begin{document}
    \section{Deckblatt}
    ...

    \pagenumbering{roman} 
    \sectionnumbering{Roman}
    \pagestyle{empty}

    \section{Erklaerung}

    \section{Sperrvermerk}  

    \tableofcontents
    \newpage
    \listoffigures
    \clearpage

    \pagenumbering{arabic} 
    \sectionnumbering{arabic}

    \pagestyle{fancy}
    \renewcommand{\sectionmark}[1]{\markright{\thesection{} #1}{}}

    \section{KapitelEinleitung}
    \section{...}
\end{document}

I tried some suggested solutions using \newcounter{} and \setcounter{}{}, but with no success.

Best Answer

The cause of this behaviour as described by the OP is the resetting of section counters, thus confusing hyperref. Using hypertexnames=false as an option to hyperref will generate unique page anchor link names.

 \documentclass[12pt, a4paper, ngerman, oneside, bibtotoc, liststotoc, bibtotocnumbered, toctotoc]{scrartcl}
\usepackage{fancyhdr}
\usepackage[utf8x]{inputenc}
\usepackage[ngerman]{babel}
\usepackage[unicode,hypertexnames=false]{hyperref}
\usepackage{bookmark}
\PrerenderUnicode{ä}


\pagestyle{fancy}
\fancyhf{}
\newcommand{\sectionnumbering}[1]{% 
  \setcounter{section}{0}% 
  \renewcommand{\thesection}{\csname #1\endcsname{section}}%
}%

\begin{document}
\section{Deckblatt}

\pagenumbering{roman} 
\sectionnumbering{Roman}
\pagestyle{empty}
\section{Erklärung}
\section{Sperrvermerk}  
\clearpage
\tableofcontents
\newpage
\listoffigures
\clearpage

\pagenumbering{arabic} 
\sectionnumbering{arabic}

\pagestyle{fancy}
\renewcommand{\sectionmark}[1]{\markright{\thesection{} #1}{}}
\section{KapitelEinleitung}
\section{...}
\end{document}