diff --git a/notebook-commands.tex b/notebook-commands.tex
index 61ff67178298266eff2c926eebad6d5cec6e1fa6..f3313aeeceb98a6837ba3abb5b144fe1e807da17 100644
--- a/notebook-commands.tex
+++ b/notebook-commands.tex
@@ -1,3 +1,4 @@
+\def\PYZsq{\textquotesingle}% Upright quotes in Pygmentized code
 % Colors for the hyperref package
 \definecolor{urlcolor}{rgb}{0,.145,.698}
 \definecolor{linkcolor}{rgb}{.71,0.21,0.01}
diff --git a/notebook-preamble.tex b/notebook-preamble.tex
index 75656ff418a2622ca675134b0680f7df2895077b..1ab29124da4ded111b9e59a57030957d10e4a1e4 100644
--- a/notebook-preamble.tex
+++ b/notebook-preamble.tex
@@ -14,10 +14,6 @@
 \usepackage{xcolor} % Allow colors to be defined
 \usepackage{enumerate} % Needed for markdown enumerations to work
 \usepackage{textcomp} % defines textquotesingle
-% Hack from http://tex.stackexchange.com/a/47451/13684:
-\AtBeginDocument{%
-    \def\PYZsq{\textquotesingle}% Upright quotes in Pygmentized code
-}
 \usepackage{upquote} % Upright quotes for verbatim code
 \usepackage{eurosym} % defines \euro