网址中换行

网址中换行

我正在使用该apacite软件包,如果 doi 可用,我会尝试bibtex隐藏 url。我在帖子中找到了答案apacite:如果 doi 可用,如何抑制 url?

这正是我所寻找的,但出于某种原因,该hyperref包不再像以前那样对 URL 的换行有帮助(在我尝试答案之前)。有人能帮我解决这个问题吗?

\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}

tesis.bib

@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}
}

答案1

解决方案apacite:如果 doi 可用,如何抑制 url?可以进行如下修改(需要environ包)。

\usepackage{apacite}
\usepackage{etoolbox}
\usepackage{environ}

\newtoggle{bibdoi}
\newtoggle{biburl}
\makeatletter

\undef{\APACrefURL}
\undef{\endAPACrefURL}
\undef{\APACrefDOI}
\undef{\endAPACrefDOI}

\long\def\collect@url#1{\global\def\bib@url{#1}}
\long\def\collect@doi#1{\global\def\bib@doi{#1}}
\newenvironment{APACrefURL}{\global\toggletrue{biburl}\Collect@Body\collect@url}{\unskip\unskip}
\newenvironment{APACrefDOI}{\global\toggletrue{bibdoi}\Collect@Body\collect@doi}{}

\AtBeginEnvironment{thebibliography}{
 \pretocmd{\PrintBackRefs}{%
  \iftoggle{bibdoi}
    {\iftoggle{biburl}{\unskip\unskip doi:\bib@doi}{}}
    {\iftoggle{biburl}{Retrieved from\bib@url}{}}
  \togglefalse{bibdoi}\togglefalse{biburl}%
  }{}{}
}

不同之处在于,我们使用提供的设施environ(即)来存储用于包装和字段内容的\Collect@Body两个环境上的内容。apacitedoiurl

在此处输入图片描述

相关内容