2

I don't this this is correct:

![enter image description here]1

The word spacing for the first entries seems wrong, the first in particular.

Here's the MWE:

\documentclass[a4paper,11pt]{article}
\usepackage{natbib}
\bibpunct[, ]{(}{)}{;}{a}{,}{,}
\usepackage[british]{babel}
\usepackage{url}
\usepackage{hyperref}
\begin{document}
        \cite{stoptheclot:2008} \cite{wiki:xxx} \cite{stoptheclot2:2008}
        \pagebreak
        \bibliographystyle{apalike}
        \bibliography{bibfile}
\end{document}

The .bib file is:

% Encoding: UTF-8
@misc{wiki:xxx,
     author = "{Wikipedia contributors}",
     title = "LaTeX --- {Wikipedia}{,} The Free Encyclopedia",
     year = "2011",
     howpublished = "\url{https://en.wikipedia.org/w/index.php?title=LaTeX&oldid=413720397}",
note = "Viewed 12th November 2018."
}

@misc{stoptheclot:2008,
    author = "{stoptheclot contributors}",
    title = "Vitamin K and Coumadin - What you need to Know. [online]",
    year = "2008",
    note = "Viewed 12th November 2018.",
    howpublished = "\url{https://www.stoptheclot.org/news/vitamin-k-and-coumadin-what-you-need-to-know}"
    }   

@misc{stoptheclot2:2008,
    author = "{Stoptheclot contributors}",
    title = "Vitamin K and Coumadin - What you need to",
    year = "2008",
    note = "Viewed 12th November 2018.",
    howpublished = "\url{https://www.stoptheclot.org/news/vitamin-k-and-coumadin-what-you-need-to-know}"
}

Is there any way I can control the spacing of the references (preferably left justified)?

3
  • Try the xurl package Nov 20, 2018 at 15:13
  • If you want your text left aligned, you could use \raggedright before your bibliography, but this will still give strange line breaks within the url, so I suggest the xurl package Nov 20, 2018 at 15:16
  • xurl works a treat.
    – Paul McG
    Nov 20, 2018 at 15:18

1 Answer 1

2

The xurl package can be used to add more possible breaking points to the urls:

\documentclass[a4paper,11pt]{article}
\usepackage{natbib}
\bibpunct[, ]{(}{)}{;}{a}{,}{,}
\usepackage[british]{babel}
\usepackage{url}
\usepackage{hyperref}


\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
% Encoding: UTF-8
@misc{wiki:xxx,
     author = "{Wikipedia contributors}",
     title = "LaTeX --- {Wikipedia}{,} The Free Encyclopedia",
     year = "2011",
     howpublished = "\url{https://en.wikipedia.org/w/index.php?title=LaTeX&oldid=413720397}",
note = "Viewed 12th November 2018."
}

@misc{stoptheclot:2008,
    author = "{stoptheclot contributors}",
    title = "Vitamin K and Coumadin - What you need to Know. [online]",
    year = "2008",
    note = "Viewed 12th November 2018.",
    howpublished = "\url{https://www.stoptheclot.org/news/vitamin-k-and-coumadin-what-you-need-to-know}"
    }   

@misc{stoptheclot2:2008,
    author = "{Stoptheclot contributors}",
    title = "Vitamin K and Coumadin - What you need to",
    year = "2008",
    note = "Viewed 12th November 2018.",
    howpublished = "\url{https://www.stoptheclot.org/news/vitamin-k-and-coumadin-what-you-need-to-know}"
}
\end{filecontents*}

\usepackage{xurl}

\begin{document}
        \cite{stoptheclot:2008} \cite{wiki:xxx} \cite{stoptheclot2:2008}
        \pagebreak
        \bibliographystyle{apalike}
        \bibliography{\jobname}
\end{document}

enter image description here

2
  • Replacing \usepackage{url} with \usepackage{xurl} works too.
    – Paul McG
    Nov 20, 2018 at 15:33
  • @Paul Even in the example in your question, you don't need the url package, because you load hyperref Nov 20, 2018 at 15:34

You must log in to answer this question.

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