8

Anybody knows how to lock the back reference at the top left corner of the bibliography entry by employing BibTeX? The result should be like this:

enter image description here

It works to me when using \bibitem (yes, it goes there automatically) but not through a .bib file.

Here it is my code:

\documentclass[a4paper,12pt]{book}                                                          
\usepackage[spanish]{babel}                                                                         
\usepackage[T1]{fontenc}                                                                                
\usepackage{latexsym}                                                                                       
\usepackage{lettrine}                                                                                       
\usepackage[latin1]{inputenc}                                                                       
\usepackage{setspace}                                                                                       
\spanishdecimal{.}                                                                                          
\usepackage[usenames,dvipsnames]{xcolor}
\usepackage{eso-pic}
\usepackage{everyshi}
\usepackage{pdfpages}

\usepackage[round]{natbib}
\bibliographystyle{plainnat}    
\usepackage[backref=page,citecolor=MidnightBlue,linkcolor=MidnightBlue]{hyperref}
\hypersetup{colorlinks=true,plainpages=false}
\usepackage{etoolbox}


%backref edit. this part is thanks to [lockstep](http://tex.stackexchange.com/questions/36307/formatting-back-references-in-bibliography)

\makeatletter

\patchcmd{\BR@backref}{\newblock}{\newblock p.~}{}{}
\patchcmd{\BR@backref}{\par}{\par}{}{}


%all-in-one hyperlink ([D.Roepo](http://tex.stackexchange.com/questions/115039/single-link-in-author-year-citation-style-using-natbib-and-hyperref))

\pretocmd{\NAT@citex}{%
  \let\NAT@hyper@\NAT@hyper@citex
  \def\NAT@postnote{#2}%
  \setcounter{NAT@total@cites}{0}%
  \setcounter{NAT@count@cites}{0}%
  \forcsvlist{\stepcounter{NAT@total@cites}\@gobble}{#3}}{}{}
\newcounter{NAT@total@cites}
\newcounter{NAT@count@cites}
\def\NAT@postnote{}

% include postnote and \citet closing bracket in hyperlink
\def\NAT@hyper@citex#1{%
  \stepcounter{NAT@count@cites}%
  \hyper@natlinkstart{\@citeb\@extra@b@citeb}#1%
  \ifnumequal{\value{NAT@count@cites}}{\value{NAT@total@cites}}
    {\ifNAT@swa\else\if*\NAT@postnote*\else%
     \NAT@cmt\NAT@postnote\global\def\NAT@postnote{}\fi\fi}{}%
  \ifNAT@swa\else\if\relax\NAT@date\relax
  \else\NAT@@close\global\let\NAT@nm\@empty\fi\fi% avoid compact citations
  \hyper@natlinkend}
\renewcommand\hyper@natlinkbreak[2]{#1}

% avoid extraneous postnotes, closing brackets
\patchcmd{\NAT@citex}
  {\ifNAT@swa\else\if*#2*\else\NAT@cmt#2\fi
   \if\relax\NAT@date\relax\else\NAT@@close\fi\fi}{}{}{}
\patchcmd{\NAT@citex}
  {\if\relax\NAT@date\relax\NAT@def@citea\else\NAT@def@citea@close\fi}
  {\if\relax\NAT@date\relax\NAT@def@citea\else\NAT@def@citea@space\fi}{}{}

\makeatother

\usepackage{float}                                                                                          
\usepackage{epstopdf}                                                                               
\usepackage{amsmath,amsbsy,amsfonts,amssymb,amscd,fancyhdr}                                                 
\DeclareGraphicsExtensions{.jpg,.pdf,.png,.gif,.eps}                                                        
\usepackage{rotating}                                                                                       
\usepackage{longtable}                                                                                      
\usepackage{chngpage}                                                                                       
\usepackage{anysize} 
\usepackage{geometry}
\usepackage{aecompl}

\newcommand\BackgroundPic{
\put(0,0){
\parbox[b][\paperheight]{\paperwidth}{
\vfill
\centering

\vfill
}}}


\begin{document}


As it is said in \citet{trigo00} and \citet{venus}...   

\mainmatter                                                                     


{\refname}                                                  
\addcontentsline{toc}{part}{Bibliografía}



%%%%%%%% B1 (bibliography according to bibitems) %%%%%%%%%%%%%%%

\begin{thebibliography}{999}\bibliographystyle{plainnat}\label{biblio}

\bibitem[Svedhem et al.(2007)]{venus}

Svedhem, Hakan; Titov, Dmitry V.; Taylor, Fredric V.; Witasse, Oliver (2007). ``Venus     as a more Earth-like planet''. Nature 450 (7170): 629-632.

\bibitem[Trigo y DaCamara(2000)]{trigo00}

R. M. Trigo and C. C. DaCamara, ``Circulation weather types and their influence on    the precipitation regime in Portugal'', {\em International Journal of Climatology}, vol. 20, pp. 1559-1581, 2000.

\end{thebibliography}  
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%%%%%%% B2 (Bibliography according to Bibtex) %%%%%%%%%%%
     %     \bibliography{my_bib_file}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


\end{document}  

my_bib_file.bib:

@article

{venus,
title={Venus as a more Earth-like planet.},
author={Svedhem, H. and Titov, D.V. and Taylor, F.W. and Witasse, O.},
journal={Nature},
volume={450},
number={7170},
pages={629-32},
year={2007},
}



@article {trigo00,
author = {Trigo, Ricardo M. and DaCamara, Carlos C.},
title = {Circulation weather types and their influence on the precipitation regime in  Portugal},
journal = {International Journal of Climatology},
volume = {20},
number = {13},
publisher = {John Wiley & Sons, Ltd.},
pages = {1559--1581},
keywords = {atmospheric circulation variability, droughts, Portugal, precipitation,    weather typing},
year = {2000},
}

If B1 is commented and B2 enabled, the backref goes to the end of the bibliography entry, like this (I need the format at the top but with BibTeX):

enter image description here

2
  • 3
    Can you please show us the compilable code you have just now?
    – Mensch
    Aug 30 '13 at 1:21
  • I think now it's fine, here you are.
    – callogher
    Aug 31 '13 at 19:12
2

It appears that a blank line is needed after each \bibitem. This is also suggested in the manual of hyperref, in the section "Extension options" (backref). The thebibliography environment in your example has those blank lines, but BibTeX with plainnat.bst does not add the corresponding blank lines to the .bbl file it produces.

I don't know if a more elegant solution exists, but one way to force the blank lines is to make a local copy of plainnat.bst and modify a function called output.bibitem defined in the file.

  1. Locate the original file (kpsewhich plainnat.bst)

  2. Make a copy of it, for example to the directory where the document is located. If the copy has the same name as the original, it will be seen by all documents in the same directory using \bibliographystyle{plainnat}.

  3. Edit the copy, changing the final newline$ inside the definition of output.bibitem to newline$ newline$, i.e. adding one newline$. The definition can be found by searching for the string FUNCTION {output.bibitem}.

The result:

Picture of result with modified bibliography style

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.