From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:203:b4db::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id QL4RGBj1yWHXPAEAgWs5BA (envelope-from ) for ; Mon, 27 Dec 2021 18:17:12 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id 4NBhFRj1yWF/rwAA9RJhRA (envelope-from ) for ; Mon, 27 Dec 2021 18:17:12 +0100 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 17F1637770 for ; Mon, 27 Dec 2021 18:17:12 +0100 (CET) Received: from localhost ([::1]:47774 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n1tcV-0006el-6M for larch@yhetil.org; Mon, 27 Dec 2021 12:17:11 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38676) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n1tbq-0006eG-SI for emacs-orgmode@gnu.org; Mon, 27 Dec 2021 12:16:33 -0500 Received: from ciao.gmane.io ([116.202.254.214]:33336) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n1tbo-0003Pv-JR for emacs-orgmode@gnu.org; Mon, 27 Dec 2021 12:16:30 -0500 Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1n1tba-0003na-1A for emacs-orgmode@gnu.org; Mon, 27 Dec 2021 18:16:14 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: emacs-orgmode@gnu.org From: Sebastian P. Luque Subject: Re: caption width in LateX export Date: Mon, 27 Dec 2021 11:16:03 -0600 Organization: Church of Emacs Message-ID: <87czliotnw.fsf@phoca.sebkatja.org> References: <87lf06q1t9.fsf@phoca.sebkatja.org> <874k6utry0.fsf@posteo.net> <87h7aup5u1.fsf@phoca.sebkatja.org> <87ee5yxjmf.fsf@posteo.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) Cancel-Lock: sha1:09ELZ0Gr9cjnyaSYzvNM+BjO5oc= Received-SPF: pass client-ip=116.202.254.214; envelope-from=geo-emacs-orgmode@m.gmane-mx.org; helo=ciao.gmane.io X-Spam_score_int: 5 X-Spam_score: 0.5 X-Spam_bar: / X-Spam_report: (0.5 / 5.0 requ) BAYES_00=-1.9, DKIM_ADSP_CUSTOM_MED=0.001, FORGED_GMAIL_RCVD=1, FREEMAIL_FORGED_FROMDOMAIN=0.248, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, NML_ADSP_CUSTOM_MED=0.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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" X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1640625432; 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: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post; bh=NPtJzwxvj8x6GtMx/uyEtxUicOcpuQvz4ah5Pqsb0B8=; b=VmmudENT0mWX0JyGBaLiJwTBEjawBT76TCjkm0aTD1FQr1+CrN1eY71Bz+oD5rcFWoce50 u0YzwSqYMlUPZfav4bN2W/tk3KEUFnKKs9y8BwNNaFtPrQU0JVKI+pfB2F6tfN8zM3LRH0 +TTNjHb6r+wJUr6u0RAwKFe9BGgy9aItSFcQ7kx+8Lv5eucmo7qOcS1UgqxiqrO//GlOSe TtyKgxvShYdfr2/7DuqkUO21vtbjK1aI7Kmg7MZ7z0KVdKwBKI0ZqcDnG6RC8VEn/s7PX7 b4DsHuy6vlV0EvGULsG5qq9zJr5goxyb/501dOVQCpyXNNU8xBcKXoUPouKTiQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1640625432; a=rsa-sha256; cv=none; b=rF+X3wBqhXVcJ05eOe90QEQhuMCjyyp9RCo5zjkYmS9D6qp1QT85/S4GAKh9HCU5X8Bmrz J7QcC/Ju9VZ2zwMFqO3bqUZ46cN3zvNVgmchl4b0XGQchUEUGL+3DJU4viqXdiNyR2FImi QdosZtt6y40uLgpT6ytbpahNpxZwsFFEVSQ2h5P3ejSI8DNHfmiwkrS+0pnQe7wIPa3d8k u8c3jZO29F7ML/SCwohusVKnmevEVytdzwsRDHoh30Oae4R41OD7Ju4fWpuMOW9KV7A42G FoWreVTTKe/8EHfmoRWRx6FwADWfXxjx/K8zHbRdTSrjBTkXmtDLMYlZDlIFMQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=gmail.com (policy=none); 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" X-Migadu-Spam-Score: -2.47 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=gmail.com (policy=none); 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" X-Migadu-Queue-Id: 17F1637770 X-Spam-Score: -2.47 X-Migadu-Scanner: scn1.migadu.com X-TUID: Wb8SrOOA5M/Y On Mon, 27 Dec 2021 13:28:08 +0000, Juan Manuel MacĂ­as wrote: > Sebastian P. Luque writes: >> Thank you, Juan. Unfortunately, there is a price for this solution >> as it is now impossible to name and refer to this segment as usual: > I see. Have you tried the option with LuaTeX that I put in my other > message? You can compile with LuaTeX also using latexmk: > (setq org-latex-pdf-process '("latexmk -lualatex -e > '$lualatex=q/lualatex %%O -shell-escape %%S/' %f")) I haven't tried this yet, but it's great to know latexmk can use LuaTex. > In any case, since this is a simple substitution, you can use also a > function in Elisp as a final output filter[1]: > #+BIND: org-export-filter-final-output-functions (caption-auto-width) > #+begin_src emacs-lisp :exports results :results none > (defun caption-auto-width (text backend info) (when > (org-export-derived-backend-p backend 'latex) (with-temp-buffer > (insert text) (save-excursion (goto-char (point-min)) (while > (re-search-forward "\\(\\\\includegraphics.+\\)" nil t) (replace-match > "\\\\sbox0{\\1}" t nil))) (save-excursion (goto-char (point-min)) > (while (re-search-forward "\\(\\\\caption.+\\)" nil t) (replace-match > "\\\\begin{minipage}{\\\\wd0}\\\\usebox0\\1\\\\end{minipage}" t nil))) > (setq text (buffer-string))))) #+end_src > Vid. [[fig:1]] > #+NAME: fig:1 #+CAPTION: Lorem ipsum dolor sit amet, consectetuer > adipiscing elit. Donec hendrerit tempor tellus. Donec pretium posuere > tellus > #+ATTR_LaTeX: :width .3\linewidth [[my-image.jpg]] > [1] You need to set this variable as non-nil, in order to use bind > keywords: (setq org-export-allow-bind-keywords t) > Hope this works, This is great, and very interesting to learn about the BIND keyword. Thank you, -- Seb