0

I have a relatively complicated reference system due to the fact that I have to produce three volumes and cross-reference them. So far everything is working well except one minor thing:

After I reference a page I have space after page number and before dot like this:

Vgl. S. 4 .

It should be:

Vgl. S. 4.

I could solve this by adding a dot in the command, which I can't do because sometimes I have place where I should write:

Vgl. S. 4, 12, 15.

Adding a dot inside that command would produce:

Vgl. S. 4., 12., 15..

So I need to find a way for Latex to stop adding empty space after the page number.

Here is my MWE.

\documentclass[twoside]{scrbook}
\usepackage[]{scrlayer-scrpage}
\usepackage{lipsum}
\usepackage{hyperref}
\hypersetup{%
    colorlinks,%
    citecolor=black,%
    filecolor=black,%
    linkcolor=black,%
    urlcolor=black,%
    hypertexnames=false%
}%
\usepackage[counter,user,hyperref]{zref}
\makeatletter
\AtBeginDocument{%
\@ifpackageloaded{hyperref}{%
}{
  \providecommand{\phantomsection}{}
  \providecommand{\hyperlink}[2]{#2}
}

\zref@newlist{partpage}
\zref@newprop*{partprop}[-1]{\number\value{part}}
\zref@addprops{partpage}{partprop,page,anchor}

%\newcounter{herecntr}

\newcommand{\here}[1]{%
  \phantomsection% Needed for correct hyper links
  \zref@labelbyprops{#1}{partprop,page,anchor}%
}

\newcommand{\crossref}[1]{%
  \ifnum\value{part}=\zref@extract{#1}{partprop}\relax% Check whether the current part counter value is the same as the extracted part property from the label
  S. \hyperlink{\zref@extract{#1}{anchor}}{\zpageref{#1}}
  \else% No, it is not the same!
  Booktitle, Bd. \zref[partprop]{#1}, S. \hyperlink{\zref@extract{#1}{anchor}}{\zpageref{#1}}%
  \fi
}
}
\makeatother
\clearpairofpagestyles
\lehead{}
\cehead{Chapter\space\leftmark}
\lehead{\pagemark}
\lohead{}
\cohead{\rightmark}
\rohead{\pagemark}
\lefoot{}
\cfoot{}
\begin{document}
\chapter{CHTITLE}
\lipsum[1-20]\here{test}\label{test}
\section{STITLE}
\lipsum[21-40]\footnote{Vgl. \crossref{test}.}
\end{document}
stx932
  • 950

1 Answers1

4

You have unwanted whitespace after the page number in your code. You can fix that by commenting out the line break in the definition of \crossref:

\newcommand{\crossref}[1]{%
  \ifnum\value{part}=\zref@extract{#1}{partprop}\relax% Check whether the current part counter value is the same as the extracted part property from the label
  S. \hyperlink{\zref@extract{#1}{anchor}}{\zpageref{#1}}% <-- HERE
  \else% No, it is not the same!
  Booktitle, Bd. \zref[partprop]{#1}, S. \hyperlink{\zref@extract{#1}{anchor}}{\zpageref{#1}}%
  \fi
}
stx932
  • 950
DG'
  • 21,727