From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:403:4ea1::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id WL4vBWUUymHHeAEAgWs5BA (envelope-from ) for ; Mon, 27 Dec 2021 20:30:45 +0100 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id wKShOmQUymFG1wAAG6o9tA (envelope-from ) for ; Mon, 27 Dec 2021 20:30:44 +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 9C90F1E5E3 for ; Mon, 27 Dec 2021 20:30:44 +0100 (CET) Received: from localhost ([::1]:37246 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n1vhj-00022K-Db for larch@yhetil.org; Mon, 27 Dec 2021 14:30:43 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35788) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n1vfx-00020e-V9 for emacs-orgmode@gnu.org; Mon, 27 Dec 2021 14:28:56 -0500 Received: from mout01.posteo.de ([185.67.36.65]:57293) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n1vfv-0004ox-IP for emacs-orgmode@gnu.org; Mon, 27 Dec 2021 14:28:53 -0500 Received: from submission (posteo.de [89.146.220.130]) by mout01.posteo.de (Postfix) with ESMTPS id D7D27240028 for ; Mon, 27 Dec 2021 20:28:43 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1640633323; bh=z77L5pqbj2Qi+32dX7DZLJgoARUZUoB2hm/UuIwVYuQ=; h=From:To:Subject:Date:From; b=VqLrD2xsFABNUcIhxMLIa4V3sqDfDq84ZmsNhi5yJPFLH0hLQN7kjND0zmnwqjV/Z KjBPCF5FjDyUZXnvNsY9qZf0RzadG/sDIBOwg7bvGxIdjpuspZvDlP5CrwBVsDPLmf 0P7S6hw+HHFr8G9AKGKUsHxS2+EwvwZnHmvUT9w7ITVdN/jVzZnR2If+1jbSNgP/WJ vWlr01X/9XG1jVmc/OPAcb4DAlgHMwKUpyQf5jZ5eC2RrS1suIb8LUydrzjJuvL+Wj Y17BC3Cly706xr60It3L0/XmrQXYYg41s/uUwN1BDsqlqVPhqmNINdJuzLi1FCdQS5 cvHVqgPZUW9pQ== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4JN74q1lxSz6tnk for ; Mon, 27 Dec 2021 20:28:43 +0100 (CET) From: =?utf-8?Q?Juan_Manuel_Mac=C3=ADas?= To: orgmode Subject: Re: caption width in LateX export References: <87lf06q1t9.fsf@phoca.sebkatja.org> <874k6utry0.fsf@posteo.net> <87h7aup5u1.fsf@phoca.sebkatja.org> <87ee5yxjmf.fsf@posteo.net> <87czliotnw.fsf@phoca.sebkatja.org> Date: Mon, 27 Dec 2021 19:28:40 +0000 In-Reply-To: <87czliotnw.fsf@phoca.sebkatja.org> (Sebastian P. Luque's message of "Mon, 27 Dec 2021 11:16:03 -0600") Message-ID: <87ilv9q23b.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: , 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=1640633444; 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:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=EHsSkyrG/Fg/YcKf8FCcGbPeLHnkqw4Y0HKyhpHaRZI=; b=X65+gE9ruEHew7ZeCc5L0YBaE5l5lFB0Bgsm2gXUftuGehoTRgW7UJvV5bEsXBGTx8Hcr+ g/7tF1hjK8nhLYk3a3rs5nFL1Hv5NAD62XepFQrTO89UvgFWPwzmDJTALGhcxaHkP+M/WP G2j9sHuH9ABn2tB7sxnJmklf75nnu9g90bfFY8+2w8kowMi1skOwGCEmLRqnXFB1yMfMiV +BgoVWmVr+ZtKMCB+hWHk4E0eO23G/e7sIdgGAzpKIonLocpMUzabbLWOgrIo6bGL4M17S ANLKzBlAyIzPKXjVysXoPIalVniWz1JIP68Ll8pKPcukOGEQSBsIb/hG5/jcvg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1640633444; a=rsa-sha256; cv=none; b=gemZ1nvlgTKaqjMK7q6ImRlnvkEL7qzQeMkdjMjJuQdknGaRo5IDivkX0LDmjam75l1OEI yQ86fe5prqL4TUBoIhlwE15gE+xXCNYXeBcCfubAQfTyBp322zKQAqtLlw4l6hsNOHmwE9 mqvKEKi+mWCN+8P0ZKLJRh5SATPVk3RkheG5SN7HQJoZc5G1jqZU8cZOu88AglG0JvII6K fDD0CtCuNfN7cqTzVRsj+BXYvZwck8B2tj5vL2KlEjTOTa21zxvPbIKwAA2MLkENQYq7o8 oklwRbRU8TMBwLXTropsIMz9EiQRPgbmvYqyGRbba2pGCH3iuhLH2hO+throFg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=VqLrD2xs; 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=VqLrD2xs; 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: 9C90F1E5E3 X-Spam-Score: -4.47 X-Migadu-Scanner: scn1.migadu.com X-TUID: IFrp1NiWsQn/ Sebastian P. Luque writes: > This is great, and very interesting to learn about the BIND keyword. > > Thank you, You're welcome. Of course, if you use the filter very often, it is not necessary to include it in a document or use the bind keyword. It would be enough to add the function to your init and the line: (add-to-list 'org-export-filter-final-output-functions #'caption-auto-width) In a case like this, however, I would prefer to use the other function in Lua within LuaTeX, since two commands could be defined: one to enable the automatic caption width and one to disable it, throughout the document. E.g.: #+begin_src latex \usepackage{luacode} \begin{luacode*} function caption_width ( text ) text = string.gsub ( text, "(\\includegraphics.+)", "\\sbox0{%1}") text = string.gsub ( text, "(\\caption.+)", "\\begin{minipage}{\\wd0}\\usebox0%1\\end{minipage}") return text end \end{luacode*} \newcommand\CaptionAutoWidthOn{\directlua{luatexbase.add_to_callback ( "process_input_buffer" , caption_width , "caption_width" )}} \newcommand\CaptionAutoWidthOff{\directlua{luatexbase.remove_from_callback ( "process_input_buffer" , "caption_width" )}} #+end_src \CaptionAutoWidthOn #+CAPTION: Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec hendrerit tempor tellus #+ATTR_LaTeX: :width .3\linewidth [[img.jpg]] \CaptionAutoWidthOff #+CAPTION: Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec hendrerit tempor tellus #+ATTR_LaTeX: :width .1\linewidth [[img.jpg]]