1

Im trying to format på references using natbib, but somehow i always get big ugly looking gaps in my references. Any solutions to this? I have tried the version which i use "howpublished" and the "note".

@misc{trafikverket_2018,
author =    {{Trafikverket}},
title =     {{Granskningshandling} {E6.21} {Lundbyleden} delen {Brantingsmotet}–{Ringömotet}},
year =      {2018},
note =      {\url{https://www.trafikverket.se/contentassets/6e09cdddd92c4b7c84bbe584ff72b18d/1_plan_och_milljobeskrivning.pdf?fbclid=IwAR3BepAcid8YwBbAlk_MwWmverrtMrXRMW7JzFC1NHj2QwRlWwJCQ0hOAHY} {Hämtad den 9/2 - 2021}
}

\usepackage{natbib} \usepackage[hyphens]{url} \bibliographystyle{apalike} \bibliography{Referenser.bib}

enter image description here

  • 1
    https://tex.stackexchange.com/questions/115690/urls-in-bibliography-latex-not-breaking-line-as-expected – Johannes_B Feb 10 '21 at 08:12
  • 1
    URLs are hard to break (see Johannes_B's link above), but depending on your document language foreign words are also hard to break (if your document language is Swedish, you'd expect hyphenation to work for Swedish words, but names and proper nouns could still be an issue). – moewe Feb 10 '21 at 08:26
  • 1
    Note that your URL can be slightly shortened to https://www.trafikverket.se/contentassets/6e09cdddd92c4b7c84bbe584ff72b18d/1_plan_och_milljobeskrivning.pdf This might help a tiny bit. – moewe Feb 10 '21 at 08:28
  • What happens if you replace \usepackage[hyphens]{url} with \usepackage{xurl}? – Mico Feb 10 '21 at 09:43

1 Answers1

0

I would like to suggest that you replace \usepackage[hyphens]{url} with \usepackage{xurl}. That way, line breaks can occur anywhere in URL strings rather than just at hyphenation characters.

I would also break up the note field into two separate fields, with the URL string moving to a newly-created howpublished field.

enter image description here

\documentclass{article} % or some other suitable document class
\begin{filecontents}[overwrite]{Referenser.bib}
@misc{trafikverket_2018,
   author =    {Trafikverket},
   title =     {{Granskningshandling} {E6.21} {Lundbyleden} delen {Brantingsmotet}–{Ringömotet}},
   year =      {2018},
   howpublished = {\url{https://www.trafikverket.se/contentassets/6e09cdddd92c4b7c84bbe584ff72b18d/1_plan_och_milljobeskrivning.pdf?fbclid=IwAR3BepAcid8YwBbAlk_MwWmverrtMrXRMW7JzFC1NHj2QwRlWwJCQ0hOAHY}},
   note =      {Hämtad den 9/2 - 2021}
}
\end{filecontents}

\usepackage[T1]{fontenc} \usepackage[swedish]{babel} \usepackage{natbib} \bibliographystyle{apalike} \usepackage{xurl} % <-- new

\begin{document} \cite{trafikverket_2018} \bibliography{Referenser} \end{document}

Mico
  • 506,678
  • Oh, and please do give consideration to @moewe's suggestion to simplify and shorten the URL string by omitting the ?fbclid=IwAR3BepAcid8YwBbAlk_MwWmverrtMrXRMW7JzFC1NHj2QwRlWwJCQ0hOAHY substring. – Mico Feb 10 '21 at 10:01
  • Thank u! This worked perfectly, looks much nicer with this package. And yes i trimed the url to, thanks @moeve for noticing that – deluxetheo Feb 10 '21 at 14:08