如何使用页面站点进行方程式内的引用

如何使用页面站点进行方程式内的引用

我有一个问题。我想引用我的公式并附上来源。我遇到了以下问题,只要我有页码,就会出现错误。我该如何解决这个问题,以便我也可以在引用中输入页码?我在这里找到了解决方案https://tex.stackexchange.com/a/251979/263023

\documentclass[12pt]{report}
\usepackage[usegeometry]{typearea}% load before geometry
\usepackage[a4paper, left={2.5cm}, right={2cm}, top={3cm}, bottom={3cm}, headheight=15pt]{geometry}
\usepackage{filecontents}
\usepackage[ngerman]{babel}

\begin{filecontents*}{\jobname.bib}
@article{einstein,
  author  = {Albert Einstein},
  title   = {{Zur Elektrodynamik bewegter Körper}. ({German}) 
             [{On} the electrodynamics of moving bodies]},
  journal = {Annalen der Physik},
  volume  = {322},
  number  = {10},
  pages   = {891--921},
  year    = {1905},
  DOI     = {http://dx.doi.org/10.1002/andp.19053221004}, 
}
@online{ApoG,
  Address = {03.08.2013},
  Edition = {15.10.1980},
  Publisher = {juris GmbH},
  Title = {ApoG - Gesetz {\"u}ber das Apothekenwesen},
  Url = {www.juris.de/purl/gesetze/_ges/ApoG},
  Year = {1980},
}
\end{filecontents*}

\usepackage[%
backend=bibtex      % biber or bibtex
%,style=authoryear    % Alphabeticalsch
,style=numeric-comp  % numerical-compressed
,sorting=none        % no sorting
,sortcites=true      % some other example options ...
,block=none
,indexing=false
,citereset=none
,isbn=true
,url=true
,doi=true            % prints doi
,natbib=true         % if you need natbib functions
]{biblatex}
\DefineBibliographyStrings{ngerman}{%
    urlseen = {aufgerufen am}
}
\addbibresource{\jobname.bib}



\usepackage{float} 



% ------------ NEW
\makeatletter
\newcommand*{\eqcite}[1]{%
    \def\@eqcite{\org@cite{#1}}%
}
\let\@eqcite\@empty
\def\@eqnnum{%
    {%
        \normalfont
        \normalcolor
        \ifx\@eqcite\@empty
        \else
        \@eqcite\space
        \fi
        (\theequation)%
    }%
}
\g@addto@macro\equation{%
    \let\org@cite\cite
    \let\cite\eqcite
}
\let\org@cite\cite
\makeatother


% --------------- NEW END

\usepackage[ngerman]{cleveref}
\crefname{equation}{Formel}{Formel}
\creflabelformat{equation}{#2\textup{#1}#3}



\begin{document}
The famous inequality math relation:
\begin{equation}
\label{eq:test}
\cite{einstein}
  y \neq x 
\end{equation}


New formula

\begin{equation}
    \cite[S.~235]{einstein}
    y \neq x 
\end{equation}


\cref{eq:test}
\printbibliography
\end{document}

在此处输入图片描述

我想要的是 在此处输入图片描述

答案1

所示的定义\eqcite(因此\cite在方程式中也是如此)仅接受一个强制参数。这意味着它不支持biblatex通常的两个可选参数。

通过以下定义,\NewDocumentCommand我们可以恢复通常的行为。(我稍微修剪了一下示例,以便我们可以专注于代码的重要部分。)

\documentclass[12pt]{report}
\usepackage[ngerman]{babel}

\usepackage{biblatex}

\addbibresource{biblatex-examples.bib}

\makeatletter
\NewDocumentCommand\eqcite{oom}{%
  \def\@eqcite{\org@cite}%
  \IfNoValueF{#1}
    {\appto\@eqcite{[#1]}%
     \IfNoValueF{#2}
       {\appto\@eqcite{[#2]}}}%
  \appto\@eqcite{{#3}}}

\let\@eqcite\@empty
\def\@eqnnum{%
  {%
    \normalfont
    \normalcolor
    \ifx\@eqcite\@empty
    \else
      \@eqcite\space
    \fi
    (\theequation)%
  }%
}
\g@addto@macro\equation{%
  \DeclareCommandCopy\org@cite\cite
  \DeclareCommandCopy\cite\eqcite
}
\DeclareCommandCopy\org@cite\cite
\makeatother

\usepackage[ngerman]{cleveref}
\crefname{equation}{Formel}{Formel}
\creflabelformat{equation}{#2\textup{#1}#3}

\begin{document}
The famous inequality math relation:
\begin{equation}
  \label{eq:test}
  \cite{sigfridsson}
  y \neq x 
\end{equation}


New formula

\begin{equation}
  \cite[235]{sigfridsson}
  y \neq x 
\end{equation}

\begin{equation}
  \cite[cf.][235]{sigfridsson}
  y \neq x 
\end{equation}

\begin{equation}
  \cite[cf.][]{sigfridsson}
  y \neq x 
\end{equation}


\cref{eq:test}
\printbibliography
\end{document}

方程式中带有前后注的工作引用。

相关内容