1

Full Minimal Example Zip File

it's the first time I'm working with LaTex and I have some issues with the bibliography. For some references but not for all, the doi is strangely presented in a new row with a gap. How can I change that? I used a Springer template from here: https://www.springernature.com/gp/authors/campaigns/latex-author-support

Here are relevant information:

\documentclass[sn-apa]{sn-jnl}% APA Reference Style
\bibliography{sn-bibliography}
\bibliographystyle{sn-apacite}%

And here is a picture of the problem: enter image description here

And here are the entries in my .bib file:

@article{Cousineau2010, 
title={Outliers detection and treatment: a review.}, 
volume={3}, 
url={https://revistas.usb.edu.co/index.php/IJPR/article/view/844}, 
doi = {10.21500/20112084.844}, 
number={1}, 
journal={International Journal of Psychological Research}, 
author={Cousineau, Denis and Chartier, Sylvain}, 
year={2010}, 
pages={58–-67} 
}
@book{Cramer2008,
author = {Cramer, Henriette and Evers, Vanessa and Ramlal, Satyan and {Van Someren}, Maarten and Rutledge, Lloyd and Stash, Natalia and Aroyo, Lora and Wielinga, Bob},
booktitle = {User Modeling and User-Adapted Interaction},
doi = {10.1007/s11257-008-9051-3},
number = {5},
pages = {455--496},
title = {{The effects of transparency on trust in and acceptance of a content-based art recommender}},
volume = {18},
year = {2008},
}

The Cramer reference is of type book.I want no gap between the doi of Cousineau and the rest of the references. If I change the Cousineau reference in my .bib file from article to proceeding, the doi shows correctly. How can I change the settings of article references?

Here is potentially relevant code from the sn-jnl file (line 1685):

\if@APA@refstyle%   
\usepackage[natbibapa]{apacite}%   
\gdef\NumBib{NO}%   
\bibliographystyle{sn-apacite}%  
\def\refdoi#1{\urlstyle{rm}\url{#1}}%   
\renewcommand{\doiprefix}{}%   
\AtBeginDocument{%
\renewcommand{\BPBI}{.}% Period between initials - command from apacite.sty   }%   
\setlength{\bibsep}{1em}%  
\def\bibfont{\reset@font\fontfamily{\rmdefault}
\normalsize\selectfont}%

Please let me know if more information is needed to understand the issue.

Thanks a lot in advance.

14
  • 1
    Please provide a full but minimal example. You tex example is incomplete so we cannot just copy it and test as is. Additionally as sn-jnl is not a known class (it is not in TeXLive for example), please provide a link to it. Your example also does not provide any information as to which bibtex style is used. Does adding the xurl package help? Your problem is clearly the formating of the URL in Cousineau2010 and so we need to know exactly how that text is generated and that is not possible with the date you have provided so far.
    – daleif
    Commented Mar 6, 2023 at 16:36
  • Thank you very much for the comments and information. The link to the Springer LaTex template I used is here: springernature.com/gp/authors/campaigns/latex-author-support. Currently, I do not load any natbib or biblatex packages in my preamble. After I read your comment, I looked into the sn-jnl file. I found some code starting in line 1685 - I will update my original question.
    – Newcomer
    Commented Mar 14, 2023 at 8:32
  • I also figured out that if I change in my .bib file an article to a proceeding type, then the doi shows correctly. So I assume that somehow the specification of the setting for article references is not correct.
    – Newcomer
    Commented Mar 14, 2023 at 8:34
  • using the "xurl" package doesn't solve the problem
    – Newcomer
    Commented Mar 14, 2023 at 8:40
  • Additionally if you want help then please provide a full minimal example, not these sniplets. Note that if apacite is in use (it is not in your sniplet but might in the class, I haven't looked, then apacite changes the URL package (if loaded) at the start of the document. If neither your document or the class actually loads the url package, then you can get around this using \AtBeginDocument{\usepackage{xurl}} as it then (might) come later than the apacite changes. Problem is that apacite has not been updated since 2013 long before xurl arrived.
    – daleif
    Commented Mar 14, 2023 at 8:51

1 Answer 1

0

Too long for a comment.

Here is a nasty idea. If we look at the generated .bbl file we see

\begin{APACrefURL}
  {https://revistas.usb.edu.co/index.php/IJPR/article/view/844}
  \end{APACrefURL}

with the env being defined in apacite.sty as

\newenvironment{APACrefURL}[1][]{%
  \ifx\@empty#1\@empty
    \BRetrievedFrom % Retrieved from
  \else
    \BRetrieved{#1}%  Retrieved <date>, from
  \fi
}{}

which basically means that the URL part is never given any special formatting. Indeed if we change the URL in the example to contain a _ compilation fails.

But what if we could get the env to read the URL as an argument and then we control the formatting. This requires either a modern LaTeX installation or the xparse package.

\RenewDocumentEnvironment{APACrefURL}{ o m }{
  \IfNoValueTF{#1}{
    \BRetrievedFrom %
  }{
    \BRetrieved{#1} %
  }
  \url{#2}
}{}

This uses \url which is better than nothing.

It does seem that if we also add

\AtBeginDocument{\usepackage{xurl}}

then the URL formatting seems better (slightly better lines breaks, but I still don't think we get the break at any char that xurl might normally bring to the table)

Note that the code used is just the sn-article.tex template from the Springer link.

1
  • thanks a lot for your suggestions, I'll try that out!
    – Newcomer
    Commented Mar 22, 2023 at 14:14

You must log in to answer this question.

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