From 5887f477807181e875b7f84385f579f75f61f420 Mon Sep 17 00:00:00 2001
From: Joshua Fogg <joshua.h.fogg@gmail.com>
Date: Tue, 10 May 2022 15:12:17 +0100
Subject: [PATCH] Allow  with  w/o warnings

---
 README.md   |  2 +-
 edmaths.sty | 22 +++++++++++++++-------
 2 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/README.md b/README.md
index 1446003..d8ab3ec 100644
--- a/README.md
+++ b/README.md
@@ -36,7 +36,7 @@ Here `<options>` is a comma-separated list of the following keywords:
 | `fourier` | This provides much improved typography by activating the fourier font package (based on [Adobe’s Utopia](https://fonts.adobe.com/fonts/utopia) family) along with the [cmap](https://www.ctan.org/pkg/cmap) and [microtype](https://www.ctan.org/pkg/microtype) packages; all those are required for this option. |
 | `hyperref` | If the [hyperref](https://www.ctan.org/pkg/hyperref) and [xcolor](https://www.ctan.org/pkg/xcolor) packages are installed, this creates PDF output with clickable and all-black links. The packages are set up with sane default options, but to modify the behaviour, simply use the `\hypersetup` command; see the `hyperref` documentation for details. |
 | `colour` | If the `hyperref` option is used, this sets clickable links to have a sane default colour (sepia for internal links, blue for external URLs). |
-| `fancyhdr` | If the [fancyhdr](https://www.ctan.org/pkg/fancyhdr) package is installed, this creates nice page headers and footers (with sane default settings); to modify this behaviour, simply use the commands described in the `fancyhdr` documentation. This may produce warnings if used without `twoside` in the `documentclass`.
+| `fancyhdr` | If the [fancyhdr](https://www.ctan.org/pkg/fancyhdr) package is installed, this creates nice page headers and footers (with sane default settings); to modify this behaviour, simply use the commands described in the `fancyhdr` documentation.
 
 ### Usage
 
diff --git a/edmaths.sty b/edmaths.sty
index 9880be2..4685de0 100644
--- a/edmaths.sty
+++ b/edmaths.sty
@@ -107,13 +107,21 @@
     \RequirePackage{fancyhdr}
     \pagestyle{fancy}
     \fancyhf{}
-    % NOTE if this is used without `twoside` in \documentclass{...} then fancyhdr will
-    % complain that the 'E' used here is useless.  
-    \fancyhead[RO,LE]{\thepage}
-    \fancyfoot[RO,LE]{\thepage}
-    \fancyhead[LO]{\it\@title}
-    \fancyhead[RE]{\@author}
-    \fancyfoot[RE,LO]{}
+    % if \fancyhead or \fancyfoot are used without `twoside` in \documentclass{...} then
+    % fancyhdr will complain that the 'E' used here is useless, so need to condition.
+    \if@twoside%
+        %%% put the stuff for true here (twoside=true)
+        \fancyhead[RO,LE]{\thepage}
+        \fancyfoot[RO,LE]{\thepage}
+        \fancyhead[LO]{\it\@title}
+        \fancyhead[RE]{\@author}
+        \fancyfoot[RE,LO]{}
+    \else%
+        %%% put the stuff for false here (twoside=false)
+        \fancyhead[LO]{\it\@title~~$\cdot$~~\@author}
+        \fancyhead[R]{\thepage}
+        \fancyfoot[R,LO]{}
+    \fi%  
 } {}
 
 
-- 
GitLab