3

Is there a way to include a backslash in the title field a bibliographic entry? The MWE below keeps erroring out with

! Undefined control sequence.
<argument> Faster \unfolding 
                         of communities 

almost like it first makes the \textbackslash into a backslash, and then reinterpreting \unfolding as a command.

\RequirePackage{filecontents}
\begin{filecontents*}{\jobname.bib}

@article{Traag2015,
  eprinttype = {arxiv},
  eprint = {1503.01322},
  title = {Faster \textbackslash unfolding of communities: speeding up the Louvain algorithm},
  url = {http://arxiv.org/abs/1503.01322},
  shorttitle = {Faster unfolding of communities},
  abstract = {textbackslash},
  timestamp = {2015-05-27 22:09:43},
  author = {Traag, V. A.},
  urldate = {2015-05-27},
  date = {2015-03-04},
  keywords = {Computer Science - Data Structures and Algorithms,Computer Science - Social and Information Networks,Physics - Physics and Society}
}


\end{filecontents*}

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[backend=biber, bibencoding=utf8]{biblatex}
\addbibresource{\jobname.bib}
\begin{document}
\nocite{*}
\printbibliography
\end{document}
4
  • 2
    A download and examination of the actual publication -- which is trivially easy to accomplish since the arxiv url is available -- reveals that the backslash character in the title field of the bib entry you're working with is not present in the original. Instead, the backslash character is purely an artifact of whatever process created the bib entry. Do correct the bib entry rather than figure out how to typeset the specious backslash character.
    – Mico
    Jul 16, 2015 at 22:27
  • Hi Mico, I appreciate your efforts, but the MWE was intended to show the problem rather than result in the typesetting of this particular reference. I develop the Zotero Better BibTeX extension, and I'm looking for a safe mapping when exporting to BibTeX for the general case. For my case it doesn't matter that the backslash is not present in the original. It was in fact, but in the abstract rather than the title, and I was just toying around with the sample to see if it was particular to the abstract field (it was not).
    – retorquere
    Jul 17, 2015 at 6:51
  • It wouldn't have hurt if you had indicated up front that the sample bib entry had been modified deliberately in order to make a specific point.
    – Mico
    Jul 17, 2015 at 7:22
  • That would indeed have prevented confusion, sorry for that. I had intended for the question to be interpreted quite literally.
    – retorquere
    Jul 17, 2015 at 7:40

2 Answers 2

2

The expansion of \textbackslash (note the space) does get interpreted as \, and ultimately results in \unfolding. You can declare a robust alternative

\DeclareRobustCommand{\tbs}{\textbackslash}

which doesn't expand, and then use it as normal:

enter image description here

\RequirePackage{filecontents}
\DeclareRobustCommand{\tbs}{\textbackslash}
\begin{filecontents*}{\jobname.bib}

@article{Traag2015,
  eprinttype = {arxiv},
  eprint = {1503.01322},
  title = {Faster \tbs{} unfolding of communities: speeding up the Louvain algorithm},
  url = {http://arxiv.org/abs/1503.01322},
  shorttitle = {Faster unfolding of communities},
  abstract = {textbackslash},
  timestamp = {2015-05-27 22:09:43},
  author = {Traag, V. A.},
  urldate = {2015-05-27},
  date = {2015-03-04},
  keywords = {Computer Science - Data Structures and Algorithms,Computer Science - Social and Information Networks,Physics - Physics and Society}
}


\end{filecontents*}

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[backend=biber, bibencoding=utf8]{biblatex}
\addbibresource{\jobname.bib}
\begin{document}
\nocite{*}
\printbibliography
\end{document}
4
  • Aside: The backslash character is not present in the actual publication; it's merely an artifact of whatever process created the bib entry.
    – Mico
    Jul 16, 2015 at 22:31
  • I think that point was made clearly the first two times.
    – retorquere
    Jul 17, 2015 at 6:52
  • @Werner: super thanks for your explanation. Would \char`\\ also work? I'm looking for a solution that wouldn't need any work done in the preamble; I develop the Zotero Better BibTeX plugin, and I can't assume (too much) about the document in which the exported BibTeX will be used.
    – retorquere
    Jul 17, 2015 at 6:54
  • @retorquere: That seems to work too, yes.
    – Werner
    Jul 17, 2015 at 13:55
2

Since Biber is translating \textbackslash in a single backslash, trick TeX into thinking it has to print a control sequence as a string (with {} for getting the space).

title = {Faster \string\textbackslash unfolding{} of communities: 
         speeding up the Louvain algorithm},

enter image description here

Or, more simply,

title = {Faster \string\unfolding{} of communities: 
         speeding up the Louvain algorithm},

since Biber will not interpret macros it doesn't know.

2
  • Aside: The backslash character is not present in the actual publication; it's merely an artifact of whatever process created the bib entry.
    – Mico
    Jul 16, 2015 at 22:31
  • @MIco yes, yes. That was not the point of my question.
    – retorquere
    Jul 17, 2015 at 6:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .