From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id 8KqTNYNu5mV9FgAA62LTzQ:P1 (envelope-from ) for ; Tue, 05 Mar 2024 01:59:48 +0100 Received: from aspmx1.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1.migadu.com with LMTPS id 8KqTNYNu5mV9FgAA62LTzQ (envelope-from ) for ; Tue, 05 Mar 2024 01:59:47 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=HhCZdmlS; 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"; dmarc=pass (policy=none) header.from=posteo.net ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1709600387; 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: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=lUaUj44l22D8YejgHY/NNeVi/AMa8G2bPWZiZ7sPlG8=; b=Nn68iPtRsz31lDDsH0xt4kV18rEypBMOtT86pkgAZGjC9bADfvy4ITjkuWB1KOhA+0yVos OLMCNgPwiUO4CSlg+ObQTIbnfnN9f8i06doLah6xacH0QHPkAYiuoq4XMRN37kRDA5188B 3fp3hZCbdNwtCWW+8eymPE2ybxTajZnke8DVsUKKZ3npVUhJ+1dhun9bZxRX+9DUVVfaKH q8Tt6iIyV9OGAg9SlGenT61Vb+jAhyKemx/B1S0sE+g6cMDGrYZO9iNQ9ckE3QUm6Et1oH mcsu6w37C/GrtWPTiivXs1jl3aShSEPfP76uz5AKiZgmU8wvwl0JJReaDOyJLw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=HhCZdmlS; 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"; dmarc=pass (policy=none) header.from=posteo.net ARC-Seal: i=1; s=key1; d=yhetil.org; t=1709600387; a=rsa-sha256; cv=none; b=JizlQxkovs271bSZxoZLmdghR07RM9VOUOlTcEJkXnIsWwjMjq0tPjJZj3W8TPaekbm6Fs wIOiGy91wG7swC630gbU/iDVUuDcqXDaGX86OiKsBAwV5z3alIlUDeMWwtwDuZI0GUSkHT 3KPWY64NiIcoeHE8qR4xDDpz9jc4/5atNK9AOJctIbzyeMqOBd8nZszaqmYzxLrzawL1Y+ dbKHsO9lgaBLz0n0MrDoxv6fX4r38v/tdS/0ioD9Jub9JCW+JhUAbkuZfkfLfkqHkPogf2 5LW/wbqkT8CvNq/Kx27Nd/p84CXTLztn401CaU0S1ol2ZZ8s9tklFADR3+A/rQ== 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 81C2373E76 for ; Tue, 5 Mar 2024 01:59:47 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhJ8o-0002Kj-Ra; Mon, 04 Mar 2024 19:58:46 -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 1rhJ8n-0002K4-6y for emacs-orgmode@gnu.org; Mon, 04 Mar 2024 19:58:45 -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 1rhJ8i-0006pC-U9 for emacs-orgmode@gnu.org; Mon, 04 Mar 2024 19:58:44 -0500 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 6AB86240101 for ; Tue, 5 Mar 2024 01:58:37 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1709600317; bh=ynEwMYUX9ovfQnTBkt59Ap4Z5qC+syJcnaGNLWJPT5Q=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type: Content-Transfer-Encoding:From; b=HhCZdmlSgj0is0KwBACzNdfIiL129UhTHThTbwDKkk1oUH1GR41s5/Qj3SSfBW0Eg NIPnjywyNePHNvjEDdglJM95f3vFOQvHcihSqm1g5lvynMQUHnMPtrmX0fRmC4DSB7 CFWxWfvnoN0mOFD4zR1on9EJJPfXi20Ye/IDdIGhTN+SS2yv7j7TQetbT1ECRj+Pif SQ7U7+9bg4eHDwD7EjMe4wB7FJx3MmugSwqApujzMHsE5euh6t/upbLSe2Y8Lhabrw cKMMorDB080BZizdqefyNaiL3PC+m7azfmd62OmFKR8JjINXvdakIAVMV8DVlwH/pe kbCyqnfYJq5Xg== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4Tpcd90bwsz6ty0 for ; Tue, 5 Mar 2024 01:58:36 +0100 (CET) From: =?utf-8?Q?Juan_Manuel_Mac=C3=ADas?= To: orgmode Subject: [tip] Export to PDF with latexmk 'continuous preview' option Date: Tue, 05 Mar 2024 00:58:34 +0000 Message-ID: <877cihmr45.fsf@posteo.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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-Country: US X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -7.50 X-Spam-Score: -7.50 X-Migadu-Queue-Id: 81C2373E76 X-Migadu-Scanner: mx11.migadu.com X-TUID: kdDWVt3pbRTV A little-known (and sometimes very useful) latexmk option is the -pvc option. According to the latexmk manual: [...] The second previewing option is the powerful -pvc option (mnemonic: "preview continuously"). In this case, latexmk runs continuously, regularly monitoring all the source files to see if any have changed. Every time a change is detected, latexmk runs all the programs necessary to generate a new version of the document. A good previewer will then automatically update its display. Thus the user can simply edit a file and, when the changes are written to disk, latexmk completely automates the cycle of updating the .dvi (and/or the .ps and .pdf) file, and refreshing the previewer's display. It's not quite WYSIWYG, but usefully close. In order to use this option from Org, I have defined a simple minor mode that runs latexmk with the -pvc option and creates a buffer to monitor the process. Every time the document, or any file involved, is saved, the PDF is updated. We can define in our `latexmkrc' our favorite external PDF viewer (Atril, Okular, Evince, etc.). I have this line: =E2=94=8C=E2=94=80=E2=94=80=E2=94=80=E2=94=80 =E2=94=82 $pdf_previewer =3D "atril %O %S > /dev/null 2>&1 &"; =E2=94=94=E2=94=80=E2=94=80=E2=94=80=E2=94=80 And here's the code (for documents that are long, complex, or take a while to export, it may be better to use the asynchronous version of `org-latex-export-to-latex'): =E2=94=8C=E2=94=80=E2=94=80=E2=94=80=E2=94=80 =E2=94=82 (defun my-org-compile-latexmk-interactive () =E2=94=82 (let* ((tex-file (org-export-output-file-name ".tex"))) =E2=94=82 (start-process-shell-command =E2=94=82 "latexmk" =E2=94=82 (format "*%s-latexmk-process*" (file-name-sans-extension tex= -file)) =E2=94=82 (concat =E2=94=82 "latexmk -f -pvc -lualatex -e '$lualatex=3Dq/lualatex %O -s= hell-escape %S/' " =E2=94=82 tex-file)))) =E2=94=82 =E2=94=82 (define-minor-mode org-interactive-compile-pdf-mode =E2=94=82 "TODO" =E2=94=82 :lighter " OrgInteractivePDF" =E2=94=82 (if org-interactive-compile-pdf-mode =E2=94=82 (progn =E2=94=82 (my-org-compile-latexmk-interactive) =E2=94=82 (add-hook 'after-save-hook #'org-latex-export-to-latex nil = t)) =E2=94=82 (remove-hook 'after-save-hook #'org-latex-export-to-latex t) =E2=94=82 (when (equal (process-status "latexmk") 'run) =E2=94=82 (kill-process "latexmk")))) =E2=94=94=E2=94=80=E2=94=80=E2=94=80=E2=94=80 And a screencast: -- Juan Manuel Mac=C3=ADas -- Composici=C3=B3n tipogr=C3=A1fica, tratamiento d= e datos, dise=C3=B1o editorial y ortotipograf=C3=ADa