包标题不兼容:biblatex citecounter 对表格标题内的引用进行双重计数

包标题不兼容:biblatex citecounter 对表格标题内的引用进行双重计数

可以使用biblatex包来计算文档正文中使用引文的次数。这可以通过添加citecounter=true包选项来启用。即使使用此选项,默认情况下也会禁用浮点数内的引用计数,但它们也可以重新启用,因为回答经过莫威Biblatex citecounter 不计算图片标题中的参考文献显示。下面的 MWE 采用了这种修改。

caption我还需要使用不幸篡改上述解决方案的软件包。现在,表格标题中的每个引用都是重复计算对于下面的 MWE,它显示了四个引用实例,而不是明显的两个。

我该如何解决这个问题?(可以对 MWE 进行简单的算术运算,但在我的实际文档中不可行)。

还有一些挥之不去的警告,例如

LaTeX Warning: There were undefined references.
Package biblatex Warning: Please (re)run Biber on the file:
(biblatex)                VeaOtsing
(biblatex)                and rerun LaTeX afterwards.

caption但无论是否存在这些似乎都存在,奇怪......


平均能量损失

\documentclass{book}

\usepackage[date=year, style=alphabetic, backref=true, citecounter=true]{biblatex}
\addbibresource{referencesTest.bib} % file with references

%%Making sure citations in table captions are also counted. Based on moewe's answer.
\makeatletter
\AtBeginDocument{%
        \patchcmd\@floatboxreset
        {\boolfalse{citetracker}%
                \boolfalse{pagetracker}}
        {}
        {}
        {\blx@err@patch{float}}}
\makeatother

%% Adding the auxiliary line after bibliography entry 
\renewbibmacro*{pageref}{%
    \addperiod%
    \iflistundef{pageref}%
    {}{\newline\scriptsize\printtext[brackets]{%
            \ifnumgreater{\value{pageref}}{1}%
            {\bibstring{backrefpages}\ppspace}%
            {\bibstring{backrefpage}\ppspace}%
            \printlist[pageref][-\value{listtotal}]{pageref}, total \arabic{citecounter} times\addperiod}}\nopunct}

\usepackage{caption} % now references in table captions are double-counted

\begin{document}

\begin{table}[!htbp]
    \caption{{Sample-1 table, \cite[21]{example_reference_2023}}}
\end{table}

\begin{table}[!htbp]
    \caption{{Sample-2 table, \cite[2]{example_reference_2023}}}
\end{table}

\printbibliography
    
\end{document}

referencesTest.bib

@book{example_reference_2023,
    location = {FakeCity},
    title = {Made-up Title},
    publisher = {Nowhere and noone},
    author = {Mr Smith},
    date = {2023},
}
  • 书目输出包裹caption存在(共计 4 次,而不是 2 次):

输出带标题的参考书目

  • 书目输出没有包裹caption存在(共计2次,准确率较高):

输出不带标题的参考书目

日志文件(caption存在时;用户名已更改):

This is pdfTeX, Version 3.141592653-2.6-1.40.25 (MiKTeX 23.5) (preloaded format=pdflatex 2023.8.29)  18 SEP 2023 23:37
entering extended mode
 restricted \write18 enabled.
 %&-line parsing enabled.
