![Hyperref из глоссария ведет на неправильную страницу после использования /setcounter](https://rvso.com/image/420748/Hyperref%20%D0%B8%D0%B7%20%D0%B3%D0%BB%D0%BE%D1%81%D1%81%D0%B0%D1%80%D0%B8%D1%8F%20%D0%B2%D0%B5%D0%B4%D0%B5%D1%82%20%D0%BD%D0%B0%20%D0%BD%D0%B5%D0%BF%D1%80%D0%B0%D0%B2%D0%B8%D0%BB%D1%8C%D0%BD%D1%83%D1%8E%20%D1%81%D1%82%D1%80%D0%B0%D0%BD%D0%B8%D1%86%D1%83%20%D0%BF%D0%BE%D1%81%D0%BB%D0%B5%20%D0%B8%D1%81%D0%BF%D0%BE%D0%BB%D1%8C%D0%B7%D0%BE%D0%B2%D0%B0%D0%BD%D0%B8%D1%8F%20%2Fsetcounter.png)
У меня есть документ с кодом, который я добавил ниже. Первые две страницы документа — титульный лист и страница с оглавлением. Эти две страницы не должны учитываться, потому что само содержание начинается на третьей странице. Из-за этого третья страница должна иметь номер 1. Чтобы сделать это, я добавил \setcounter{page}{1} в свой стиль страницы "Content". После того, как я это сделал, номер страницы в моем глоссарии также изменился на 1, как и должно быть. Когда я нажимаю на эту 1, чтобы попасть на страницу, где написано слово, которое описано в моем глоссарии, hyperref ведет меня на титульный лист, как на первую страницу документа. Это неправильно, потому что он должен вести меня на третью страницу документа, которая пронумерована страницей номер 1. Есть ли способ решить эту проблему?
Вот код моего документа:
\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}
решение1
Используйте другую систему нумерации для первых страниц (страниц со скрытыми номерами страниц).
\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}
Дополнительное замечание: Не изменяйте значение счетчика страниц в настройках стиля страницы Content
.