Pdflatex 拒绝处理带有井号的 .bib 文件#

Pdflatex 拒绝处理带有井号的 .bib 文件#

Pdflatex(不是 Biber)在howpublishedbbl 中抱怨有关 hastag 符号的行。当我删除 hastag 时,它确实可以编译,但出了什么问题,如何首先防止这种情况发生?

Illegal parameter number in definition of \NewValue. ...s://tools.ietf.org/html/rfc3168#page-11}}

梅威瑟:

\documentclass[
12pt,
a4paper
%   BCOR=20mm
]{scrbook}
%\KOMAoptions{appendixprefix=true}
%
%NOTE Packages, my Macros und Formatdefinitions
\usepackage[english,ngerman]{babel} % Multilingual support -> ctan.org/pkg/babel
\usepackage[T1]{fontenc}            % Allows different font encodings and hyphenation -> ctan.org/pkg/fontenc
\usepackage[utf8]{inputenc}         % Translates input encodings into LaTeX internal language

\usepackage{blindtext}
    \usepackage[                % stuff in case of biber: .bib file, style etc.
    backend=biber,      
    style=numeric,
    citestyle=numeric]{biblatex}
        \addbibresource{Literatur_utf8.bib}                     
        \defbibfilter{papers}{  type=article or type=book}  % Can seperate books/eBooks and links

\begin{document}
    This is the mwe \cite{Floyd_undated-cb}
\end{document}

这是条目:

\entry{Floyd_undated-cb}{misc}{}
  \name{author}{3}{}{%
    {{hash=bcb66fc187ba17e78c6c22747197aecf}{%
       family={Floyd},
       family_i={F\bibinitperiod},
       given={Sally},
       given_i={S\bibinitperiod}}}%
    {{hash=e1587d1fc53e04bb032d1278b592db58}{%
       family={Ramakrishnan},
       family_i={R\bibinitperiod},
       given={K\bibnamedelima K},
       given_i={K\bibinitperiod\bibinitdelim K\bibinitperiod}}}%
    {{hash=88b8fe0624f2fc41889533817e5d5b7e}{%
       family={Black},
       family_i={B\bibinitperiod},
       given={David\bibnamedelima L},
       given_i={D\bibinitperiod\bibinitdelim L\bibinitperiod}}}%
  }
  \strng{namehash}{ec7a91f3f202ddfd3328bffa83be3444}
  \strng{fullhash}{ec7a91f3f202ddfd3328bffa83be3444}
  \field{sortinit}{F}
  \field{sortinithash}{c6a7d9913bbd7b20ea954441c0460b78}
  \field{labelnamesource}{author}
  \field{labeltitlesource}{title}
  \field{howpublished}{\url{https://tools.ietf.org/html/rfc3168#page-11}}
  \field{title}{The Addition of Explicit Congestion Notification ({ECN}) to {IP}}
  \verb{url}
  \verb https://tools.ietf.org/html/rfc3168#page-11
  \endverb
  \keyw{bibliography\_bsc}
\endentry

比伯版本:

(c:/texlive/2015/texmf-dist/tex/latex/biblatex/biblatex_.sty
Package: biblatex_ 2016/03/03 v3.3 programmable bibliographies (biber) (PK/JW/A
B)

答案1

.bib即使您将未转义的井号隐藏在\url命令中,它也不能出现在文件的非逐字字段中,通常它不会造成危害。

最好在专用url字段中提供 URL(无论如何您似乎已经这样做了),它可以处理诸如#和朋友之类的恶意字符,因为它使用特殊的逐字模式。

然后,您可以在造成任何损害之前使用 Biber 的源映射删除它。如果我们还没有字段,howpublished我们甚至可以尝试从该字段中恢复 URL 。howpsublishedurl

\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map{
      \step[fieldsource=howpublished, match=\regexp{\A\\url\{(.+)\}\Z}, final]
      \step[fieldset=url, fieldvalue={$1}]
      \step[fieldset=howpublished, null]
    }
  }
}

完整 MWE

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{filecontents}
\usepackage{biblatex}  

\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map{
      \step[fieldsource=howpublished, match=\regexp{\A\\url\{(.+)\}\Z}, final]
      \step[fieldset=url, fieldvalue={$1}]
      \step[fieldset=howpublished, null]
    }
  }
}

\begin{filecontents}{\jobname.bib}
@misc{bronto,
  title        = {A Theory on Brontosauruses},
  author       = {Anne Elk},
  howpublished = {\url{https://example.edu/~elk/bronto.html#page11}},
}
@misc{tric,
  title        = {A Theory on Triceratops},
  author       = {Anne Elk},
  url          = {https://example.edu/~elk/tric.html#page11},
  howpublished = {\url{https://example.edu/~elk/tric.html#page12}},
}
\end{filecontents}

\addbibresource{\jobname.bib}

\begin{document}
\cite{bronto,tric}             
\printbibliography                           
\end{document}

相关内容