**./CountingReferencesTest.tex
(CountingReferencesTest.tex
LaTeX2e <2023-06-01> patch level 1
L3 programming layer <2023-08-11>
(C:\Users\UserNameChanged\MikTeX\tex/latex/base\book.cls
Document Class: book 2023/05/17 v1.4n Standard LaTeX document class
(C:\Users\UserNameChanged\MikTeX\tex/latex/base\bk10.clo
File: bk10.clo 2023/05/17 v1.4n Standard LaTeX file (size option)
)
\c@part=\count185
\c@chapter=\count186
\c@section=\count187
\c@subsection=\count188
\c@subsubsection=\count189
\c@paragraph=\count190
\c@subparagraph=\count191
\c@figure=\count192
\c@table=\count193
\abovecaptionskip=\skip48
\belowcaptionskip=\skip49
\bibindent=\dimen140
)
(C:\Users\UserNameChanged\MikTeX\tex/latex/biblatex\biblatex.sty
Package: biblatex 2023/03/05 v3.19 programmable bibliographies (PK/MW)

(C:\Users\UserNameChanged\MikTeX\tex/generic/pdftexcmds\pdftexcmds.sty
Package: pdftexcmds 2020-06-27 v0.33 Utility functions of pdfTeX for LuaTeX (HO
)

(C:\Users\UserNameChanged\MikTeX\tex/generic/infwarerr\infwarerr.sty
Package: infwarerr 2019/12/03 v1.5 Providing info/warning/error messages (HO)
)
(C:\Users\UserNameChanged\MikTeX\tex/generic/iftex\iftex.sty
Package: iftex 2022/02/03 v1.0f TeX engine tests
)
(C:\Users\UserNameChanged\MikTeX\tex/generic/ltxcmds\ltxcmds.sty
Package: ltxcmds 2020-05-10 v1.25 LaTeX kernel commands for general use (HO)
)
Package pdftexcmds Info: \pdf@primitive is available.
Package pdftexcmds Info: \pdf@ifprimitive is available.
Package pdftexcmds Info: \pdfdraftmode found.
)
(C:\Users\UserNameChanged\MikTeX\tex/latex/etoolbox\etoolbox.sty
Package: etoolbox 2020/10/05 v2.5k e-TeX tools for LaTeX (JAW)
\etb@tempcnta=\count194
)
(C:\Users\UserNameChanged\MikTeX\tex/latex/graphics\keyval.sty
Package: keyval 2022/05/29 v1.15 key=value parser (DPC)
\KV@toks@=\toks17
)
(C:\Users\UserNameChanged\MikTeX\tex/latex/kvoptions\kvoptions.sty
Package: kvoptions 2022-06-15 v3.15 Key value format for package options (HO)

(C:\Users\UserNameChanged\MikTeX\tex/latex/kvsetkeys\kvsetkeys.sty
Package: kvsetkeys 2022-10-05 v1.19 Key value parser (HO)
))
(C:\Users\UserNameChanged\MikTeX\tex/latex/logreq\logreq.sty
Package: logreq 2010/08/04 v1.0 xml request logger
\lrq@indent=\count195

(C:\Users\UserNameChanged\MikTeX\tex/latex/logreq\logreq.def
File: logreq.def 2010/08/04 v1.0 logreq spec v1.0
))
(C:\Users\UserNameChanged\MikTeX\tex/latex/base\ifthen.sty
Package: ifthen 2022/04/13 v1.1d Standard LaTeX ifthen package (DPC)
)
(C:\Users\UserNameChanged\MikTeX\tex/latex/url\url.sty
\Urlmuskip=\muskip16
Package: url 2013/09/16  ver 3.4  Verb mode for urls, etc.
)
\c@tabx@nest=\count196
\c@listtotal=\count197
\c@listcount=\count198
\c@liststart=\count199
\c@liststop=\count266
\c@citecount=\count267
\c@citetotal=\count268
\c@multicitecount=\count269
\c@multicitetotal=\count270
\c@instcount=\count271
\c@maxnames=\count272
\c@minnames=\count273
\c@maxitems=\count274
\c@minitems=\count275
\c@citecounter=\count276
\c@maxcitecounter=\count277
\c@savedcitecounter=\count278
\c@uniquelist=\count279
\c@uniquename=\count280
\c@refsection=\count281
\c@refsegment=\count282
\c@maxextratitle=\count283
\c@maxextratitleyear=\count284
\c@maxextraname=\count285
\c@maxextradate=\count286
\c@maxextraalpha=\count287
\c@abbrvpenalty=\count288
\c@highnamepenalty=\count289
\c@lownamepenalty=\count290
\c@maxparens=\count291
\c@parenlevel=\count292
\blx@tempcnta=\count293
\blx@tempcntb=\count294
\blx@tempcntc=\count295
\c@blx@maxsection=\count296
\blx@maxsegment@0=\count297
\blx@notetype=\count298
\blx@parenlevel@text=\count299
\blx@parenlevel@foot=\count300
\blx@sectionciteorder@0=\count301
\blx@sectionciteorderinternal@0=\count302
\blx@entrysetcounter=\count303
\blx@biblioinstance=\count304
\labelnumberwidth=\skip50
\labelalphawidth=\skip51
\biblabelsep=\skip52
\bibitemsep=\skip53
\bibnamesep=\skip54
\bibinitsep=\skip55
\bibparsep=\skip56
\bibhang=\skip57
\blx@bcfin=\read2
\blx@bcfout=\write3
\blx@langwohyphens=\language84
\c@mincomprange=\count305
\c@maxcomprange=\count306
\c@mincompwidth=\count307
Package biblatex Info: Trying to load biblatex default data model...
Package biblatex Info: ... file 'blx-dm.def' found.

(C:\Users\UserNameChanged\MikTeX\tex/latex/biblatex\blx-dm.def
File: blx-dm.def 2023/03/05 v3.19 biblatex localization (PK/MW)
)
Package biblatex Info: Trying to load biblatex style data model...
Package biblatex Info: ... file 'alphabetic.dbx' not found.
Package biblatex Info: Trying to load biblatex custom data model...
Package biblatex Info: ... file 'biblatex-dm.cfg' not found.
\c@afterword=\count308
\c@savedafterword=\count309
\c@annotator=\count310
\c@savedannotator=\count311
\c@author=\count312
\c@savedauthor=\count313
\c@bookauthor=\count314
\c@savedbookauthor=\count315
\c@commentator=\count316
\c@savedcommentator=\count317
\c@editor=\count318
\c@savededitor=\count319
\c@editora=\count320
\c@savededitora=\count321
\c@editorb=\count322
\c@savededitorb=\count323
\c@editorc=\count324
\c@savededitorc=\count325
\c@foreword=\count326
\c@savedforeword=\count327
\c@holder=\count328
\c@savedholder=\count329
\c@introduction=\count330
\c@savedintroduction=\count331
\c@namea=\count332
\c@savednamea=\count333
\c@nameb=\count334
\c@savednameb=\count335
\c@namec=\count336
\c@savednamec=\count337
\c@translator=\count338
\c@savedtranslator=\count339
\c@shortauthor=\count340
\c@savedshortauthor=\count341
\c@shorteditor=\count342
\c@savedshorteditor=\count343
\c@labelname=\count344
\c@savedlabelname=\count345
\c@institution=\count346
\c@savedinstitution=\count347
\c@lista=\count348
\c@savedlista=\count349
\c@listb=\count350
\c@savedlistb=\count351
\c@listc=\count352
\c@savedlistc=\count353
\c@listd=\count354
\c@savedlistd=\count355
\c@liste=\count356
\c@savedliste=\count357
\c@listf=\count358
\c@savedlistf=\count359
\c@location=\count360
\c@savedlocation=\count361
\c@organization=\count362
\c@savedorganization=\count363
\c@origlocation=\count364
\c@savedoriglocation=\count365
\c@origpublisher=\count366
\c@savedorigpublisher=\count367
\c@publisher=\count368
\c@savedpublisher=\count369
\c@language=\count370
\c@savedlanguage=\count371
\c@origlanguage=\count372
\c@savedoriglanguage=\count373
\c@pageref=\count374
\c@savedpageref=\count375
\shorthandwidth=\skip58
\shortjournalwidth=\skip59
\shortserieswidth=\skip60
\shorttitlewidth=\skip61
\shortauthorwidth=\skip62
\shorteditorwidth=\skip63
\locallabelnumberwidth=\skip64
\locallabelalphawidth=\skip65
\localshorthandwidth=\skip66
\localshortjournalwidth=\skip67
\localshortserieswidth=\skip68
\localshorttitlewidth=\skip69
\localshortauthorwidth=\skip70
\localshorteditorwidth=\skip71
Package biblatex Info: Trying to load compatibility code...
Package biblatex Info: ... file 'blx-compat.def' found.

(C:\Users\UserNameChanged\MikTeX\tex/latex/biblatex\blx-compat.def
File: blx-compat.def 2023/03/05 v3.19 biblatex compatibility (PK/MW)
)
Package biblatex Info: Trying to load generic definitions...
Package biblatex Info: ... file 'biblatex.def' found.

(C:\Users\UserNameChanged\MikTeX\tex/latex/biblatex\biblatex.def
File: biblatex.def 2023/03/05 v3.19 biblatex compatibility (PK/MW)
\c@textcitecount=\count376
\c@textcitetotal=\count377
\c@textcitemaxnames=\count378
\c@biburlbigbreakpenalty=\count379
\c@biburlbreakpenalty=\count380
\c@biburlnumpenalty=\count381
\c@biburlucpenalty=\count382
\c@biburllcpenalty=\count383
\biburlbigskip=\muskip17
\biburlnumskip=\muskip18
\biburlucskip=\muskip19
\biburllcskip=\muskip20
\c@smartand=\count384
)
Package biblatex Info: Trying to load bibliography style 'alphabetic'...
Package biblatex Info: ... file 'alphabetic.bbx' found.

(C:\Users\UserNameChanged\MikTeX\tex/latex/biblatex/bbx\alphabetic.bbx
File: alphabetic.bbx 2023/03/05 v3.19 biblatex bibliography style (PK/MW)
Package biblatex Info: Trying to load bibliography style 'standard'...
Package biblatex Info: ... file 'standard.bbx' found.

(C:\Users\UserNameChanged\MikTeX\tex/latex/biblatex/bbx\standard.bbx
File: standard.bbx 2023/03/05 v3.19 biblatex bibliography style (PK/MW)
\c@bbx:relatedcount=\count385
\c@bbx:relatedtotal=\count386
))
Package biblatex Info: Trying to load citation style 'alphabetic'...
Package biblatex Info: ... file 'alphabetic.cbx' found.

(C:\Users\UserNameChanged\MikTeX\tex/latex/biblatex/cbx\alphabetic.cbx
File: alphabetic.cbx 2023/03/05 v3.19 biblatex citation style (PK/MW)
Package biblatex Info: Redefining '\cite'.
Package biblatex Info: Redefining '\parencite'.
Package biblatex Info: Redefining '\footcite'.
Package biblatex Info: Redefining '\footcitetext'.
Package biblatex Info: Redefining '\smartcite'.
Package biblatex Info: Redefining '\textcite'.
Package biblatex Info: Redefining '\textcites'.
Package biblatex Info: Redefining '\cites'.
Package biblatex Info: Redefining '\parencites'.
Package biblatex Info: Redefining '\smartcites'.
)
Package biblatex Info: Trying to load configuration file...
Package biblatex Info: ... file 'biblatex.cfg' found.

(C:\Users\UserNameChanged\MikTeX\tex/latex/biblatex\biblatex.cfg
File: biblatex.cfg 
)
Package biblatex Info: Input encoding 'utf8' detected.
Package biblatex Info: Document encoding is UTF8 ....

(C:\Users\UserNameChanged\MikTeX\tex/latex/l3kernel\expl3.sty
Package: expl3 2023-08-11 L3 programming layer (loader) 

(C:\Users\UserNameChanged\MikTeX\tex/latex/l3backend\l3backend-pdftex.def
File: l3backend-pdftex.def 2023-04-19 L3 backend support: PDF output (pdfTeX)
\l__color_backend_stack_int=\count387
\l__pdf_internal_box=\box51
))
Package biblatex Info: ... and expl3
(biblatex)             2023-08-11 L3 programming layer (loader) 
(biblatex)             is new enough (at least 2020/04/06),
(biblatex)             setting 'casechanger=expl3'.

(C:\Users\UserNameChanged\MikTeX\tex/latex/biblatex\blx-case-expl3.sty
(C:\Users\UserNameChanged\MikTeX\tex/latex/l3packages/xparse\xparse.sty
Package: xparse 2023-02-02 L3 Experimental document command parser
)
Package: blx-case-expl3 2023/03/05 v3.19 expl3 case changing code for biblatex
))
(C:\Users\UserNameChanged\MikTeX\tex/latex/caption\caption.sty
Package: caption 2023/07/31 v3.6n Customizing captions (AR)

(C:\Users\UserNameChanged\MikTeX\tex/latex/caption\caption3.sty
Package: caption3 2023/07/31 v2.4d caption3 kernel (AR)
\caption@tempdima=\dimen141
\captionmargin=\dimen142
\caption@leftmargin=\dimen143
\caption@rightmargin=\dimen144
\caption@width=\dimen145
\caption@indent=\dimen146
\caption@parindent=\dimen147
\caption@hangindent=\dimen148
Package caption Info: Standard document class detected.
)
\c@caption@flags=\count388
\c@continuedfloat=\count389
)
\@quotelevel=\count390
\@quotereset=\count391

(CountingReferencesTest.aux)
\openout1 = `CountingReferencesTest.aux'.

LaTeX Font Info:    Checking defaults for OML/cmm/m/it on input line 30.
LaTeX Font Info:    ... okay on input line 30.
LaTeX Font Info:    Checking defaults for OMS/cmsy/m/n on input line 30.
LaTeX Font Info:    ... okay on input line 30.
LaTeX Font Info:    Checking defaults for OT1/cmr/m/n on input line 30.
LaTeX Font Info:    ... okay on input line 30.
LaTeX Font Info:    Checking defaults for T1/cmr/m/n on input line 30.
LaTeX Font Info:    ... okay on input line 30.
LaTeX Font Info:    Checking defaults for TS1/cmr/m/n on input line 30.
LaTeX Font Info:    ... okay on input line 30.
LaTeX Font Info:    Checking defaults for OMX/cmex/m/n on input line 30.
LaTeX Font Info:    ... okay on input line 30.
LaTeX Font Info:    Checking defaults for U/cmr/m/n on input line 30.
LaTeX Font Info:    ... okay on input line 30.
Package biblatex Info: Trying to load language 'english'...
Package biblatex Info: ... file 'english.lbx' found.

(C:\Users\UserNameChanged\MikTeX\tex/latex/biblatex/lbx\english.lbx
File: english.lbx 2023/03/05 v3.19 biblatex localization (PK/MW)
)
Package biblatex Info: Input encoding 'utf8' detected.
Package biblatex Info: Automatic encoding selection.
(biblatex)             Assuming data encoding 'utf8'.
\openout3 = `CountingReferencesTest.bcf'.

Package biblatex Info: Trying to load bibliographic data...
Package biblatex Info: ... file 'CountingReferencesTest.bbl' found.

(CountingReferencesTest.bbl)
Package biblatex Info: Reference section=0 on input line 30.
Package biblatex Info: Reference segment=0 on input line 30.
Package caption Info: Begin \AtBeginDocument code.
Package caption Info: End \AtBeginDocument code.
 [1{C:/Users/UserNameChanged/AppData/Local/MiKTeX/fonts/map/pdftex/pdftex.map}

] [2

] [3] (CountingReferencesTest.aux)
 ***********
LaTeX2e <2023-06-01> patch level 1
L3 programming layer <2023-08-11>
 ***********


LaTeX Warning: There were undefined references.


Package biblatex Warning: Please (re)run Biber on the file:
(biblatex)                CountingReferencesTest
(biblatex)                and rerun LaTeX afterwards.

Package logreq Info: Writing requests to 'CountingReferencesTest.run.xml'.
\openout1 = `CountingReferencesTest.run.xml'.

 ) 
Here is how much of TeX's memory you used:
 9899 strings out of 475465
 193551 string characters out of 5770800
 1918248 words of memory out of 5000000
 31165 multiletter control sequences out of 15000+600000
 559374 words of font info for 40 fonts, out of 8000000 for 9000
 1141 hyphenation exceptions out of 8191
 66i,5n,81p,697b,1589s stack positions out of 10000i,1000n,20000p,200000b,200000s
<C:/Users/UserNameChanged/MikTeX/fonts/type1/public/amsfonts/cm/cmbx12.pfb><C:/Users/R
asmus/MikTeX/fonts/type1/public/amsfonts/cm/cmr10.pfb><C:/Users/UserNameChanged/MikTeX/f
onts/type1/public/amsfonts/cm/cmr7.pfb><C:/Users/UserNameChanged/MikTeX/fonts/type1/publ
ic/amsfonts/cm/cmti10.pfb>
Output written on CountingReferencesTest.pdf (3 pages, 52514 bytes).
PDF statistics:
 32 PDF objects out of 1000 (max. 8388607)
 0 named destinations out of 1000 (max. 500000)
 1 words of extra memory for PDF output out of 10000 (max. 10000000)

CountingReferences.bbl

% $ biblatex auxiliary file $
% $ biblatex bbl format version 3.2 $
% Do not modify the above lines!
%
% This is an auxiliary file used by the 'biblatex' package.
% This file may safely be deleted. It will be recreated by
% biber as required.
%
\begingroup
\makeatletter
\@ifundefined{[email protected]}
  {\@latex@error
     {Missing 'biblatex' package}
     {The bibliography requires the 'biblatex' package.}
      \aftergroup\endinput}
  {}
\endgroup


\refsection{0}
  \datalist[entry]{anyt/global//global/global}
    \entry{example_reference_2023}{book}{}
      \name{author}{1}{}{%
        {{hash=e7f142de2478aeb2fd60490489084a80}{%
           family={Smith},
           familyi={S\bibinitperiod},
           given={Mr},
           giveni={M\bibinitperiod}}}%
      }
      \list{location}{1}{%
        {FakeCity}%
      }
      \list{publisher}{2}{%
        {Nowhere}%
        {noone}%
      }
      \strng{namehash}{e7f142de2478aeb2fd60490489084a80}
      \strng{fullhash}{e7f142de2478aeb2fd60490489084a80}
      \strng{bibnamehash}{e7f142de2478aeb2fd60490489084a80}
      \strng{authorbibnamehash}{e7f142de2478aeb2fd60490489084a80}
      \strng{authornamehash}{e7f142de2478aeb2fd60490489084a80}
      \strng{authorfullhash}{e7f142de2478aeb2fd60490489084a80}
      \field{labelalpha}{Smi23}
      \field{sortinit}{S}
      \field{sortinithash}{b164b07b29984b41daf1e85279fbc5ab}
      \field{labelnamesource}{author}
      \field{labeltitlesource}{title}
      \field{title}{Made-up Title}
      \field{year}{2023}
      \field{dateera}{ce}
    \endentry
  \enddatalist
\endrefsection
\endinput

答案1

由于单行检查,字幕内容被处理两次。

您可以禁用检查:

\captionsetup{singlelinecheck=false}

或者在检查期间禁用 citetracker。caption 有一个(未记录的)钩子用于此:

\AtCaptionSingleLineCheck{\boolfalse{citetracker}}

相关内容