# use \path instead of \verb in biblatex [duplicate]

Noting that \path can be made to wrap arbitrary text as per Forcing linebreaks in \url, I would like to use \path instead of \verb inside of biblatex for the "verbatim" fields.

This would mean overriding both \verb and \endverb, see for example these lines in the .bbl file generated from the MWE below.

  \verb{file}
\verb /Users/joe/Weholdthesetruthstobeself-evidentthatallmenarecreatedequalthattheyareendowedbytheirCreatorwithcertainunalienableRightsthatamongtheseareLifeLibertyandthepursuitofHappiness/dec.txt
\endverb


I'm confused about how that would work syntactically.

The image here shows desired line wrapping on "Path"; the (nice) behaviour for a file name with lots of underscores; and the (not very nice) behaviour for file name without underscores.

Source code for the above:

% arara: pdflatex
% arara: biber
% arara: pdflatex
% arara: pdflatex
\documentclass{article}

entrykey=false,
natbib,
hyperref=false,
url=false,
doi=false,
%style=apa,
sorting=nyt,
isbn=false,
%backref=true,
firstinits=true,
minnames=13,
maxnames=35,
minbibnames=10,
maxbibnames=100,
parentracker=true,
defernumbers=true,
backend=biber]{biblatex}

\usepackage[hyphenbreaks]{breakurl}
\PassOptionsToPackage{hyphens}{url}

\begin{filecontents}{\jobname.bib}
@inproceedings{XXXXXX,
author = {PQR},
booktitle = {BBC},
keywords = {LLM},
title = {ARP},
year = {2010a},
file = {/Users/joe/We_hold_these_truths_to_be_self-evident_that_all_men_are_created_equal_that_they_are_endowed_by_their_Creator_with_certain_unalienable_Rights_that_among_these_are_Life_Liberty_and_the_pursuit_of_Happiness/dec.txt},
}

@inproceedings{YYYYYYYY,
author = {PQR},
booktitle = {BBC},
keywords = {LLM},
title = {ARP},
year = {2010b},
file = {/Users/joe/Weholdthesetruthstobeself-evidentthatallmenarecreatedequalthattheyareendowedbytheirCreatorwithcertainunalienableRightsthatamongtheseareLifeLibertyandthepursuitofHappiness/dec.txt},
}
\end{filecontents}

\expandafter\def\expandafter\UrlBreaks\expandafter{\UrlBreaks%  save the current one
\do\a\do\b\do\c\do\d\do\e\do\f\do\g\do\h\do\i\do\j%
\do\k\do\l\do\m\do\n\do\o\do\p\do\q\do\r\do\s\do\t%
\do\u\do\v\do\w\do\x\do\y\do\z\do\A\do\B\do\C\do\D%
\do\E\do\F\do\G\do\H\do\I\do\J\do\K\do\L\do\M\do\N%
\do\O\do\P\do\Q\do\R\do\S\do\T\do\U\do\V\do\W\do\X%
\do\Y\do\Z}

\begin{document}

Path: \path{/Users/joe/Weholdthesetruthstobeself-evidentthatallmenarecreatedequalthattheyareendowedbytheirCreatorwithcertainunalienableRightsthatamongtheseareLifeLibertyandthepursuitofHappiness/dec.txt}

\nocite{*}

\printbibliography

\end{document}


## marked as duplicate by Joe Corneli, Kurt, Raaja, JouleV, Stefan PinnowMar 12 at 12:27

First off, the output in the .bbl file is purely for internal use for biblatex and its use of the command \verb does not mean that this is the command that is actually used to print the field later on in the bibliography. So patching the .bbl to have \path instead of \verb would just break biblatex, but not the file paths in the bibliography.

The important thing for the output is the field format for file. In your setup (with the reading style) the definition is

\DeclareFieldFormat{file}{\bibstring{file}\addcolon\space \url{#1}}


so biblatex uses the \url command from the url package (which it loads).

But this is not the whole story. biblatex has its own modification of url's settings to enable a more fine-grained control over URL breaking in the bibliography. In particular \UrlBreaks is redefined for all URLs printed by biblatex. So your redefinition of \UrlBreaks gets overwritten.

You can get a similar result to your redefinition with biblatex's built-in features by setting biburlucpenalty and biburllcpenalty to non-zero values. See also Line breaks of long URLs in biblatex bibliography?. For good measure you may also want to look into setting biburlnumpenalty.

\documentclass{article}

\setcounter{biburlucpenalty}{9000}
\setcounter{biburllcpenalty}{9000}

%\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@inproceedings{XXXXXX,
author = {PQR},
booktitle = {BBC},
keywords = {LLM},
title = {ARP},
year = {2010},
file = {/Users/joe/We_hold_these_truths_to_be_self-evident_that_all_men_are_created_equal_that_they_are_endowed_by_their_Creator_with_certain_unalienable_Rights_that_among_these_are_Life_Liberty_and_the_pursuit_of_Happiness/dec.txt},
}

@inproceedings{YYYYYYYY,
author = {PQR},
booktitle = {BBC},
keywords = {LLM},
title = {ARP},
year = {2010},
file = {/Users/joe/Weholdthesetruthstobeself-evidentthatallmenarecreatedequalthattheyareendowedbytheirCreatorwithcertainunalienableRightsthatamongtheseareLifeLibertyandthepursuitofHappiness/dec.txt},
}
\end{filecontents}

\begin{document}
\nocite{*}
\printbibliography
\end{document}


If you don't want to use biblatex's built-in features and want to carry your custom redefinition of url's settings into biblatex, then a bit of extra work is needed.

The cheapest solution I found was

\newcommand*{\mkjcurlbreaks}{%
\expandafter\def\expandafter\UrlBreaks\expandafter{\UrlBreaks%  save the current one
\do\a\do\b\do\c\do\d\do\e\do\f\do\g\do\h\do\i\do\j%
\do\k\do\l\do\m\do\n\do\o\do\p\do\q\do\r\do\s\do\t%
\do\u\do\v\do\w\do\x\do\y\do\z\do\A\do\B\do\C\do\D%
\do\E\do\F\do\G\do\H\do\I\do\J\do\K\do\L\do\M\do\N%
\do\O\do\P\do\Q\do\R\do\S\do\T\do\U\do\V\do\W\do\X%
\do\Y\do\Z}}

\mkjcurlbreaks


An alternative approach could modify the definition of biblatex's \biburlsetup directly.