1

Problem

I want the URLs displayed in my bibliography to have the same font, size and colour as the rest of my text. I am using the natbib citation management package and the elsarticle-harv bibliography style.

enter image description here

Furthermore I wondered if it is possible to change to complete font of the bibliography, as I like the else-harv referencing style I would like to only adapt it to my text font.

An example of my latex Code:

documentclass[11pt,twoside,english,openright, bibliography=totoc]{scrreprt}
\usepackage{helvet}
\renewcommand{\familydefault}{\sfdefault}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage[a4paper]{geometry}
\geometry{verbose,tmargin=2.5cm,bmargin=2.5cm,lmargin=2.75cm,rmargin=2.5cm,headheight=18pt,headsep=8pt,footskip=26pt}
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}
\setlength{\parskip}{\smallskipamount}
\setlength{\parindent}{0pt}
\usepackage{verbatim}
\usepackage{textcomp}
\usepackage{amstext}
\usepackage{graphicx}
\usepackage{setspace}
\usepackage[authoryear]{natbib}
\usepackage{nomencl}
% the following is useful when we have the old nomencl.sty package
\providecommand{\printnomenclature}{\printglossary}
\providecommand{\makenomenclature}{\makeglossary}
\makenomenclature
\onehalfspacing

\makeatletter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
\usepackage{lscape} 
{scrpage2} &oldpackage
\usepackage[automark, headsepline, footsepline, plainfootsepline]{scrlayer-scrpage}
\pagestyle{scrheadings}
\clearpairofpagestyles
\ohead{\headmark}
\ifoot[Test]{Test}
\cfoot[]{}
\ofoot[\pagemark]{\pagemark}
\ihead[]{}
\chead[]{}
\automark[chapter]{chapter} %rechte Seite erst dann Linke Seite
\usepackage{pdfpages}
\renewcommand\nomname{List of Acronyms}


\RedeclareSectionCommand[beforeskip=12pt,afterskip=12pt]{chapter}
\setkomafont{chapter}{\sffamily\LARGE}
\RedeclareSectionCommand[beforeskip=12pt,afterskip=10pt]{section}
\RedeclareSectionCommand[beforeskip=12pt,afterskip=8pt]{subsection}
\RedeclareSectionCommand[beforeskip=-12pt,afterskip=8pt]{paragraph}
\setkomafont{paragraph}{\sffamily\normalsize}

\usepackage {blindtext} 

\setkeys{Gin}{width=\textwidth} 
\raggedbottom
\usepackage[section]{placeins} 
\usepackage {media9} 
\usepackage[hyphens]{url}
\usepackage[colorlinks=true, urlcolor=blue, linkcolor=black,  citecolor=black]{hyperref} %gibt Bookmarks in bestimmter Farbe wieder

\@ifundefined{showcaptionsetup}{}{%
 \PassOptionsToPackage{caption=false}{subfig}}
\usepackage{subfig}
\makeatother

\usepackage{babel}
\begin{document}

\bibliographystyle{elsarticle-harv}
\nocite{*}
\bibliography{_bib}

\end{document}
  • A separate comment: Since "Dijkstra" is the surname of a person, it shouldn't be lowercased even when it occurs in the title field of an entry. To keep BibTeX from converting Dijkstra to dijkstra -- as is done in the screenshot you posted -- encase it in a pair of curly braces, i.e., enter it in the title field as ... for {Dijkstra's} algorithm.... – Mico Aug 25 '16 at 13:09
3

First, you should add the instruction \urlstyle{same} to the preamble, immediately after loading the url package.

Second, you should change the option urlcolor=blue to urlcolor=black while loading the hyperref package.


Addendum to address the OP's follow-up question, on how to insert a colon after the string URL. I suggest you proceed as follows:

  • Find the file elsarticle-harv.bst in your TeX distribution. Make of a copy of this file and call the copy, say, elsarticle-harv-colon.bst. Do not edit an original file of the TeX distribution directly.

  • Open the file elsarticle-harv-colon.bst in a text editor. The one you use to edit your tex files will do fine.

  • Find the the string

    "\expandafter\ifx\csname urlprefix\endcsname\relax\def\urlprefix{URL }\fi"
    

    (It is located on line 1519 in my copy of the file.)

  • In this line, change \urlprefix{URL } to \urlprefix{URL: }.

  • Save the new bibliography style file either in the directory where you main tex file is located or in a directory that's searched by your TeX distribution. If you choose the second option, be sure to update the filename database of your TeX distribution suitably.

  • In your main tex file, change

    \bibliographystyle{elsarticle-harv}
    

    to

    \bibliographystyle{elsarticle-harv-colon}
    
  • Rerun LaTeX, BibTeX, and LaTeX twice more to fully propagate all changes.

Happy BibTeXing!

  • Is it also somehow possible to gete a colon after the URL in the bibliography ? And thanks for the first answer! :) – KiW Aug 25 '16 at 13:12
  • @KiW - You're welcome. I've posted an addendum to explain how to go about modifying the bibliography style file to get a colon after the string URL. – Mico Aug 25 '16 at 13:33
  • thanks for all the help, one last question - how can I include something after the URL like "Accessed: Date" ? – KiW Aug 25 '16 at 18:24
  • @KiW - Please post a new query to ask the new question. (Aside: The solution will require performing some not-insignificant surgery on the bst file.) – Mico Aug 25 '16 at 18:40
  • tex.stackexchange.com/questions/326761/… would be awesome if you could have a look at this! Would really appreciate some help! – KiW Aug 28 '16 at 9:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.