THE SOLUTION:
It works with doi and url field filled with the _ character. The output is not
exactly correct with the bibliography style chosen show the url or the doi, but
the information displayed is correct and this don't break the TeX Preview.
Also, this works even if the bibliography style doesn't show the content of the
url or the doi field.
And click on the "@" icon in the right of the url or doi field also works as
expected.
WHAT TO DO:
All we have to do is go to the BibDesk setting, go to the TeX Preview panel,
click on the button to edit the TeX template, this opens the file
~/Library/Application Support/BibDesk/previewtemplate.tex and then, we have to
add the line:
\usepackage[colorlinks,allcolors=blue]{hyperref}
just before \begin{document}.
THE RESULT:
If the chosen bibliography style doesn't show the url or doi field, the preview
is not broken by the presence of "_" in the doi or url field. No red message
anymore !!! (unless there is an error in other fields like abstract with
non-ASCII characters).
If the chosen bibliography style shows the url or the doi field, the preview is
also not broken, but perhaps the doi is shown with tt character. But the TeX
Preview is anyway a preview, not a real output. It purpose is to verify is any
information (author, title with uppercases, journal name, volume, year, month
is correctly displayed. The preview is not broken by the presence of the "_" in
the doi or url field.
The BibDesk app is then functional even if there are "_" in the doi or url
field.
For the real usage, in the real LaTeX document, with the real .bib file, we can
use the usual techniques suggested managing the "_" in the doi or url field.
My question was about BibDesk and all her functionality (including the "@" icon
button AND the TeX Preview). It's better to have a working TeX Preview, even if
the output is slightly different from the real case, than a broken TeX Preview
because of the presence of "_" in the doi or url field.
*********************
I hope you will in a next update directly add the line
\usepackage[colorlinks,allcolors=blue]{hyperref} so the TeX Preview works for
all users when there is "_" in the doi or url field. You can show a disclaimer
stating that the output can differ from the real usage case, because of the
inclusion of the hyperref package.
*********************
So BibDesk will work smoothly for users in many more situations.
---
Another, but less working solution. It's a brute force solution, with side
effects (probably a very fragile solution, not advisable). Instead of
\usepackage[colorlinks,allcolors=blue]{hyperref}, add this line just before
\begin{document}:
\catcode`_=11
But then, for example with the elsarticle-num bibliography style, if the url
field is correctly displayed (url with _ in tt font shape), for the doi, the
number is displayed in roman font shape as expected, but the _ character is
displayed as: ̇ (space + COMBINING DOT ABOVE, U+0020 and U+0307).
Probably not a really good method, which cannot work correctly in some
situations.
I'm sorry if all my text is hard to read for a fluent English language user.
Thanks.
> Le 23 mai 2024 à 15:28, Nathan <[email protected]> a écrit :
>
>
>> On May 23, 2024, at 5:16 AM, Christiaan Hofman <[email protected]> wrote:
>>
>> I am not sure what to do exactly about the underscore and the dueling
>> requirements for URL and tex. I am also not completely sure about what tex
>> can handle, also combined with the \url command. One option may be to use a
>> tex conversion for the underscore, so it its saved as {\_} in .bib, but in
>> BibDesk it turns up as _.
>
> I don't think TeX conversion of URL and DOI fields is a good idea, although I
> haven't analyzed all the implications of such a choice. Adam R. Maxwell's
> response seemed right to me: you "need to edit the BibTeX style to
> interpret/display those fields correctly, instead of altering the underlying
> data to be incorrect".
>
>> On May 22, 2024, at 9:02 PM, Adam R. Maxwell via Bibdesk-users
>> <[email protected]> wrote:
>>
>> You are missing something, although I don't know if it's obvious. You (or
>> Elsevier) need to edit the BibTeX style to interpret/display those fields
>> correctly, instead of altering the underlying data to be incorrect. Take a
>> look at how abbrvnat.bst (to pick a random example) handles this.
>> Unfortunately, not all styles handle a "doi" field correctly, so you may not
>> find a one-size-fits-all solution.
>>
>> If you can't modify the style or are sending your input files to Elsevier,
>> you might look into wrapping the doi field contents in a \url command (style
>> will be tricky here), or just export a minimal BibTeX file without doi and
>> send that.
>>
>> A final option if you can't modify the style would be to send the contents
>> of your .bbl file after you correctly handle doi (or just insert the
>> \bibitem commands to your document to produce camera-ready copy). IIRC some
>> publishers require this, as they won't use BibTeX.
>
>
> By the way, I encountered similar URL encoding issues some years ago when
> exporting citations to HTML with a BibDesk export template. As I recall, the
> problem was that I needed to translate some characters in URLs to HTML
> entities such as "&", ">", "<". I solved that particular problem by
> post-processing the exported HTML with a simple regex shell script.
>
> Nathan
>
> _______________________________________________
> Bibdesk-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/bibdesk-users
_______________________________________________
Bibdesk-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-users