From 9053214fba2b4be05102f2f46157733e63947f92 Mon Sep 17 00:00:00 2001
From: John MacFarlane <jgm@berkeley.edu>
Date: Mon, 21 Mar 2022 10:42:18 -0700
Subject: [PATCH] LaTeX template: Move urlstyle and xurl commands to after
 hyperref.

Closes #7978.
---
 data/templates/default.latex    | 4 ++--
 test/lhs-test.latex             | 4 ++--
 test/lhs-test.latex+lhs         | 4 ++--
 test/writer.latex               | 4 ++--
 test/writers-lang-and-dir.latex | 4 ++--
 5 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/data/templates/default.latex b/data/templates/default.latex
index f77be2fa0..7d539fe02 100644
--- a/data/templates/default.latex
+++ b/data/templates/default.latex
@@ -210,8 +210,6 @@ $if(verbatim-in-note)$
 \usepackage{fancyvrb}
 $endif$
 \usepackage{xcolor}
-\IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available
-\urlstyle{same} % disable monospaced font for URLs
 $if(geometry)$
 $if(beamer)$
 \geometry{$for(geometry)$$geometry$$sep$,$endfor$}
@@ -378,6 +376,8 @@ $if(csquotes)$
 \usepackage{csquotes}
 $endif$
 \IfFileExists{bookmark.sty}{\usepackage{bookmark}}{\usepackage{hyperref}}
+\IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available
+\urlstyle{same} % disable monospaced font for URLs
 $if(verbatim-in-note)$
 \VerbatimFootnotes % allow verbatim text in footnotes
 $endif$
diff --git a/test/lhs-test.latex b/test/lhs-test.latex
index a83e31202..49521d3c1 100644
--- a/test/lhs-test.latex
+++ b/test/lhs-test.latex
@@ -33,8 +33,6 @@
   \KOMAoptions{parskip=half}}
 \makeatother
 \usepackage{xcolor}
-\IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available
-\urlstyle{same} % disable monospaced font for URLs
 \usepackage{color}
 \usepackage{fancyvrb}
 \newcommand{\VerbBar}{|}
@@ -81,6 +79,8 @@
   \usepackage{selnolig}  % disable illegal ligatures
 \fi
 \IfFileExists{bookmark.sty}{\usepackage{bookmark}}{\usepackage{hyperref}}
+\IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available
+\urlstyle{same} % disable monospaced font for URLs
 \hypersetup{
   hidelinks,
   pdfcreator={LaTeX via pandoc}}
diff --git a/test/lhs-test.latex+lhs b/test/lhs-test.latex+lhs
index 54af9388f..6c11e99bd 100644
--- a/test/lhs-test.latex+lhs
+++ b/test/lhs-test.latex+lhs
@@ -33,8 +33,6 @@
   \KOMAoptions{parskip=half}}
 \makeatother
 \usepackage{xcolor}
-\IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available
-\urlstyle{same} % disable monospaced font for URLs
 \usepackage{listings}
 \newcommand{\passthrough}[1]{#1}
 \lstset{defaultdialect=[5.3]Lua}
@@ -48,6 +46,8 @@
   \usepackage{selnolig}  % disable illegal ligatures
 \fi
 \IfFileExists{bookmark.sty}{\usepackage{bookmark}}{\usepackage{hyperref}}
+\IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available
+\urlstyle{same} % disable monospaced font for URLs
 \hypersetup{
   hidelinks,
   pdfcreator={LaTeX via pandoc}}
diff --git a/test/writer.latex b/test/writer.latex
index 5e93840e4..0b47a069e 100644
--- a/test/writer.latex
+++ b/test/writer.latex
@@ -34,8 +34,6 @@
 \makeatother
 \usepackage{fancyvrb}
 \usepackage{xcolor}
-\IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available
-\urlstyle{same} % disable monospaced font for URLs
 \usepackage{graphicx}
 \makeatletter
 \def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi}
@@ -58,6 +56,8 @@
   \usepackage{selnolig}  % disable illegal ligatures
 \fi
 \IfFileExists{bookmark.sty}{\usepackage{bookmark}}{\usepackage{hyperref}}
+\IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available
+\urlstyle{same} % disable monospaced font for URLs
 \VerbatimFootnotes % allow verbatim text in footnotes
 \hypersetup{
   pdftitle={Pandoc Test Suite},
diff --git a/test/writers-lang-and-dir.latex b/test/writers-lang-and-dir.latex
index eb466c266..d4d3feb68 100644
--- a/test/writers-lang-and-dir.latex
+++ b/test/writers-lang-and-dir.latex
@@ -33,8 +33,6 @@
   \KOMAoptions{parskip=half}}
 \makeatother
 \usepackage{xcolor}
-\IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available
-\urlstyle{same} % disable monospaced font for URLs
 \setlength{\emergencystretch}{3em} % prevent overfull lines
 \providecommand{\tightlist}{%
   \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
@@ -64,6 +62,8 @@
   \newenvironment{LTR}{\beginL}{\endL}
 \fi
 \IfFileExists{bookmark.sty}{\usepackage{bookmark}}{\usepackage{hyperref}}
+\IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available
+\urlstyle{same} % disable monospaced font for URLs
 \hypersetup{
   pdflang={en},
   hidelinks,