2

I want to cite and format the bibliographic references according to APA style. So I tried:

    \documentclass[12pt,a4paper,twoside]{article}
    \usepackage{amsmath}
    \usepackage{setspace}
    \usepackage{apacite}
    \begin{document}
    \title{blabla}
        \author{blabla}
        \date{\today}
        \maketitle
    \cite{delistraty_2014}

    \bibliographystyle{apacite}
    \bibliography{ref.bib}
    \end{document}

But the output of the reference list seems weird Spaces are totally wrong, and the hyperlink of the website has a strange font.

So what can I do to solve it out?

1
  • Welcome to TeX.SE. You need to load the url package and/or the hyperref package in order to enable line breaks in long URL strings.
    – Mico
    Feb 26, 2018 at 8:56

2 Answers 2

2

To typeset long URL strings, it's a good idea to load the url package and/or the hyperref package. That way, LaTeX is much more likely to "find" permissible line break opportunities.

enter image description here

\RequirePackage{filecontents}
\begin{filecontents}{ref.bib}
@misc{delistraty_2014,
  author = "Cody C. Delistraty",
  title  = "The Beauty-Happiness Connection",
  year   = 2014,
  month  = "Aug.",
  howpublished = "Atlantic Media Co.", 
  url    = "https://www.theatlantic.com/health/archive/2014/08/the-beautyhappiness-connection/375678/",
}
\end{filecontents}

\documentclass[12pt,a4paper,twoside]{article}
\usepackage{apacite}
\bibliographystyle{apacite}
\usepackage[hyphens,spaces,obeyspaces]{url}

\begin{document}
\cite{delistraty_2014}
\bibliography{ref}
\end{document} 
6
  • If you want the URL string to use the main text font instead of a monospaced font, just issue the directive \urlstyle{same} after loading the url package.
    – Mico
    Feb 26, 2018 at 9:27
  • Yes, it works. Thanks very much! Another problem is what if I want the url in the reference to be a hyperlink? What should I do, instead of "\cite{xxxxx}"?
    – user155860
    Feb 26, 2018 at 15:36
  • @user155860 - If you want to enable hyperlinking of URL strings, you must load the hyperref package.
    – Mico
    Feb 26, 2018 at 15:43
  • However, if I use "hyperref" package, I can't use \cite{xxx} command. So what should I do?
    – user155860
    Mar 4, 2018 at 8:57
  • 1
    Yes,hyperref going after url solves the problem. Thank you!
    – user155860
    Mar 5, 2018 at 9:16
1

Loading the xurl-package should solve the problem:

\RequirePackage{filecontents}
\begin{filecontents}{ref.bib}
@misc{delistraty_2014,
  author = "Cody C. Delistraty",
  title  = "The Beauty-Happiness Connection",
  year   = 2014,
  month  = "Aug.",
  howpublished = "Atlantic Media Co.", 
  url    = "https://www.theatlantic.com/health/archive/2014/08/the-beautyhappiness-connection/375678/",
}
\end{filecontents}
    
    \documentclass[12pt,a4paper,twoside]{article}
    \usepackage{amsmath}
    \usepackage{setspace}
    \usepackage{apacite}
    \usepackage{xurl}
    \begin{document}
    \title{blabla}
        \author{blabla}
        \date{\today}
        \maketitle
    \cite{delistraty_2014}

    \bibliographystyle{apacite}
    \bibliography{ref.bib}
    \end{document}

The compilde document

2
  • 1
    Welcome to TeX.SE! You could improve your answer if you try it out and share your MWE and your result which shows that your recommendation really solves the problem. Mar 4, 2023 at 14:49
  • 1
    Thankx a bunch @Οὖτις, just did that
    – mittens
    Mar 4, 2023 at 15:12

You must log in to answer this question.

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