# Editing bst file to underline title

I could not find an option in makebst that would make the titles of articles be underlined, however, using emphasize in an otherwise correct bst I was able to underline it. Unfortunately this makes the resulting underlined text get outside the margins. My code is

\documentclass[10pt,oneside,letterpaper,spanish]{book}
\usepackage[utf8x]{inputenc}
\usepackage[activeacute,spanish]{babel}
\decimalpoint %\spanishdecimal{.}

\usepackage[spanish]{babel}
\usepackage{natbib}

\begin{document}
asdasd \citep{chsh_inequality} asdasd \citep*{aspect_test_bell}
\bibliography{ejem_biblio}

\end{document}


and my bib file is

% This file was created with JabRef 2.5. % Encoding: Cp1252

@ARTICLE{chsh_inequality,
author = {{Clauser}, J.~F. and {Horne}, M.~A. and {Shimony}, A. and {Holt}, R.~A.
},
title = "{Proposed Experiment to Test Local Hidden-Variable Theories}",
journal = {Physical Review Letters},
year = 1969,
month = oct,
volume = 23,
number = 15,
pages = {880-884},
doi = {10.1103/PhysRevLett.23.880},
adsnote = {Provided by the SAO/NASA Astrophysics Data System}
}

@ARTICLE{aspect_test_bell,
author = {{Aspect}, A. and {Grangier}, P. and {Roger}, G.},
title = "{Experimental Tests of Realistic Local Theories via Bell's Theorem}",
journal = {Physical Review Letters},
keywords = {Fluorescence, phosphorescence},
year = 1981,
month = aug,
volume = 47,
number = 15,
pages = {460-463},
doi = {10.1103/PhysRevLett.47.460},
adsnote = {Provided by the SAO/NASA Astrophysics Data System}
}


The bst file I generated with makebst is http://pastebin.com/ji5d4vrx. On line 527 replacing { title with { emphasize title makes the titles become underlined, but they come outside of the margins. like this

How could I fix the margins? Also, how to add the missing spaces between the authors and the title and between the title and the year?

-
Underlining is a sure sign of bad typography; please, don't do it. –  egreg Jan 5 '13 at 11:41
But I absolutely have to. –  Oscar Lazo Jan 5 '13 at 11:44
In this case look at what the soul package provides. –  egreg Jan 5 '13 at 11:46
But that is meant for use in the body of the document, how can I make it work through a bst? –  Oscar Lazo Jan 5 '13 at 12:12
If I make the change you propose, I get that the author list is underlined. –  egreg Jan 5 '13 at 13:28

I suggest you to revise your .bst file. For instance, change lines 1574--1575 into

  write$newline$
"\expandafter\ifx\csname bbluline\endcsname\relax\let\bbluline\underline\fi"


and in your TeX file write

\usepackage{ulem}
\def\bbluline#1{\uline#1}


Also the definition of \enquote should be changed: lines 1572-1573 should be

  write$newline$
"\newcommand{\enquote}[1]{~#1'\ }"


Moreover, line 197 must be changed as

    { "\bbluline{" swap$* "}" * }  (that is, changing \uline into \bbluline). Of course, line 527 should become 526 FUNCTION {format.title} 527 { title emphasize 528 "title" bibinfo.check  that is, removing also add.blank. - That will produce a similar result, the underlined text goes on until it reaches the margins. – Oscar Lazo Jan 5 '13 at 15:35 @OscarLazo Not in my experiment. Actually the plain \uline from ulem would work if you didn't enclose the full title in the additional pair of braces. – egreg Jan 5 '13 at 15:36 Could you post your code? I'm pretty sure I did just what you suggested. – Oscar Lazo Jan 5 '13 at 15:58 @OscarLazo Sorry, I forgot the change on line 197, where \uline should become \bbluline – egreg Jan 5 '13 at 16:10 I tried with just \usepackage{ulem} \def\bbluline#1{\uline#1} in the tex file and "\enquote{ \uline" swap$ * in line 531 –  Oscar Lazo Jan 5 '13 at 16:14

write into the preamble of your document

\usepackage{soul}


and change the title function in your bst file to

FUNCTION {format.title}
duplicate$empty$ 'skip${ "\enquote{\ul{" swap$ *
if$} if$

what is a typo? If I do what you suggest I get an error after pdflatex bibtex pdflatex: Package soul Error: Reconstruction failed` –  Oscar Lazo Jan 5 '13 at 16:01