Hyperref de um glossário leva à página errada após usar/setcounter

Hyperref de um glossário leva à página errada após usar/setcounter

Tenho um documento com o código, que adicionei abaixo. As duas primeiras páginas do documento são a página de título e a página com o índice. Essas duas páginas não devem ser contabilizadas, pois o próprio conteúdo começa na terceira página. Por isso, a terceira página deveria ter o número 1. Para fazer isso, adicionei \setcounter{page}{1} ao meu estilo de página "Conteúdo". Depois de fazer isso, o número da página do meu glossário também mudou para 1, como deveria. Quando clico naquele 1 para chegar à página onde está escrita a palavra descrita no meu glossário, o hiperref me leva à página de título, como a primeira página do documento. Isso está errado, pois deveria me levar à terceira página do documento, que está numerada com o número 1. Existe alguma maneira de resolver esse problema?

Este é o código do meu documento:

\documentclass{article}

\usepackage[headsepline,footsepline]{scrlayer-scrpage}
\usepackage{graphicx,xcolor}
\usepackage[margin=38mm,includeheadfoot]{geometry}
\usepackage{setspace, fontspec, hyperref}
\usepackage[acronym]{glossaries}    
\pagenumbering{arabic}

\DeclareNewLayer[
    background,
    topmargin,
    mode=picture,
    contents={\includegraphics[height=\layerheight,width=\layerwidth]{Picture1.png}}
]{top}

\DeclareNewLayer[
    background,
    bottommargin,
    mode=picture,
    contents={\includegraphics[height=\layerheight,width=\layerwidth]{Picture2.png}}
]{bottom}

\defpairofpagestyles{Titlepage}{}

\AddLayersToPageStyle{Titlepage}{top,bottom}

\newpairofpagestyles[scrheadings]{Tableofcontents}
{
    \clearscrheadfoot
    \ihead{Author}
    \chead{Title}
    \ohead{\includegraphics{Logo.png}}
}

\newpairofpagestyles[scrheadings]{Content}
{
    \clearscrheadfoot
    \setcounter{page}{1}
    \ihead{Author}
    \chead{Title}
    \ohead{\includegraphics{Logo.png}}
    \cfoot{Page \pagemark}
}

\makeglossaries
\newglossaryentry{Test}
{
    name=Test,
    description={Test}
}

\begin{document}
    \begin{titlepage}
      \KOMAoption{headsepline}{false}
      \KOMAoption{footsepline}{false}
      \begin{center}
        \thispagestyle{Titlepage}        
        Titlepage
      \end{center}
    \end{titlepage}

    \thispagestyle{Tableofcontents}
    \tableofcontents
    \clearpage
    
    \thispagestyle{Content}
    This is a \gls{Test}

    \printglossary
 \end{document}

Responder1

Use um sistema de numeração diferente para as primeiras páginas (páginas com números de página ocultos).

\documentclass{article}
\usepackage[headsepline,footsepline]{scrlayer-scrpage}
\usepackage{graphicx}
%\usepackage{xcolor}% not used in the example
\usepackage[margin=38mm,includeheadfoot]{geometry}
%\usepackage{setspace}% not used in the example
\usepackage{fontspec}
\usepackage{hyperref}
\usepackage[acronym]{glossaries}

\DeclareNewLayer[
    background,
    topmargin,
    mode=picture,
    contents={\putLL{\includegraphics[height=\layerheight,width=\layerwidth]{example-image-a}}}
]{top}

\DeclareNewLayer[
  background,
  bottommargin,
  mode=picture,
  contents={\putLL{\includegraphics[height=\layerheight,width=\layerwidth]{example-image-b}}}
]{bottom}

\DeclarePageStyleByLayers{Titlepage}{top,bottom}

\newpairofpagestyles[scrheadings]{Tableofcontents}
{
  \clearpairofpagestyles% <- replace outdated command
  \ihead{Author}
  \chead{Title}
  \ohead{\smash{\includegraphics[height=1cm]{example-image}}}% use \smash to hide the height of the image
}

\newpairofpagestyles[scrheadings]{Content}
{
  \clearpairofpagestyles% <- replace outdated command
  \ihead{Author}
  \chead{Title}
  \ohead{\smash{\includegraphics[height=1cm]{example-image}}}% use \smash to hide the height of the image
  \cfoot{\pagemark}
}
\renewcommand*{\pagemark}{{\usekomafont{pagenumber}Page~\thepage}}

\newcommand*{\Content}{%
  \cleardoublepage
  \pagenumbering{arabic}% resets the page number to 1
  \pagestyle{Content}%
}

\makeglossaries
\newglossaryentry{Test}
{
  name=Test,
  description={Test}
}

\begin{document}
\pagenumbering{roman}
\begin{titlepage}
  \thispagestyle{Titlepage}
  \begin{center}
    Titlepage
  \end{center}
\end{titlepage}

\pagestyle{Tableofcontents}
\tableofcontents

\Content
This is a \gls{Test}
\printglossary
\end{document}

Observação adicional: Não altere o valor do contador de páginas nas configurações de estilo de página Content.

informação relacionada