From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id cD2xGZDYxmWTSAEAqHPOHw:P1 (envelope-from ) for ; Sat, 10 Feb 2024 02:59:44 +0100 Received: from aspmx1.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0.migadu.com with LMTPS id cD2xGZDYxmWTSAEAqHPOHw (envelope-from ) for ; Sat, 10 Feb 2024 02:59:44 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=QmGmwyts; 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-Seal: i=1; s=key1; d=yhetil.org; t=1707530384; a=rsa-sha256; cv=none; b=gk3LrKdoGRZ/WMOSTTyyA38x+q+EmGq0mSHS3ijnQuC+vDRupdsHnBpvR4e/se7KG9vbqY Os738l+lrlqWWgtx/0waFs6Jj2J5nEnCXR7RB7OtLBiYt7dXGZaS1uG7CpuzkNDq8qYfdK a2LbxMvx1OfS6XAss5NZxgDLBvSKr6vbQl9d9+9V5AvesJYFs3UqZPM7PUQ1MWqdI16kHd HybYPTNj0VdjQ0eP6NIOF5MgYnjP1mroTFgz9IRhUIom77DzudJK3syY+iDqYb8YWnajlz 0NOe0QCDAaSV2pUa1ZNVZimg8ftgFn0yPPSsb++BTC4DuRt4s8rlU9pToAB1iw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=QmGmwyts; 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=1707530384; 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=h9h7L8fq7LDtmhAmohWZmgrA0CJO+Y+h2x1Mu8b90g4=; b=jugbheS65oS22tzdCBSDSh540btmqXY22kY95tol27NG3izyrZMB68b2eplFpVq+a+N/65 U5jSofbfnSBehA6dBw10A+24cKbTnOB/XbNR6LB/xuM081ohrqX2xLgiP5cKTfCuP/fAcW ds0zprH0hM6QPQ1fKluf39D1/0x464ESsJQzV8yzRxwckhPUVXwtB2VJfAnDrnY5hMequc MQ1Vi4QfJHfubdf2Z7SFWe0qTjy/GrhcqEP8xMfo9D5Jxxp7KxKiMkdtBdi6XzAw3euhC2 0fUeXXnDTYHAK6Ccx/g4hIeXDntR/dKTGWQkaTKlFMI3NiEzWj4mBqFaED3cQA== 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 0D3FE6DBC3 for ; Sat, 10 Feb 2024 02:59:44 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rYcdr-00075K-Uq; Fri, 09 Feb 2024 20:58:55 -0500 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 1rYcdq-00074p-3Y for emacs-orgmode@gnu.org; Fri, 09 Feb 2024 20:58:54 -0500 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 1rYcdn-0003Wt-Ns for emacs-orgmode@gnu.org; Fri, 09 Feb 2024 20:58:53 -0500 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id C4BC8240101 for ; Sat, 10 Feb 2024 02:58:47 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1707530327; bh=Bm25Ma9CJHNqvJXEcOchO3bvvM1c7tnFQK6itYEQ/og=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=QmGmwytsu/sb3uhT7QgjzL6Gc1dkHtooJ0hlPY8V0sEVOUdT1WObLpoIPa5y0NUlA BJTR83wcsHzOQU3mXInNIKMkaLVljziG7GcFUSltkVoRA68nwXk4Q2y/YNwYLRnkDh WXw/PUEsXduZx5SDRLN4U3rmYpy4pTX623JdT2m9qJv1kltoxdaITZir3MvrkTA2UT rMB70LpHQMWPfT9a8BhswXucPjyfhqc2F7CHmTawSBkslZeXsHjSFYzv1xX9gb4obz +Ut4LiaS2q3EVJREgepjLVq5iYef0IaMxI8rxHDd4h0ODWw2w4lc/fqdQqOfSm4W2r oIy7xjrlgs60g== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4TWv5g20HXz6tn4 for ; Sat, 10 Feb 2024 02:58:46 +0100 (CET) From: =?utf-8?Q?Juan_Manuel_Mac=C3=ADas?= To: orgmode Subject: [patch] Add two new header args to LaTeX block Date: Sat, 10 Feb 2024 01:58:45 +0000 Message-ID: <87zfw9yt9m.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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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-Scanner: mx10.migadu.com X-Spam-Score: -9.90 X-Migadu-Queue-Id: 0D3FE6DBC3 X-Migadu-Spam-Score: -9.90 X-TUID: 0lD5tvJ0Jeh5 --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable The attached patch adds two new header args to the LaTeX block: - `:pdf-process' allows modifying the value of `org-latex-pdf-process' locally to the block. This can be useful for evaluating a given block with another LaTeX compiler, or even using some custom script. Example: #+begin_src latex :pdf-process '("lualatex -shell-escape -interaction non= stopmode -output-directory %o %f") \textbf{hello world} #+end_src - `:full-to-pdf' makes the block like a standalone LaTeX document, which should contain everything needed to be compiled, from \documentclass{} to \end{document}. Example: #+begin_src latex :full-to-pdf yes \documentclass{article}=20=20 \begin{document} \textbf{hello world} \end{document} #+end_src I think both arguments can have many practical uses. For example, to compile separately and load multiple subdocuments, with different preambles: #+NAME: doc1 #+begin_src org :exports none :results latex ,#+include: some-document.org #+end_src #+begin_src latex :noweb yes :results silent file :file file.pdf :full-to= -pdf yes \documentclass{article} \usepackage[spanish]{babel} \usepackage{fontspec} \setmainfont{Vollkorn} \begin{document} <> \end{document} #+end_src #+latex: \includepdf{file.pdf} =20=20 Or even to evaluate ConTeXt code within a LaTeX block: #+begin_src latex :full-to-pdf yes :results raw file :file file.pdf :pdf-= process '("cd %o && context %f") \starttext \startsection[title=3D{Testing ConTeXt}] Lorem ipsum dolor. \stopsection \stoptext #+end_src Best regards, Juan Manuel=20 --=20 Juan Manuel Mac=C3=ADas -- Composici=C3=B3n tipogr=C3=A1fica, tratamiento d= e datos, dise=C3=B1o editorial y ortotipograf=C3=ADa --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-lisp-ob-latex.el-Add-two-new-header-args-to-LaTeX-bl.patch >From fe1b40e2b22e2c668440bea13feda0ab7923bdd8 Mon Sep 17 00:00:00 2001 From: Juan Manuel Macias Date: Sat, 10 Feb 2024 02:01:08 +0100 Subject: [PATCH] lisp/ob-latex.el: Add two new header args to LaTeX block. * (org-babel-execute:latex): `:pdf-process' allows modifying the value of `org-latex-pdf-process' in a specific block. The `:full-to-pdf' argument requires that the LaTeX block contains all the code necessary to be compiled, as if it were an autonomous LaTeX document: the expected result will always be a PDF file. --- lisp/ob-latex.el | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lisp/ob-latex.el b/lisp/ob-latex.el index acb83228b..118d81338 100644 --- a/lisp/ob-latex.el +++ b/lisp/ob-latex.el @@ -162,6 +162,9 @@ This function is called by `org-babel-execute-src-block'." (height (and fit (cdr (assq :pdfheight params)))) (width (and fit (cdr (assq :pdfwidth params)))) (headers (cdr (assq :headers params))) + (pdf-process (cdr (assq :pdf-process params))) + (org-latex-pdf-process (if pdf-process pdf-process org-latex-pdf-process)) + (full-to-pdf (cdr (assq :full-to-pdf params))) (in-buffer (not (string= "no" (cdr (assq :buffer params))))) (org-latex-packages-alist (append (cdr (assq :packages params)) org-latex-packages-alist))) @@ -187,6 +190,14 @@ This function is called by `org-babel-execute-src-block'." (list org-babel-latex-pdf-svg-process) extension err-msg log-buf))) (rename-file img-out out-file t)))) + ((and (string= "pdf" extension) full-to-pdf) + (with-temp-file tex-file + (insert body)) + (when (file-exists-p out-file) (delete-file out-file)) + (let ((tmp-pdf (org-babel-latex-tex-to-pdf tex-file))) + (let* ((log-buf (get-buffer-create "*Org Babel LaTeX Output*")) + (err-msg "org babel latex failed")) + (rename-file tmp-pdf out-file t)))) ((string-suffix-p ".tikz" out-file) (when (file-exists-p out-file) (delete-file out-file)) (with-temp-file out-file -- 2.43.0 --=-=-=--