引用 \here \where 的问题

引用 \here \where 的问题

嗨,我在引用时遇到了问题,无法使用 MWE 重现。问题如下。如果该页位于引用之前或之后,我也需要在引用的页码旁边写上(参见上面的 P. X - 参见下面的 P. Y)。

为此我使用以下定义:

\makeatletter%
\newcount\here@undef%
\newcommand{\here}[1]{%
  \@ifundefined{here@#1@undef}{}{\advance\here@undef by -1}%
  \@namedef{here@#1}{}}%
\newcommand{\where}[1]{%
  \@ifundefined{here@#1}{%
    unten\space%
    \@ifundefined{here@#1@undef}{%
      \@namedef{here@#1@undef}{}%
      \advance\here@undef by 1%
    }{}%
  }{%
    oben%
  }%
}%
\AtEndDocument{%
  \ifnum\here@undef>0%
    \GenericWarning{}{There were undefined above/below labels}%
  \fi}%
\makeatother%

\here{x}\label{x}然后我在文本中放入:\footnote{Siehe dazu \where{x} S. \pageref{x}.}

现在,这对于大多数部分来说都可以正常工作,但是对于一些条目,它并不意味着当它低于时它会告诉它高于,或者当它高于时它会告诉它低于。

以下是一个例子:

在此处输入图片描述

页码没问题,但应该是 oben(上方)而不是 below(下方)。这种情况只发生在少数参考文献中 - 并非全部,但这仍然是一个问题,不应该发生。

我不明白为什么它会这样做。在 .aux 文件中它看起来像这样:

\@writefile{toc}{\defcounter {refsection}{0}\relax }\@writefile{toc}{\contentsline {subsubsection}{\numberline {1.2.2}Homoousianismus}{36}{subsubsection.1.2.2}}
\newlabel{hmsnsnms}{{1.2.2}{36}{Homoousianismus}{subsubsection.1.2.2}{}}
\newlabel{ZGHPAZ8A62}{{1.2.2}{36}{Homoousianismus}{subsubsection.1.2.2}{}}
\newlabel{ZGGRAAN9M3}{{1.2.2}{36}{Homoousianismus}{subsubsection.1.2.2}{}}
\newlabel{ZGF97PS312}{{1.2.2}{37}{Homoousianismus}{subsubsection.1.2.2}{}}
\newlabel{ZENP2OXA6Z}{{1.2.2}{37}{Homoousianismus}{subsubsection.1.2.2}{}}
\newlabel{ZDNOW6A981}{{1.2.2}{38}{Homoousianismus}{subsubsection.1.2.2}{}}
\newlabel{athglbkntns}{{1.2.2}{38}{Homoousianismus}{subsubsection.1.2.2}{}}
\newlabel{ZBT29MH2LW}{{1.2.2}{38}{Homoousianismus}{subsubsection.1.2.2}{}}
\newlabel{ZAPYHEWQ07}{{1.2.2}{39}{Homoousianismus}{subsubsection.1.2.2}{}}
\newlabel{ZA4HNDP59U}{{1.2.2}{39}{Homoousianismus}{subsubsection.1.2.2}{}}
\newlabel{Z546N43KIX}{{1.2.2}{39}{Homoousianismus}{subsubsection.1.2.2}{}}
\newlabel{Z50RQN9QUC}{{1.2.2}{39}{Homoousianismus}{subsubsection.1.2.2}{}}
\newlabel{Z4RSFUMEBP}{{1.2.2}{39}{Homoousianismus}{subsubsection.1.2.2}{}}
\newlabel{Z2ZXAGGBHJ}{{1.2.2}{39}{Homoousianismus}{subsubsection.1.2.2}{}}
\newlabel{doppltexath}{{2}{40}{Homoousianismus}{Item.29}{}}
\newlabel{Z0H2OLHK3K}{{1.2.2}{42}{Homoousianismus}{Item.30}{}}

有问题的参考是:

\newlabel{doppltexath}{{2}{40}{Homoousianismus}{Item.29}{}}

我明白这样做的原因是这里有{2}(第二章)而不是{1.2.2}(第一章),但我不明白他为什么要对这个条目这样做,它只是一个像其他条目一样的普通条目(没有什么特别之处)。

这是一个 MWE,但正如我提到的,我无法重现这种行为:

\documentclass[a4paper,11pt]{scrartcl}
\usepackage[latin1]{inputenc}
\usepackage{csquotes}
\usepackage{blindtext}
\usepackage{filecontents}
\usepackage{hyperref}
\hypersetup{
    colorlinks,
     citecolor=black,
     filecolor=black,
     linkcolor=black,
     urlcolor=black
}
\makeatletter%
\newcount\here@undef%
\newcommand{\here}[1]{%
  \@ifundefined{here@#1@undef}{}{\advance\here@undef by -1}%
  \@namedef{here@#1}{}}%
\newcommand{\where}[1]{%
  \@ifundefined{here@#1}{%
    unten\space%
    \@ifundefined{here@#1@undef}{%
      \@namedef{here@#1@undef}{}%
      \advance\here@undef by 1%
    }{}%
  }{%
    oben%
  }%
}%
\AtEndDocument{%
  \ifnum\here@undef>0%
    \GenericWarning{}{There were undefined above/below labels}%
  \fi}%
\makeatother%
\begin{filecontents}{\jobname.bib} 
@incollection{athanasius1857,
    Address = {Parisiis},
    Author = {{Athanasius Alexandrinus}},
    Booktitle = {S. P. N. Athanasii archiepiscopi Alexandrini opera omnia quae exstant},
    Editor = {Jacques Paul Migne},
    Keywords = {source},
    Pages = {14013-1422},
    Publisher = {Accurante J.-P. Migne},
    Series = {Patrologia Graeca},
    Shortauthor = {Ath.},
    Shorttitle = {ep. fest. 12.},
    Title = {Epistola XII heortastica},
    Volume = {26},
    Year = {1857}}
@book{athanasius1858,
    Address = {Parisiis},
    Author = {{Athanasius Alexandrinus}},
    Booktitle = {S. P. N. Athanasii archiepiscopi Alexandrini opera omnia quae exstant},
    Editor = {Jacques Paul Migne},
    Keywords = {source},
    Pages = {1403-1412},
    Publisher = {Accurante J.-P. Migne},
    Series = {Patrologia Graeca},
    Shortauthor = {Ath.},
    Shorttitle = {ep. fest. 11.},
    Title = {Epistola XI heortastica},
    Volume = {26},
    Year = {1857}}
\end{filecontents}
\usepackage[ngerman]{babel}
\usepackage[style=historische-zeitschrift, maxnames=2, hyperref=true, backref=true, backrefstyle=none, backend=bibtex,idemtracker=true]{biblatex}
\bibliography{\jobname}
%
\begin{document}
\blindtext\footnote{Siehe dazu \where{x} S. \pageref{x}ff.}
\pagebreak
\blindtext\here{x}\label{x}
\pagebreak
\blindtext\footnote{Siehe dazu \where{x} S. \pageref{x}ff.}
\pagebreak
\printbibliography

\end{document}

此外,我认为这非常重要,这只发生在有参考文献的情况下Cf. below,而不是有Cf. above参考文献的情况下!

如果有人想看一下,我还在这里上传了我的 .tex 和 .aux 文件:

https://dl.dropboxusercontent.com/u/17374757/Inhalt.tex https://dl.dropboxusercontent.com/u/17374757/struktur.aux

感谢您的帮助!

答案1

\here如果我将其封闭在一个环境中,我可以重现该问题:

\begin{quotation}
\blindtext\here{x}\label{x}
\end{quotation}

然后第二个\where会说“unten”而不是“oben”。问题是\@namedef\advance在本地执行,因此它们的操作在环境结束时被撤消。

在和\global前面使用。此外,在常量后面省略。\@namedef\advance%

\documentclass[a4paper,11pt]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage{csquotes}
\usepackage{blindtext}
\usepackage{filecontents}
\usepackage{hyperref}
\hypersetup{
    colorlinks,
     citecolor=black,
     filecolor=black,
     linkcolor=black,
     urlcolor=black
}

\makeatletter
\newcount\here@undef
\newcommand{\here}[1]{%
  \@ifundefined{here@#1@undef}{}{\global\advance\here@undef by -1}%
  \global\@namedef{here@#1}{}%
}
\newcommand{\where}[1]{%
  \@ifundefined{here@#1}{%
    unten%
    \@ifundefined{here@#1@undef}{%
      \global\@namedef{here@#1@undef}{}%
      \global\advance\here@undef by 1
    }{}%
  }{%
    oben%
  }%
}
\AtEndDocument{%
  \ifnum\here@undef>0
    \GenericWarning{}{There were undefined above/below labels}%
  \fi}
\makeatother

\begin{filecontents}{\jobname.bib} 
@incollection{athanasius1857,
    Address = {Parisiis},
    Author = {{Athanasius Alexandrinus}},
    Booktitle = {S. P. N. Athanasii archiepiscopi Alexandrini opera omnia quae exstant},
    Editor = {Jacques Paul Migne},
    Keywords = {source},
    Pages = {14013-1422},
    Publisher = {Accurante J.-P. Migne},
    Series = {Patrologia Graeca},
    Shortauthor = {Ath.},
    Shorttitle = {ep. fest. 12.},
    Title = {Epistola XII heortastica},
    Volume = {26},
    Year = {1857}}
@book{athanasius1858,
    Address = {Parisiis},
    Author = {{Athanasius Alexandrinus}},
    Booktitle = {S. P. N. Athanasii archiepiscopi Alexandrini opera omnia quae exstant},
    Editor = {Jacques Paul Migne},
    Keywords = {source},
    Pages = {1403-1412},
    Publisher = {Accurante J.-P. Migne},
    Series = {Patrologia Graeca},
    Shortauthor = {Ath.},
    Shorttitle = {ep. fest. 11.},
    Title = {Epistola XI heortastica},
    Volume = {26},
    Year = {1857}}
\end{filecontents}
\usepackage[ngerman]{babel}
\usepackage[style=historische-zeitschrift, maxnames=2, hyperref=true, backref=true, backrefstyle=none, backend=bibtex,idemtracker=true]{biblatex}

\bibliography{\jobname}

\begin{document}
\blindtext\footnote{Siehe dazu \where{x} S. \pageref{x}ff.}
\pagebreak
\begin{quotation}
\blindtext\here{x}\label{x}
\end{quotation}
\pagebreak
\blindtext\footnote{Siehe dazu \where{x} S. \pageref{x}ff.}
\pagebreak
\printbibliography

\end{document}

这将打印

请参见 S. 2ff。

在第 1 页和

请参阅此处 S. 2ff。

在第 3 页。

相关内容