請注意,\path
可以根據以下內容對任意文字進行換行在 \url 中強制換行,我想使用\path
而不是\verb
biblatex 內部的“逐字記錄”字段。
這表示覆蓋\verb
和\endverb
,例如,請參閱.bbl
下面從 MWE 產生的檔案中的這些行。
\verb{file}
\verb /Users/joe/Weholdthesetruthstobeself-evidentthatallmenarecreatedequalthattheyareendowedbytheirCreatorwithcertainunalienableRightsthatamongtheseareLifeLibertyandthepursuitofHappiness/dec.txt
\endverb
我對這在語法上如何運作感到困惑。
此處的影像顯示了「路徑」上所需的換行;有大量下劃線的檔案名稱的(好的)行為;以及不帶下劃線的文件名的(不是很好)行為。
上面的原始碼:
% arara: pdflatex
% arara: biber
% arara: pdflatex
% arara: pdflatex
\documentclass{article}
\usepackage[style=reading,
entryhead=true,
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}
\addbibresource{\jobname.bib}
\begin{document}
Path: \path{/Users/joe/Weholdthesetruthstobeself-evidentthatallmenarecreatedequalthattheyareendowedbytheirCreatorwithcertainunalienableRightsthatamongtheseareLifeLibertyandthepursuitofHappiness/dec.txt}
\nocite{*}
\printbibliography
\end{document}
答案1
首先,文件中的輸出.bbl
純粹供內部使用biblatex
,並且它對命令的使用\verb
並不意味著這是稍後在參考書目中實際用於打印字段的命令。因此,將 修補為.bbl
has\path
而不是\verb
只會破壞biblatex
,但不會破壞參考書目中的文件路徑。
對於輸出來說,重要的是 的欄位格式file
。在您的設定(使用reading
樣式)中,定義是
\DeclareFieldFormat{file}{\bibstring{file}\addcolon\space \url{#1}}
因此biblatex
使用包(它加載的)\url
中的命令。url
但這還不是故事的全部。對 的設定biblatex
進行了自己的修改url
,以便對參考書目中的 URL 破壞進行更細微的控制。特別\UrlBreaks
是為 列印的所有 URL 重新定義biblatex
。所以你的重新定義\UrlBreaks
會被覆蓋。
透過將和設為非零值,您可以獲得與biblatex
使用 的內建功能重新定義類似的結果。也可以看看biburlucpenalty
biburllcpenalty
biblatex 參考書目中長 URL 的換行符號?。為了更好地衡量,您可能還需要研究一下設定biburlnumpenalty
。
\documentclass{article}
\usepackage[style=reading, backend=biber]{biblatex}
\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}
\addbibresource{\jobname.bib}
\begin{document}
\nocite{*}
\printbibliography
\end{document}
如果您不想使用biblatex
的內建功能並希望將您自訂的url
設定重新定義到 中biblatex
,那麼需要做一些額外的工作。
我發現的最便宜的解決方案是
\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
\DeclareFieldFormat{file}{\bibstring{file}\addcolon\space\mkjcurlbreaks\url{#1}}
另一種方法可以修改biblatex
的定義\biburlsetup
直接地。