# Pdflatex refuses to process .bib file with hash sign #

Pdflatex (not Biber) complains in the howpublished line in the bbl about the hastag sign. It does compile when I delete the hastag, but whats wrong, how to prevent this in the first place?

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


MWE:

\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}
\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}


This is the entry:

\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


Biber version:

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

• Thank you for the edit, please note though that the code is next to useless for us since we don't have you .bib file, so we will still have to type that up ourselves. See here for hints on MWEs for bibliography questions. – moewe May 25 '16 at 16:06
• Please post the entry from the bib file, not the one from the bbl file. – Mico May 25 '16 at 16:07
• It can't work. The url with the # is in the argument of another command (\field) and so can't change the catcodes. Beside this: You have the same url already in the url field (where it works) so why did you add it to howpublished a second time? – Ulrike Fischer May 25 '16 at 16:08
• @AndrewSwann: The url is wrapped in a \url command. See \field{howpublished}{\url{https://tools.ietf.org/html/rfc3168#page-11}}  but in biblatex this doesn't help. url's with special chars must go in verbatim fields. – Ulrike Fischer May 25 '16 at 16:11
• Your url is in the wrong field: it should be as a url in the .bib file, not in howublished. The url field is handled verbatim, howpublsihed is not. – Joseph Wright May 25 '16 at 16:21

You can't have an unescaped hash sign in non-verbatim fields in your .bib file even if you hide it in a \url command, where normally it does not cause harm.

URLs should best be given in the dedicated url field (which you seem to have done anyway), which can handle evil characters such as # and friends, because it uses a special verbatim mode.

You can then delete the howpublished with Biber's sourcemapping before it causes any harm. We can even try and recover the URL from the howpsublished field if we don't already have a url field.

\DeclareSourcemap{
\maps[datatype=bibtex]{
\map{
\step[fieldsource=howpublished, match=\regexp{\A\\url\{(.+)\}\Z}, final]
\step[fieldset=url, fieldvalue={$1}] \step[fieldset=howpublished, null] } } }  Full 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}