![将整个 DOI 移至下一行,而不是粘在边距中](https://linux22.com/image/424559/%E5%B0%86%E6%95%B4%E4%B8%AA%20DOI%20%E7%A7%BB%E8%87%B3%E4%B8%8B%E4%B8%80%E8%A1%8C%EF%BC%8C%E8%80%8C%E4%B8%8D%E6%98%AF%E7%B2%98%E5%9C%A8%E8%BE%B9%E8%B7%9D%E4%B8%AD.png)
这是建立在我之前的一个问题我没有得到对我有用的答案。我简化了我的要求。
当我的参考书目中的 DOI 延伸到边缘时,是否可以将其引导至下一行,并在当前行留下空白,而不是这样做?
基于以下代码:
\documentclass{article}
\usepackage[width=14cm]{geometry}
\usepackage{showframe}
\usepackage[style=chem-rsc,doi=true,articletitle=true]{biblatex}
\begin{filecontents}[force]{\jobname.bib}
@article{VESTA,
author = "Momma, Koichi and Izumi, Fujio",
title = "{{\it VESTA3} for three-dimensional visualization of crystal, volumetric and morphology data}",
journal = "J. App. Cryst.",
year = "2011",
volume = "44",
number = "6",
pages = "1272--1276",
doi = {10.1107/S0021889811038970}
}
@Article{Charpin1985,
author = {Charpin, P. and Folcher, G. and Lance, M. and Nierlich, M. and Vigner, D.},
title = {Structure d'un complexe binucl\'{e}aire du nitrate d'uranyle et du N,N-dim\'{e}thyl-formamide: \(\mu\)-peroxo-bis[bis(N,N-dim\'{e}thyl-formamide)nitratodioxouranium(VI)], [(UO2)2(NO3)2O2(C3H7NO)4]},
journal = {Acta Crystallogr. Sect.~C: Struct. Chem.},
year = {1985},
volume = {41},
number = {9},
pages = {1302--1305},
doi = {10.1107/S0108270185007533},
}
@Article{Kawasaki2015,
author = {Kawasaki, Takeshi and Kitazawa, Takafumi},
title = {Crystal structure of Long Chemical Name Long Chemical Name Long that would need another package to print here asdfasdf},
journal = {Acta Crystallogr., Sect.~E: Struct. Rep. Online},
year = {2015},
volume = {71},
number = {5},
pages = {m122--m123},
doi = {10.1107/S2056989015007987},
}
@inproceedings{Meshlab,
booktitle = {Eurographics Italian Chapter Conference},
editor = {Vittorio Scarano and Rosario De Chiara and Ugo Erra},
title = {{MeshLab: an Open-Source Mesh Processing Tool}},
author = {Cignoni, Paolo and Callieri, Marco and Corsini, Massimiliano and Dellepiane, Matteo and Ganovelli, Fabio and Ranzuglia, Guido},
year = {2008},
publisher = {The Eurographics Association},
ISBN = {978-3-905673-68-5},
DOI = {10.2312/LocalChapterEvents/ItalChap/ItalianChapConf2008/129-136}
}
@Article{Vittal2011,
author = {Leong, Wei Lee and Vittal, Jagadese J.},
title = {One-Dimensional Coordination Polymers: Complexity and Diversity in Structures, Properties, and Applications},
journal = {Chem. Rev.},
year = {2011},
volume = {111},
number = {2},
pages = {688--764},
doi = {10.1021/cr100160e},
}
@article{Xu2018,
author = {Xu, Wei and Ren, Ya Nan and Xie, Miao and Zhou, Lin Xia and Zheng, Yue Qing},
doi = {10.1039/c7dt04909a},
journal = {Dalton Trans.},
number = {12},
pages = {4236--4250},
publisher = {Royal Society of Chemistry},
title = {{Six uranyl-organic frameworks with naphthalene-dicarboxylic acid and bipyridyl-based spacers: Syntheses, structures, and properties}},
volume = {47},
year = {2018}
}
@Article{HBond,
author = {Steiner, Thomas},
title = {The Hydrogen Bond in the Solid State},
journal = {Angew. Chem., Int. Ed.},
year = {2002},
volume = {41},
number = {1},
pages = {48--76},
doi = {10.1002/1521-3773(20020104)41:1<48::AID-ANIE48>3.0.CO;2-U},
}
@Article{rigu,
author = {Thorn, Andrea and Dittrich, Birger and Sheldrick, George M.},
title = {Enhanced rigid-bond restraints},
journal = {Acta Crystallogr. Sect.~A: Foundations and Advances},
year = {2012},
volume = {68},
number = {4},
pages = {448--451},
doi = {10.1107/S0108767312014535},
}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
How do I get BibLaTeX to stop putting the DOI in the margin?
The first paper is fine, since it breaks nicely into the next line.\autocite{VESTA}
However, the next two\autocite{Charpin1985,Kawasaki2015} give me problems since the part of the DOI after the / is so long.
\nocite{*}
\printbibliography
\end{document}
其中包含多个示例,因为上次我得到的代码应该可以做与此类似的事情,但是当给出不同长度和组成的 DOI 时,它很快就崩溃了。
MWE 再次显示了我想要避免的情况:
\documentclass{article}
\usepackage[width=14cm]{geometry}
\usepackage{showframe}
\usepackage[style=chem-rsc,doi=true,articletitle=true]{biblatex}
\DeclareFieldFormat{doi}{%
\nobreak\hfil\penalty50\hbox{}\nobreak
DOI\addcolon\addnbspace
\ifhyperref
{\href{https://doi.org/#1}{\nolinkurl{#1}}}
{\nolinkurl{#1}}}
\begin{filecontents}[force]{\jobname.bib}
@article{VESTA,
author = "Momma, Koichi and Izumi, Fujio",
title = "{{\it VESTA3} for three-dimensional visualization of crystal, volumetric and morphology data}",
journal = "J. App. Cryst.",
year = "2011",
volume = "44",
number = "6",
pages = "1272--1276",
doi = {10.1107/S0021889811038970}
}
@Article{Charpin1985,
author = {Charpin, P. and Folcher, G. and Lance, M. and Nierlich, M. and Vigner, D.},
title = {Structure d'un complexe binucl\'{e}aire du nitrate d'uranyle et du N,N-dim\'{e}thyl-formamide: \(\mu\)-peroxo-bis[bis(N,N-dim\'{e}thyl-formamide)nitratodioxouranium(VI)], [(UO2)2(NO3)2O2(C3H7NO)4]},
journal = {Acta Crystallogr. Sect.~C: Struct. Chem.},
year = {1985},
volume = {41},
number = {9},
pages = {1302--1305},
doi = {10.1107/S0108270185007533},
}
@Article{Kawasaki2015,
author = {Kawasaki, Takeshi and Kitazawa, Takafumi},
title = {Crystal structure of Long Chemical Name Long Chemical Name Long that would need another package to print here asdfasdf},
journal = {Acta Crystallogr., Sect.~E: Struct. Rep. Online},
year = {2015},
volume = {71},
number = {5},
pages = {m122--m123},
doi = {10.1107/S2056989015007987},
}
@inproceedings{Meshlab,
booktitle = {Eurographics Italian Chapter Conference},
editor = {Vittorio Scarano and Rosario De Chiara and Ugo Erra},
title = {{MeshLab: an Open-Source Mesh Processing Tool}},
author = {Cignoni, Paolo and Callieri, Marco and Corsini, Massimiliano and Dellepiane, Matteo and Ganovelli, Fabio and Ranzuglia, Guido},
year = {2008},
publisher = {The Eurographics Association},
ISBN = {978-3-905673-68-5},
DOI = {10.2312/LocalChapterEvents/ItalChap/ItalianChapConf2008/129-136}
}
@Article{Vittal2011,
author = {Leong, Wei Lee and Vittal, Jagadese J.},
title = {One-Dimensional Coordination Polymers: Complexity and Diversity in Structures, Properties, and Applications},
journal = {Chem. Rev.},
year = {2011},
volume = {111},
number = {2},
pages = {688--764},
doi = {10.1021/cr100160e},
}
@article{Xu2018,
author = {Xu, Wei and Ren, Ya Nan and Xie, Miao and Zhou, Lin Xia and Zheng, Yue Qing},
doi = {10.1039/c7dt04909a},
journal = {Dalton Trans.},
number = {12},
pages = {4236--4250},
publisher = {Royal Society of Chemistry},
title = {{Six uranyl-organic frameworks with naphthalene-dicarboxylic acid and bipyridyl-based spacers: Syntheses, structures, and properties}},
volume = {47},
year = {2018}
}
@Article{HBond,
author = {Steiner, Thomas},
title = {The Hydrogen Bond in the Solid State},
journal = {Angew. Chem., Int. Ed.},
year = {2002},
volume = {41},
number = {1},
pages = {48--76},
doi = {10.1002/1521-3773(20020104)41:1<48::AID-ANIE48>3.0.CO;2-U},
}
@Article{rigu,
author = {Thorn, Andrea and Dittrich, Birger and Sheldrick, George M.},
title = {Enhanced rigid-bond restraints},
journal = {Acta Crystallogr. Sect.~A: Foundations and Advances},
year = {2012},
volume = {68},
number = {4},
pages = {448--451},
doi = {10.1107/S0108767312014535},
}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
In this case, \autocite{VESTA} takes a different approach, moving the whole DOI to the next line.
This allows both\autocite{Charpin1985,Kawasaki2015} to work perfectly.
However, note what happens further down\autocite{Vittal2011,Xu2018}
with short DOIs getting way to much space.
\nocite{*}
\printbibliography
\end{document}
如您所见,参考书目似乎很敏感,所以我认为最好包含一些测试用例。现在,我不再试图将每个太长的 DOI 移到下一行(因为这似乎很难,而且公平地说,在我的参考文献部分留下了大量额外的空白),而是只想将 DOI 向下移动一行如果它会突出到边缘。哦,如果可能的话,我希望 DOI: 能随之移动。
答案1
我想你想要
\DeclareFieldFormat{doi}{%
\hfil\penalty90\hfilneg\space DOI\addcolon\addnbspace
\ifhyperref
{\href{https://doi.org/#1}{\nolinkurl{#1}}}
{\nolinkurl{#1}}}
如果换行发生在惩罚处,您可以\hfil
填补短行。如果没有,那么\hfil
和会\hfilneg
相互抵消,这样您只会从中获得正常的单词间空间\space
。如果 DOI 确实足够短,可以放在一行中,您可以放置一个\mbox{}
来#1
确保它不会中断,因为如果需要,它仍然可能会中断。
(2022 年 4 月 14 日编辑:罚款从 50 英镑调整为 90 英镑。)