From e266df43bc9cf4f3f9cedd2460dacdc1432e065c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?FEL=C5=A0=C3=96CI=20Marek?= <marek.felsoci@inria.fr>
Date: Mon, 17 Apr 2023 17:31:38 +0200
Subject: [PATCH] Add remove-from-org-latex-packages-alist also to
 latex-publish.el

---
 latex-publish.el | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/latex-publish.el b/latex-publish.el
index ba1a13e..3f68a32 100644
--- a/latex-publish.el
+++ b/latex-publish.el
@@ -18,6 +18,17 @@ undesirable behavior."
           (add-to-list 'output pkg t)))
     (setq org-latex-default-packages-alist output)))
 
+(defun remove-from-org-latex-packages-alist (package)
+  "Removes `package' from the list of packages that are included by default when
+exporting from Org to LaTeX, i.e. from `org-latex-packages-alist'. This is
+useful for controlling the order in which some of the packages are loaded in
+order to prevent conflicts or other undesirable behavior."
+  (let ((output '()))
+    (dolist (pkg org-latex-packages-alist)
+      (unless (string= package (nth 1 pkg))
+          (add-to-list 'output pkg t)))
+    (setq org-latex-packages-alist output)))
+
 ;; Custom publishing function for LaTeX files. This is useful when we need to
 ;; publish a manually written LaTeX file to PDF (e. g. a poster).
 (defun latex-publish-to-pdf (plist filename pub-dir)
-- 
GitLab