From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:403:478a::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id aMWjOIjtBWU7jQAAG6o9tA:P1 (envelope-from ) for ; Sat, 16 Sep 2023 20:01:45 +0200 Received: from aspmx1.migadu.com ([2001:41d0:403:478a::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id aMWjOIjtBWU7jQAAG6o9tA (envelope-from ) for ; Sat, 16 Sep 2023 20:01:44 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id CD2E95E06F for ; Sat, 16 Sep 2023 20:01:43 +0200 (CEST) Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=Wb45DxpC; dmarc=pass (policy=none) header.from=posteo.net; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1694887304; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=d/Z6WJAyGZt7uvc9Neid/hKzXYk/Y6txRGb4Gxsctlg=; b=fy97m3w6d5LKkup5LZUBm6GLitSfps3SboCVAGG2zbGU7MFGO+prpkwI2UI31VtcGzxmuq 3BjQB08tjqhx9it+onyHrx6+pbQL4cKb7bn8Mq3NVk0qjLXijyL9XQE7tSaxk8PAQZpH8C 0fm7rHiu8iMQCYrwCI6e0eaIpWhXenXFbeAlndxdxCJNtS7FKWnIna8JyK/cAw9B8TXV6G 0u/42uCNXgmhGmycN2OfFpM7cn7rsboioQWKh9+XdL06w6DG6/VTpkVKJxjIlDJXBo7ftY rYzR+UT7aUl7U/b7Hm5wyGaXyLO5F+AiTp1Lf/0HtfmX1OQjgmv/F0CesgsjAg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1694887304; a=rsa-sha256; cv=none; b=I1ifoWo3puv8bgLWTNPIhScd9MkjCBoc4J5oF0GGunsIRTyE3bncg9F8jVNnjoPkrkB1e9 sRckTFmhv/DedRpzzklX9KXoMpe0P7JtVAiqWClnvCmcNCkDptJhp4NgOaU7rmd0HkNiFA wo69DJv9nJCjL6+DruwvmdQpMH2a/1MZSFCI4xi7Hv9NBFqr8LBF5+v3SaUA1YBMRJWv/w +jyffM/fWu7sj82aag13lliKWlwsICX2jaTnm0xsE+fY9X2lOZleyRn/V402Y3zt7uUOri /SoI8h1xCggJWM/WvCiAxPV7b0tsc7+gN6gKNfF0AkbsfflQtDH86m8cHGV8MQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=Wb45DxpC; dmarc=pass (policy=none) header.from=posteo.net; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qhZb7-0007rg-Md; Sat, 16 Sep 2023 14:00:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qhZb6-0007rQ-7X for emacs-orgmode@gnu.org; Sat, 16 Sep 2023 14:00:48 -0400 Received: from mout02.posteo.de ([185.67.36.66]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qhZb1-00025W-QI for emacs-orgmode@gnu.org; Sat, 16 Sep 2023 14:00:47 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 8049E240101 for ; Sat, 16 Sep 2023 20:00:40 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1694887240; bh=JPmm8EPhYsHNVBb4a/n84zx13k/itGxb4pIH62sIONE=; h=From:To:Subject:Date:Message-ID:MIME-Version:From; b=Wb45DxpChP7GfTvmb7avwoOaE3Fj3do9rKYBLSb2BbcSwPj2Y6fImCD1dhlcbs8w+ I0mlH5HjjM3oqpSBtZ29V9xZN33flplf0IeI/H3zjwdPaSrUgBjzC8o2JU2Z5MXfUs gdo+mmS0yvuHv9iR4Fcef1cgjU83Soh8aTg0eA8+83aL6je7i0IySqhiTHXMFQMU1i ogzNorGi2IZwSFY+ywrSWKYJUQPX7+6MQc5psc/ZLLZhPlzt2dZhs4Z2ducPTB7ZIs hGvPO2BQbElDd949+UvTLJCTJwXCwvdFvtUPdwGpXpXAHbMlQcarDQkLza+nII8C68 3/KfdhSLLydqg== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4RnzPN0gjQz9rxD for ; Sat, 16 Sep 2023 20:00:39 +0200 (CEST) From: =?utf-8?Q?Juan_Manuel_Mac=C3=ADas?= To: orgmode Subject: [patch] ox-latex.el: Add `LATEX_PRE_HEADER' keyword Date: Sat, 16 Sep 2023 18:00:37 +0000 Message-ID: <874jjuj8vu.fsf@posteo.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=185.67.36.66; envelope-from=maciaschain@posteo.net; helo=mout02.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Spam-Score: -5.67 X-Spam-Score: -5.67 X-Migadu-Queue-Id: CD2E95E06F X-Migadu-Scanner: mx0.migadu.com X-TUID: rudBt5M8iB/2 --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Rationale for this patch: in certain cases, in a LaTeX document, it is necessary to add code before the class declaration (\documentclass...). For example, commands like \PassOptionsToPackage, \DocumentMetadata{ }, etc.; or certain packages that should be loaded first using \RequirePackage{}; and other miscellaneous cases[1]. I think that by defining a new keyword `latex_pre_header', which behaves the same as latex_header but concatenated before the class, these situations can be resolved from Org. [1] A longer example to export to a pdf that has pdf-x compliance, with the pdfx package: \providecommand{\pdfxopts}{x-1a} \begin{filecontents*}{\jobname.xmpdata} \Title{Some Title} \Author{Author} \Language{es-ES} \Keywords{keywords} \Publisher{publisher} \end{filecontents*} \documentclass{... --=20 Juan Manuel Mac=C3=ADas https://juanmanuelmacias.com https://lunotipia.juanmanuelmacias.com https://gnutas.juanmanuelmacias.com --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-lisp-ox-latex.el-latex-Add-LATEX_PRE_HEADER-keyword.patch >From ac6b743a4489f7bc8ab1cdae7ffd3b36e5f3c1d2 Mon Sep 17 00:00:00 2001 From: Juan Manuel Macias Date: Sat, 16 Sep 2023 19:22:39 +0200 Subject: [PATCH] lisp/ox-latex.el (latex): Add `LATEX_PRE_HEADER' keyword * (org-latex-make-preamble): In some cases it is necessary to add code before the `\documentclass' line. `LATEX_PRE_HEADER' behaves the same as `LATEX_HEADER', except that it is concatenated before the class. --- lisp/ox-latex.el | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el index 14105c7cc..5e97b8b3d 100644 --- a/lisp/ox-latex.el +++ b/lisp/ox-latex.el @@ -124,6 +124,7 @@ (:latex-class-options "LATEX_CLASS_OPTIONS" nil nil t) (:latex-header "LATEX_HEADER" nil nil newline) (:latex-header-extra "LATEX_HEADER_EXTRA" nil nil newline) + (:latex-pre-header "LATEX_PRE_HEADER" nil nil newline) (:description "DESCRIPTION" nil nil parse) (:keywords "KEYWORDS" nil nil parse) (:subtitle "SUBTITLE" nil nil parse) @@ -1984,13 +1985,18 @@ specified in `org-latex-default-packages-alist' or (replace-regexp-in-string "^[ \t]*\\\\documentclass\\(\\(\\[[^]]*\\]\\)?\\)" class-options header t nil 1)))) - (user-error "Unknown LaTeX class `%s'" class)))) + (user-error "Unknown LaTeX class `%s'" class))) + (pre-header (mapconcat + #'org-element-normalize-string + (list (plist-get info :latex-pre-header) "")))) (org-latex-guess-polyglossia-language (org-latex-guess-babel-language (org-latex-guess-inputenc (org-element-normalize-string (org-splice-latex-header - class-template + (if pre-header + (format "%s\n%s" pre-header class-template) + class-template) (org-latex--remove-packages org-latex-default-packages-alist info) (org-latex--remove-packages org-latex-packages-alist info) snippet? -- 2.42.0 --=-=-=--