将数字推到句子末尾 - 使用 biblatex 进行 ieee 引用

将数字推到句子末尾 - 使用 biblatex 进行 ieee 引用

我有一个关于改善文本引用流程的问题。

当用作\textcite{Hunt}句子的一部分时,它将被排版为

Hunt [4] 证明这一方法可行。

我想知道是否有任何方法可以将参考显示为:

Hunt 证明这一方法可行 [4]。

我知道这可以手动使用

\citeauthor{Hunt} showed that this works \cite{Hunt}

但我希望存在某种“智能”方法。我不知道这是否可行,但还是要提前感谢。

这应该可以作为 MWE 来实现这一点:

\documentclass{article}

\usepackage[style=numeric]{biblatex}
\usepackage{filecontents}

\begin{filecontents}{myreferences.bib}
@misc{Hunt,year = {2012},author= {Hunt}}
\end{filecontents}

\addbibresource{myreferences.bib}
\begin{document}

\textcite{Hunt} showed that this works. 

\citeauthor{Hunt} showed that this works \cite{Hunt}.

\printbibliography
\end{document}

答案1

这里的棘手之处在于,\textciteLaTeX 确切地知道将输出放在哪里,但在类似

\Pushcite{sigfridsson} showed some very interesting things.

您必须依靠biblatex找出句子的结束位置以及引用的位置。

如果你愿意使用额外的标记来帮助biblatex,你可以使用以下内容

\documentclass[british]{article}
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage{csquotes}

\usepackage[backend=biber, style=numeric]{biblatex}

\makeatletter
\newtoggle{cbx@pushcite}

\DeclareCiteCommand{\pushcite}
  {\ifundef\cbx@puhscite@savedcites
     {\gdef\cbx@puhscite@savedcites{\autocites}}
     {}%
   \gdef\cbx@pushcite@savedkeys{}%
   \boolfalse{citetracker}%
   \boolfalse{pagetracker}}
  {\ifthenelse{\iffirstcitekey\AND\value{multicitetotal}>0}
     {\protected@xappto\cbx@puhscite@savedcites{()(\thefield{multipostnote})}%
      \global\clearfield{multipostnote}}
     {}%
   \xappto\cbx@pushcite@savedkeys{\thefield{entrykey},}%
   \ifciteindex
     {\indexnames{labelname}}
     {}%
   \printnames{labelname}}
  {\multicitedelim}
  {\protected@xappto\cbx@puhscite@savedcites{%
     [\thefield{prenote}][\thefield{postnote}]{\cbx@pushcite@savedkeys}}%
   \global\toggletrue{cbx@pushcite}}

\newrobustcmd*{\Pushcite}{\bibsentence\pushcite}

\newcommand*{\releasecite}{%
  \global\togglefalse{cbx@pushcite}%
  \ifundef\cbx@puhscite@savedcites
    {}
    {\cbx@puhscite@savedcites}%
  \gundef\cbx@puhscite@savedcites}
\makeatother

\addbibresource{biblatex-examples.bib}

\begin{document}
\Pushcite{sigfridsson} showed that many things happen in chemistry \releasecite.

\Pushcite{worman} showed E.~coli likes sun \releasecite.

\printbibliography
\end{document}

但这只是比显而易见的

\Citeauthor{sigfridsson} showed many things \cite{sigfridsson}.

如果您不想添加额外的标记,那么唯一可以指导我们在哪里释放引用的就是句子末尾的句号。可以将其设置为活动字符,这意味着它可以像宏一样运行。这可以帮助我们\releasecite在每个句子末尾自动发出。

\documentclass[british]{article}
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage{csquotes}

\usepackage[backend=biber, style=numeric]{biblatex}

\makeatletter
\newtoggle{cbx@pushcite}

\DeclareCiteCommand{\pushcite}
  {\ifundef\cbx@puhscite@savedcites
     {\gdef\cbx@puhscite@savedcites{\autocites}}
     {}%
   \gdef\cbx@pushcite@savedkeys{}%
   \boolfalse{citetracker}%
   \boolfalse{pagetracker}}
  {\ifthenelse{\iffirstcitekey\AND\value{multicitetotal}>0}
     {\protected@xappto\cbx@puhscite@savedcites{()(\thefield{multipostnote})}%
      \global\clearfield{multipostnote}}
     {}%
   \xappto\cbx@pushcite@savedkeys{\thefield{entrykey},}%
   \ifciteindex
     {\indexnames{labelname}}
     {}%
   \printnames{labelname}}
  {\multicitedelim}
  {\protected@xappto\cbx@puhscite@savedcites{%
     [\thefield{prenote}][\thefield{postnote}]{\cbx@pushcite@savedkeys}}%
   \global\toggletrue{cbx@pushcite}}

\newrobustcmd*{\Pushcite}{\bibsentence\pushcite}

\newcommand*{\releasecite}{%
  \global\togglefalse{cbx@pushcite}%
  \ifundef\cbx@puhscite@savedcites
    {}
    {\cbx@puhscite@savedcites}%
  \gundef\cbx@puhscite@savedcites}

\begingroup
\catcode`\.=\active
\gdef\mkperiodreleasecite{%
  \catcode`\.=\active
  \def.{%
    \ifnum\spacefactor=1000
      \space\releasecite
    \fi
    \origdot}%
}
\endgroup

\AfterEndPreamble{%
  \let\origdot=.
  \mkperiodreleasecite}
\makeatother

\addbibresource{biblatex-examples.bib}

\begin{document}
\Pushcite{sigfridsson} showed that many things happen in chemistry.

\Pushcite{worman} showed E.~coli likes sun.

\printbibliography
\end{document}

虽然此方法在此示例中有效,但有几个缺点。

  • 激活字符可能意味着这些字符在不同上下文中无法正常工作。(在示例中,一切似乎都正常,但在更一般的文档中,我预计会出现错误或奇怪的副作用。)
  • 我们可能无法正确识别句子的结尾。在这里,我们使用了空间因素来避免将缩写点分类为句号,但这只能在一定程度上起作用。例如,代码将无法正确工作Dr.~Smith

考虑到所有这些,我可能会坚持引用

\Textcite{sigfridsson} showed that there is a lot to this.

\Citeauthor{sigfridsson} could prove the converse \cite{sigfridsson}

或者,如果你想避免重复,并能忍受稍微尴尬的标记

\documentclass[british]{article}
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage{csquotes}

\usepackage[backend=biber, style=numeric]{biblatex}

\addbibresource{biblatex-examples.bib}

\makeatletter
\newcommand*{\defertextcite}{}
\newcommand*{\defertextcite@i}{}
\def\defertextcite#1#{\defertextcite@i{#1}}
\def\defertextcite@i#1#2#3{\citeauthor{#2} #3 \autocite#1{#2}}

\newcommand*{\Defertextcite}{\defertextcite}
\makeatother

\begin{document}
\Defertextcite[380]{sigfridsson}{showed several great results}.

\printbibliography
\end{document}

相关内容