GeneralBrackets around words in .bib files

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
vertebraille
Posts: 3
Joined: Sat Dec 28, 2019 9:23 am

Brackets around words in .bib files

Post by vertebraille »

My bibliography (using natbib and a .bib file) often contains large amounts of spacing between words. I am typically generating my .bib file from a Zotero library and entries are often added via the "wizard" by entering the DOI or using the browser extension. Looking at the .bib file, it looks like the culprit is probably the use of curly brackets around seemingly random words in each entry.

Is there some way to either ignore the brackets or fix this in Zotero? Minimal example of what a document and the corresponding .bib file looks like to reproduce the spacing found below.

Code: Select all

% .tex file
\documentclass[]{article}
\usepackage[round]{natbib} 

\begin{document}

Here is a cite \citep{obamaRemarksPresidentCampaign2012}.

\bibliographystyle{plainnat}
\bibliography{references/refs_bib}

\end{document}

Code: Select all

% .bib file
@misc{obamaRemarksPresidentCampaignn2012,
	address = {Roanoke},
	type = {Transcript},
	title = {Remarks by the {President} at a {Campaignn} {Event} in {Roanoke}, {Virginia}},
	url = {https://obamawhitehouse.archives.gov/the-press-office/2012/07/13/remarks-president-campaign-event-roanoke-virginia},
	author = {Obama, Barack},
	month = jul,
	year = {2012},
}

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
Stefan Kottwitz
Site Admin
Posts: 10322
Joined: Mon Mar 10, 2008 9:44 pm

Brackets around words in .bib files

Post by Stefan Kottwitz »

Some bibliography styles convert titles to lowercase, so "Remarks by the President at a Campaign Event in Roanoke, Virginia" would become "Remarks by the president at a campaign event in roanoke, virginia". The additional curly braces are for protecting the original capitalization.

The bad spacing is still there without braces, click on "Run LaTeX here" to see it:

Code: Select all

\begin{filecontents}[force]{refs_bib.bib}
@misc{obamaRemarksPresidentCampaign2012,
	address = {Roanoke},
	type = {Transcript},
	title = {Remarks by the President at a Campaign Event in Roanoke, Virginia},
	url = {https://obamawhitehouse.archives.gov/the-press-office/2012/07/13/remarks-president-campaign-event-roanoke-virginia},
	author = {Obama, Barack},
	month = jul,
	year = {2012},
}
\end{filecontents}
% .tex file
\documentclass[]{article}
\usepackage[round]{natbib} 

\begin{document}

Here is a cite \citep{obamaRemarksPresidentCampaign2012}.

\bibliographystyle{plainnat}
\bibliography{refs_bib}

\end{document}
Long URLs can be a problem. You can allow LaTeX to break URLs in this way:

Code: Select all

\usepackage{url}
\def\UrlBreaks{\do\/\do-}
You can declare additional characters where line breaks would be allowed by using \do repeatedly as above.

Run this example to see it:

Code: Select all

\begin{filecontents}[force]{refs_bib.bib}
@misc{obamaRemarksPresidentCampaign2012,
	address = {Roanoke},
	type = {Transcript},
	title = {Remarks by the President at a Campaign Event in Roanoke, Virginia},
	url = {https://obamawhitehouse.archives.gov/the-press-office/2012/07/13/remarks-president-campaign-event-roanoke-virginia},
	author = {Obama, Barack},
	month = jul,
	year = {2012},
}
\end{filecontents}
\documentclass[]{article}
\usepackage[round]{natbib} 
\usepackage{url}
\def\UrlBreaks{\do\/\do-}
\begin{document}

Here is a cite \citep{obamaRemarksPresidentCampaign2012}.

\bibliographystyle{plainnat}
\bibliography{refs_bib}

\end{document}
I recommend adding \usepackage{microtype} for better justification.

If you still want to change it in Zotero, take a look here: Prevent extra braces in BibTeX export. There are hidden preferences you can set. (extensions.zotero.BibTeX.export.dontProtectInitialCase)

Stefan
LaTeX.org admin
Post Reply