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 KILIHsq/yWFxqQAAgWs5BA (envelope-from ) for ; Mon, 27 Dec 2021 14:29:46 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id 0OAZHMq/yWHnPQEA9RJhRA (envelope-from ) for ; Mon, 27 Dec 2021 14:29:46 +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 0557C2B28C for ; Mon, 27 Dec 2021 14:29:46 +0100 (CET) Received: from localhost ([::1]:48726 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n1q4O-0003zb-Pf for larch@yhetil.org; Mon, 27 Dec 2021 08:29:44 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45282) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n1q32-0003zP-IZ for emacs-orgmode@gnu.org; Mon, 27 Dec 2021 08:28:20 -0500 Received: from mout01.posteo.de ([185.67.36.65]:53399) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n1q2z-0002FX-Ue for emacs-orgmode@gnu.org; Mon, 27 Dec 2021 08:28:20 -0500 Received: from submission (posteo.de [89.146.220.130]) by mout01.posteo.de (Postfix) with ESMTPS id BFC71240026 for ; Mon, 27 Dec 2021 14:28:10 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1640611690; bh=P/zigJNBat2bQm0H5kxqz+pU00TB7VWweP6fAgHBJZk=; h=From:To:Cc:Subject:Date:From; b=S6LnKkYa8K2Tr9u344hLzDxrTA11uWGmj+sXuihcO360a4jnnCHa221Z3ART5jAh1 C0uPMkpqoCtSQ8AAAoZGRwW5Kem9dqkwlCNt9ya0GN/W4Bj8W/3DrZLdqnRgCzqNCj jzI6SYa8yE5OvLPxFjCM6XIFYzZgkd7qBYPgLAbyapEUBAFx4aWo+c5plLKk345GuK v5c3RtLOCnIlTf/NkcIwcUNBsG5UkRxfqveyQDZVHBROxROeGsP9VlUs/gr/HIoTB9 o/+6etakHOznpHR2iKkCxT6yKtcCmVodsFSSdAGcReIB+ZSArfolX28zvYyLLif3lw ejTJXEzzQqFqw== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4JMz4p181Dz6tpb; Mon, 27 Dec 2021 14:28:09 +0100 (CET) From: =?utf-8?Q?Juan_Manuel_Mac=C3=ADas?= To: Sebastian P. Luque Subject: Re: caption width in LateX export References: <87lf06q1t9.fsf@phoca.sebkatja.org> <874k6utry0.fsf@posteo.net> <87h7aup5u1.fsf@phoca.sebkatja.org> Date: Mon, 27 Dec 2021 13:28:08 +0000 In-Reply-To: <87h7aup5u1.fsf@phoca.sebkatja.org> (Sebastian P. Luque's message of "Mon, 27 Dec 2021 06:53:10 -0600") Message-ID: <87ee5yxjmf.fsf@posteo.net> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=185.67.36.65; envelope-from=maciaschain@posteo.net; helo=mout01.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_H2=-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: , Cc: orgmode 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=1640611786; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=Dg6v/svtqaiGmEH0um8bu6xdVNaj1PjL+svsWJAroc4=; b=ZUeNqlnGvP5Pk0+jEk98HLLskqtr/N5KWcWZvqcG7F8nVrntMgiaIL9qB4CdFyM7nxnfHb SvaH16L6+wjVztVY5ZKR2rw+zNQ6zYvsmQmOIZcMYD8XyusHcFRZYnu4gkx4SPRHXMWgQs cRbzSV0un2Zbg1/NpK3sNW3qbHCd5GNfqKqTTQx0mOFigz3zWPtOiy3suFziagk3uSycgS Or3Pamo3qI0xf6vHJda5KJKsqZt2kzae/5r6mbvmnIh2sS+Q2Y6OSoK27YI5LJhg3hJB6P Wi5mXF18PE3JGtc4mVshD0K35DFrdwfzSpm8qrCPcZpqZcoi5LLmWtXsLPgueQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1640611786; a=rsa-sha256; cv=none; b=pcInJ4GXov8Mp9faI9yQwD3KiNrtvVwEQWk6NjNDeVYGlbBFrYfmuX/83NtArkj5nok8i8 jwPf79x856EhlyQXoGyc8eV+OdqH4UwGXAGEEfS7ZdQQVLSE3rMWlP2732VmkRwBHzarw+ uAY6z46LvMVUs8MRDJRWpUb0Wvh1QxGLRQZJz4R4syf4J1eFXTZ6tHVxL2AunWABfSevie A8PnTVprbPMwoRqcAsgOQmKzS4cM9rZSCObZVtQnrcndV0gz9t99zAJYNLd/x9hsS+Ui6E JdDiXJRHW8F/vRn1o/B00mAP3ClhHTHahDTRdZuCYXlms5INPY+bBnmwV9UISw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=S6LnKkYa; 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" X-Migadu-Spam-Score: -4.47 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=S6LnKkYa; 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" X-Migadu-Queue-Id: 0557C2B28C X-Spam-Score: -4.47 X-Migadu-Scanner: scn1.migadu.com X-TUID: SWrGr8u89pM2 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")) 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, Best regards, Juan Manuel