I'm using the apacite
package and I'm trying in bibtex
to supress the url if the doi is available. I found an answer in the posting apacite: how to suppress url if doi is avalable?
It is exacty what I was looking for, but for some reason the hyperref
package is no longer of any help with the url's linebreaking as it used to (before I tried the answer). Can anyone help me fix this?
\documentclass[11pt,a4paper]{article}
\usepackage[latin1]{inputenc}
\usepackage[spanish]{babel}
\usepackage{hyperref}
%%%%%%%%%%%%%%%%%%%%%% The solution I'm using
\usepackage{filecontents}
\usepackage{apacite}
\usepackage{etoolbox}
\newtoggle{bibdoi}
\newtoggle{biburl}
\makeatletter
\newsavebox{\bib@url}
\newsavebox{\bib@doi}
\undef{\APACrefURL}
\undef{\endAPACrefURL}
\undef{\APACrefDOI}
\undef{\endAPACrefDOI}
\newenvironment{APACrefURL}
{\global\toggletrue{biburl}\lrbox\bib@url}
{\endlrbox}
\newenvironment{APACrefDOI}
{\global\toggletrue{bibdoi}\lrbox\bib@doi}
{\endlrbox}
\newcommand{\printinfo}{
\iftoggle{bibdoi}{\usebox{\bib@doi}}{\usebox{\bib@url}}
\togglefalse{bibdoi}
}
\AtBeginEnvironment{thebibliography}{
\pretocmd{\PrintBackRefs}{%
\iftoggle{bibdoi}
{\iftoggle{biburl}{\unskip\unskip}{}Doi: \usebox{\bib@doi}}
{\iftoggle{biburl}{Retrieved from \usebox{\bib@url}}}{}
\togglefalse{bibdoi}\togglefalse{biburl}%
}{}{}}
\makeatother
%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\nocite{*}
\bibliographystyle{apacite}
\bibliography{tesis}
\end{document}
And in tesis.bib
I have
@Article{allali,
Title = {{Linear} {Algebra} and Image Processing.},
Author = {Allali, Mohamed},
Journal = {International Journal of Mathematical Education in Science and Technology},
Year = {2010},
Url = {http://search.ebscohost.com/login.aspx?direct=true\&db=eric\&AN=EJ894161 \&lang=es\&site=eds-live}
}
@InProceedings{Alves,
Title = {Articulation problems between different systems of symbolic representations in {Linear} {Algebra}},
Author = {M. {Alves D{\'i}as} and M. Artigue},
Booktitle = {Proceeding of the 19th {International} {Conference} for the {Psychology} of {Mathematics} {Education}},
Year = {1995},
Url = {http://files.eric.ed.gov/fulltext/ED411135.pdf}
}
@Article{Aydin2,
Title = {The factors effecting teaching {Linear} {Algebra} },
Author = {Sinan Ayd{\i}n},
Journal = {Procedia - Social and Behavioral Sciences },
Year = {2009},
Note = {World Conference on Educational Sciences: New Trends and Issues in Educational Sciences },
Number = {1},
Pages = {1549--1553},
Volume = {1},
Doi = {10.1016/j.sbspro.2009.01.272},
Url = {http://www.sciencedirect.com/science/article/pii/S1877042809002754}
}
\documentclass{...}
and ending with\end{document}
.hyperref
. Instead, the line breaking isn't done because the contents of the url and doi field are placed in an LR box (which does not allow linebreaks).