From acd3936e5487db77efbf7055aaf6ec6b4109e9f9 Mon Sep 17 00:00:00 2001
From: Dorchies David <david.dorchies@irstea.fr>
Date: Thu, 10 Aug 2017 16:59:42 +0200
Subject: [PATCH] =?UTF-8?q?Correction=20lien=20hypertexte=20des=20r=C3=A9f?=
 =?UTF-8?q?=C3=A9rences=20(nom,=20date)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 rapport_francais/preambule_biblatex.tex       | 51 +++++++++++++++++++
 .../preambule_rapport_francais.tex            | 13 +----
 2 files changed, 52 insertions(+), 12 deletions(-)
 create mode 100644 rapport_francais/preambule_biblatex.tex

diff --git a/rapport_francais/preambule_biblatex.tex b/rapport_francais/preambule_biblatex.tex
new file mode 100644
index 0000000..6c8783e
--- /dev/null
+++ b/rapport_francais/preambule_biblatex.tex
@@ -0,0 +1,51 @@
+% Gestion de la bibliographie avec biblatex
+\usepackage[
+	backend=bibtex, 
+	style=authoryear,
+	firstinits=true,
+	natbib=true
+]{biblatex}
+\addbibresource{biblio.bib}
+%Line breaks of long URLs in biblatex bibliography http://tex.stackexchange.com/a/134281
+\setcounter{biburllcpenalty}{7000}
+\setcounter{biburlucpenalty}{8000}
+% Line break for DOI http://tex.stackexchange.com/a/50958/124910
+\setcounter{biburlnumpenalty}{100}
+
+
+% hyperlink name with biblatex authoryear
+% https://tex.stackexchange.com/a/27107/124910
+
+\DeclareFieldFormat{citehyperref}{%
+  \DeclareFieldAlias{bibhyperref}{noformat}% Avoid nested links
+  \bibhyperref{#1}}
+
+\DeclareFieldFormat{textcitehyperref}{%
+  \DeclareFieldAlias{bibhyperref}{noformat}% Avoid nested links
+  \bibhyperref{%
+    #1%
+    \ifbool{cbx:parens}
+      {\bibcloseparen\global\boolfalse{cbx:parens}}
+      {}}}
+
+\savebibmacro{cite}
+\savebibmacro{textcite}
+
+\renewbibmacro*{cite}{%
+  \printtext[citehyperref]{%
+    \restorebibmacro{cite}%
+    \usebibmacro{cite}}}
+
+\renewbibmacro*{textcite}{%
+  \ifboolexpr{
+    ( not test {\iffieldundef{prenote}} and
+      test {\ifnumequal{\value{citecount}}{1}} )
+    or
+    ( not test {\iffieldundef{postnote}} and
+      test {\ifnumequal{\value{citecount}}{\value{citetotal}}} )
+  }
+    {\DeclareFieldAlias{textcitehyperref}{noformat}}
+    {}%
+  \printtext[textcitehyperref]{%
+    \restorebibmacro{textcite}%
+    \usebibmacro{textcite}}}
\ No newline at end of file
diff --git a/rapport_francais/preambule_rapport_francais.tex b/rapport_francais/preambule_rapport_francais.tex
index 1709d09..d283e71 100644
--- a/rapport_francais/preambule_rapport_francais.tex
+++ b/rapport_francais/preambule_rapport_francais.tex
@@ -21,18 +21,7 @@
 \renewcommand{\mkbegdispquote}[2]{\itshape}
 
 % Gestion de la bibliographie avec biblatex
-\usepackage[
-	backend=bibtex, 
-	style=authoryear,
-	firstinits=true,
-	natbib=true
-]{biblatex}
-\addbibresource{biblio.bib}
-%Line breaks of long URLs in biblatex bibliography http://tex.stackexchange.com/a/134281
-\setcounter{biburllcpenalty}{7000}
-\setcounter{biburlucpenalty}{8000}
-% Line break for DOI http://tex.stackexchange.com/a/50958/124910
-\setcounter{biburlnumpenalty}{100}
+\input{rapport_francais/preambule_biblatex}
 
 
 % Extra space for numbered titles in table of contents 
-- 
GitLab