diff --git a/data/templates/default.latex b/data/templates/default.latex
index e83806940..aa262ee80 100644
--- a/data/templates/default.latex
+++ b/data/templates/default.latex
@@ -282,8 +282,6 @@ $endif$
 $if(strikeout)$
 $-- also used for underline
 \usepackage[normalem]{ulem}
-% Avoid problems with \sout in headers with hyperref
-\pdfstringdefDisableCommands{\renewcommand{\sout}{}}
 $endif$
 \setlength{\emergencystretch}{3em} % prevent overfull lines
 \providecommand{\tightlist}{%
@@ -383,6 +381,8 @@ $if(csquotes)$
 \usepackage{csquotes}
 $endif$
 \IfFileExists{bookmark.sty}{\usepackage{bookmark}}{\usepackage{hyperref}}
+% Avoid problems with \sout in headers with hyperref
+\pdfstringdefDisableCommands{\renewcommand{\sout}{}}
 \hypersetup{
 $if(title-meta)$
   pdftitle={$title-meta$},
diff --git a/test/lhs-test.latex b/test/lhs-test.latex
index a83e31202..4ec0133db 100644
--- a/test/lhs-test.latex
+++ b/test/lhs-test.latex
@@ -81,6 +81,8 @@
   \usepackage{selnolig}  % disable illegal ligatures
 \fi
 \IfFileExists{bookmark.sty}{\usepackage{bookmark}}{\usepackage{hyperref}}
+% Avoid problems with \sout in headers with hyperref
+\pdfstringdefDisableCommands{\renewcommand{\sout}{}}
 \hypersetup{
   hidelinks,
   pdfcreator={LaTeX via pandoc}}
diff --git a/test/lhs-test.latex+lhs b/test/lhs-test.latex+lhs
index 54af9388f..24bcc255d 100644
--- a/test/lhs-test.latex+lhs
+++ b/test/lhs-test.latex+lhs
@@ -48,6 +48,8 @@
   \usepackage{selnolig}  % disable illegal ligatures
 \fi
 \IfFileExists{bookmark.sty}{\usepackage{bookmark}}{\usepackage{hyperref}}
+% Avoid problems with \sout in headers with hyperref
+\pdfstringdefDisableCommands{\renewcommand{\sout}{}}
 \hypersetup{
   hidelinks,
   pdfcreator={LaTeX via pandoc}}
diff --git a/test/writer.latex b/test/writer.latex
index 33a09e23c..0074b7b1d 100644
--- a/test/writer.latex
+++ b/test/writer.latex
@@ -51,8 +51,6 @@
 \def\fps@figure{htbp}
 \makeatother
 \usepackage[normalem]{ulem}
-% Avoid problems with \sout in headers with hyperref
-\pdfstringdefDisableCommands{\renewcommand{\sout}{}}
 \setlength{\emergencystretch}{3em} % prevent overfull lines
 \providecommand{\tightlist}{%
   \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
@@ -61,6 +59,8 @@
   \usepackage{selnolig}  % disable illegal ligatures
 \fi
 \IfFileExists{bookmark.sty}{\usepackage{bookmark}}{\usepackage{hyperref}}
+% Avoid problems with \sout in headers with hyperref
+\pdfstringdefDisableCommands{\renewcommand{\sout}{}}
 \hypersetup{
   pdftitle={Pandoc Test Suite},
   pdfauthor={John MacFarlane; Anonymous},
diff --git a/test/writers-lang-and-dir.latex b/test/writers-lang-and-dir.latex
index eb466c266..8a5301085 100644
--- a/test/writers-lang-and-dir.latex
+++ b/test/writers-lang-and-dir.latex
@@ -64,6 +64,8 @@
   \newenvironment{LTR}{\beginL}{\endL}
 \fi
 \IfFileExists{bookmark.sty}{\usepackage{bookmark}}{\usepackage{hyperref}}
+% Avoid problems with \sout in headers with hyperref
+\pdfstringdefDisableCommands{\renewcommand{\sout}{}}
 \hypersetup{
   pdflang={en},
   hidelinks,