# How to modify a bibliography style to surround titles in quotes in a bibliography?

My advisor wants me to cause all titles for papers, books, and articles in " for my thesis in my bibliography.

I am using natbib and the plainnat bibliography style and am unsure how to do this. I am NOT asking how to do this or displaying a quote in the title, I want to make the title show " around it with capitalization being saved. I could go through and manually modify the .bib file I suppose...

Here is a working example:

\begin{filecontents}{mybib.bib}
@Article{Hart,
author = {P.E. Hart, N.J. Nilsson, B. Raphael},
title = {Correction to a Formal Basis for the Heuristic Determination of Minimum Cost Paths },
year = {1972},
pages = {28-29}
}
@Article{Hart2,
author = {P.E. Hart, N.J. Nilsson, B. Raphael},
title = { {Correction to a Formal Basis for the Heuristic Determination of Minimum Cost Paths''}  },
year = {1972},
pages = {28-29}
}
\end{filecontents}

\documentclass{report}
\usepackage[numbers,square]{natbib}
\begin{document}
\bibliographystyle{plainnat}

I don't want it to look like this reference \cite{Hart}

I want it to look like this \cite{Hart2}

\bibliography{mybib}

\end{document}


Is there a way to easily do this? I can always hack this by doing what I did for the second reference if not.

From reading this documentation nothing stands out to me as doing this?

-
You definitely shouldn't change your .bib file. It might be easiest to use makebst to create a new .bst file. From the command line, type latex makebst and follow the directions. There is an option for putting article titles in quotation marks. (You'll also probably want to put conference proceedings and technical reports in quotation marks as well.) –  Alan Munn Jun 23 '13 at 21:40
I just read your request more carefully. Does your advisor really want book titles to be in quotes? This is really unorthodox in most bibliography styles I know of (maybe it's standard in your field, however.) If so, my answer will need some modification. Book and journal titles are typically set in italics. –  Alan Munn Jun 23 '13 at 22:28
@AlanMunn Put the title of the paper, book or article within double quotes. I don't question things at the point where I'm just making revisions :) –  enderland Jun 23 '13 at 22:35
Ok, then I recommend you use my second method. I'll update my answer with a stern warning. :) –  Alan Munn Jun 23 '13 at 22:38

Whatever you do, don't modify your .bib file by adding the quotation marks there. This will cause you no end of trouble in the future. Here are two solutions.

## Use makebst

It's possible to the use makebst program to generate a new .bst file for yourself. To do this, you can open a command line window and type:

latex makebst


This will walk you through a whole bunch of menus of choices, including the following:

<many choices before>

<<TITLE OF ARTICLE:
(*) Title plain with no special font
(i) Title italic (\em)
(q) Title and punctuation in single quotes (Title,' ..)
(d) Title and punctuation in double quotes (Title,'' ..)
(g) Title and punctuation in guillemets (<<Title,>> ..)
(x) Title in single quotes (Title', ..)
(y) Title in double quotes (Title'', ..)
(z) Title in guillemets (<<Title>>, ..)
Select:

\ans=d
You have selected: Title and punctuation in double quotes

>>TITLE OF ARTICLE:

<<COLLECTION/PROCEEDINGS TITLES (if quoted title)
(*) Quote collection and proceedings titles too
(x) Collection and proceedings titles not in quotes
Select:

\ans=
You have selected: Quote collection and proceedings titles

<many choices after>


Then you just use this new .bst file for your thesis. You can put it in the same folder as the main .tex file of your thesis, or put it in your local texmf folder (on a TeXLive system is should go in <path-to-local-texmf>/texmf/bib/bst.

## Make a new .bst file which uses csquotes for quoting

Instead of doing things this way, if you are comfortable with editing your own copy of plainnat.bst here's a method which uses the csquotes package to do the quotation. This handles punctuation correctly and also allows you to easily change from single to double quotes if you need. It does involve some work, though, but probably will take less time than stepping through all the makebst choices (especially if you don't know what each one is asking.)

First, make a copy of plainnat.bst in the same folder of your .tex file and rename it (e.g. plainnat-csquotes.bst).

Now make the following changes/additions to that file:

First, we add a function format.atitle similar to the format.btitle function on line 432 of plainnat.bst:

FUNCTION {format.atitle}
{ title enquote
}


Next, we add an enquote function similar to the emphasize function on line 207 of plainnat.bst. Note that this uses the \textquote macro from the csquotes package, so this .bst file will require that package to be loaded. We are using the \textquote macro instead of the more general \enquote macro so that we can redefine it to place the punctuation correctly according to American standards (punctuation is always inside the quotation mark.)

FUNCTION {enquote}
{ duplicate$empty$
{pop$"" } {"\textquote{" swap$ * "}" * }
if$}  Finally we need to change any entry type that needs quotation marks around its title to use the format.atitle function instead of the format.title function. In my opinion, this should include (for consistency) the article, incollection, inproceedings, techreport, and unpublished entry types. If you search through the .bst file you will find a function for each of them. Here's the article function as an example: (before the change:) FUNCTION {article} { output.bibitem format.authors "author" output.check author format.key output new.block format.title "title" output.check new.block crossref missing$
{ journal emphasize "journal" output.check
eid empty${ format.vol.num.pages output } { format.vol.num.eid output } if$
format.date "year" output.check
}
{ format.article.crossref output.nonnull
eid empty${ format.pages output } { format.eid output } if$
}
if\$
format.issn output
format.doi output
format.url output
new.block
note output
fin.entry
}


We now change the line

format.title "title" output.check


to:

format.atitle "title" output.check


Do this for each of the other entry types listed above.

You now have a csquotes aware .bst file. To use it, you simply need to add the following lines to your preamble:

\usepackage{csquotes}
\bibliographystyle{plainnat-csquotes}


To implement correct placement of the punctuation with respect to the quotation mark we need to add the following extra line:

\renewcommand{\mktextquote}[6]{#1#2#4#5#3#6}


This will place the punctuation inside the quotation marks.

### Changing the format of book titles too

Your advisor has requested that book titles also use quotation marks. This is a very unorthodox style, and I don't recommend it at all, but if that's what he wants, it's easy enough to do. Simply find the format.btitle function and change it from:

FUNCTION {format.btitle}
{ title emphasize
}


to

FUNCTION {format.btitle}
{ title enquote
}

-
Very nice tutorial. +1 –  Harish Kumar Jun 23 '13 at 22:22
This is awesome, opened my eyes to a whole new world of LaTeX :) You know of a good way to stop the end of title". from being like that but rather end of title." ? –  enderland Jun 23 '13 at 22:55
@enderland Thanks for pointing that out. I've updated the answer. (Slight change to the .bst function and one extra line of code in the preamble.) –  Alan Munn Jun 23 '13 at 23:42