From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id qCL1DYp3Y2EtcQEAgWs5BA (envelope-from ) for ; Mon, 11 Oct 2021 01:30:18 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id CFWFCYp3Y2HgFgAAbx9fmQ (envelope-from ) for ; Sun, 10 Oct 2021 23:30:18 +0000 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 916373230A for ; Mon, 11 Oct 2021 01:30:17 +0200 (CEST) Received: from localhost ([::1]:57494 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mZiGm-0004m3-J8 for larch@yhetil.org; Sun, 10 Oct 2021 19:30:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39470) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mZiG6-0004lu-Bj for emacs-orgmode@gnu.org; Sun, 10 Oct 2021 19:29:34 -0400 Received: from mail-pj1-x102b.google.com ([2607:f8b0:4864:20::102b]:39780) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mZiG4-0004xe-Lo for emacs-orgmode@gnu.org; Sun, 10 Oct 2021 19:29:34 -0400 Received: by mail-pj1-x102b.google.com with SMTP id ls18-20020a17090b351200b001a00250584aso12874929pjb.4 for ; Sun, 10 Oct 2021 16:29:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:in-reply-to:references:date:message-id :mime-version; bh=uu2720R0HFJpKB5vnPJTcPMHF6McrXCibzka90qtiWo=; b=c07JINYnm0zxlJ3F/8KJs+CHTIHJYP7nAOT1OTtK1tEI0cz/OYfn7Qseoekq0GNI51 uZ7iZmOt5BQOe4ZrvviZrmiw0oyc3GswEVby7lryM3LFLcy4XPnvDNyv+58/e6JrszzU sYSnRiHkkij005OiJMWEZPecQnwU2m6RCwX2kHqrnS9uXnJ5HzYi+2iB880UPYPlYb1G 0wTe0kQI8KM1Z+kwHY7vS++U3mcwft4f58XuSujdt0J01H8LoAoeNXBtrBdsBW6rwiq6 Uxw4dA+DBEVo4XTa69+DFZVbnG5SE4rylaAhi/nA372sxKfAbai4T9Lk7pYUkE4nPksT qlOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=uu2720R0HFJpKB5vnPJTcPMHF6McrXCibzka90qtiWo=; b=SZb7fDf+cuZ/CkQwO5/WcwJ1azfrhmRwVv8JPI258jF6sU+m4FLh65KVOi5uqX0zHC phHuVrkRW7ijIQXDkfAc3wvaq9c49dVSWbLG8x5zNiqbRel0ZMQT8nSMFpX+bmKwtTCe Hwx9eynDlo8V8cJAl/zst1+/f+524dyGNlVoRB006ReNFqhylyLXaCDOqZ0jiXPwlmIw QlMyqmrefyqCF9DRmanOkhnjISaITVhAds4vlVul0xi8WZ3gOsx3MTCmyH30wpBMS2zY Gy2ccQTFWmvuiv/gtMp/vG9VNLoRDatAfxsqMaUnsi/cfskmGiN7tvASqaf6zQCXFGO6 tAZw== X-Gm-Message-State: AOAM533+x6zhmxsBDBUeKtQiWcabFTR5ZBdezHNnIBfbt/uqa0VQ94qJ DirBaopR0Ed69AGKcNqI1urNn1DO04w= X-Google-Smtp-Source: ABdhPJwVgwZwBrk3z+eX68UhkQ2SGBRuwMQRTyAPPQq+vf1y8kxKx60oKnFwEIGkITEYOaYqQRC1GQ== X-Received: by 2002:a17:902:e883:b0:13f:1393:d185 with SMTP id w3-20020a170902e88300b0013f1393d185mr16341603plg.64.1633908570554; Sun, 10 Oct 2021 16:29:30 -0700 (PDT) Received: from ryzen3950 (c-73-170-21-48.hsd1.ca.comcast.net. [73.170.21.48]) by smtp.gmail.com with ESMTPSA id w185sm5413755pfd.113.2021.10.10.16.29.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Oct 2021 16:29:29 -0700 (PDT) From: Matt Huszagh To: "emacs-orgmode@gnu.org" Cc: Subject: Re: Patch to align baseline of latex fragments and surrounding text In-Reply-To: <874k9oxy48.fsf@gmail.com> References: <874k9oxy48.fsf@gmail.com> Date: Sun, 10 Oct 2021 16:29:28 -0700 Message-ID: <871r4sxxuv.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=2607:f8b0:4864:20::102b; envelope-from=huszaghmatt@gmail.com; helo=mail-pj1-x102b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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.23 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 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1633908617; 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=uu2720R0HFJpKB5vnPJTcPMHF6McrXCibzka90qtiWo=; b=J6RRkt4zukYnc48e6+rn/RLpqoO4iHz0KyUhdivJJSyS0gnML+jHm5+Rsy2rWmE3HPeAFJ 7H7UsZN7OCT8PzRvtiGGx8ko93SFiJTSAz3gnd33+yrSl4dPkPx0tEFZ/cN43EvPeQAFZN kWpT4yd3z6uwum242z5x9rgzwo+dpNmB1hdIaHGnjsFjuMCJp8xLwRMumvsO1i+uqSlKlA zcV9XT0caIZqM5bT5l9GexggvH2F78giS2BHIk8kXMTwP9eu3qPIejhAputhr0Njk1L327 9cvB7a/miy9eWTjlIStF3N5Lwsh7uO86F/z8KE1nsaPQOUES9vf4SE8NadAMZQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1633908617; a=rsa-sha256; cv=none; b=Itpppmf1LTGJquCFjlW2A/zcbTRanvoy1P8mR6telCOi94tOuPfusSxVTjwIcI3dPkTQIh r5iaOSNn38xVvN79wdNmJODvx5myBpLuEYFGVQTzBU85mW1sDlXA4t3qU0xXxYS1TJuzUn 0CHFVRVGGJaTQatFNnRWQGRKNeS4f+SZuZ/aSu5SkgaH/IZ/9sk7K3GBnAr5HrB5WNSZP9 GFgvy6T9UWeCDLKJ9WeJUhuwHjZS0GImfBRJbWWxsFMfrwyWS4fUESG8fmxNP5GrMqLULM KlA63hbu2z0gNfguHWUgQHlOyk4Kn4G1U5dVJeuRvvNduUM6jiDdclklc15EWw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=c07JINYn; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Spam-Score: -1.61 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=c07JINYn; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Queue-Id: 916373230A X-Spam-Score: -1.61 X-Migadu-Scanner: scn0.migadu.com X-TUID: MLNvu8XC7W9d Matt Huszagh writes: > I've created a patch to align the baseline of latex image fragments to > the surrounding text. The patch consists of several parts. First, it > adds a customizable variable that can be set to a user supplied function > to compute the value of :ascent passed to `overlay-put'. It can also be > set to a symbol (e.g., 'center, which is the current setting and still > the default), or an integer (:ascent can take an integer > percentage). The patch also modifies `org--make-preview-overlay' to use > this new variable. > > The other part of the patch is a new function that computes the correct > value for :ascent from an SVG file. > > Unfortunately, this isn't a general-purpose solution to baseline text > alignment. It currently only works with SVG images and requires that > these SVG images encode the text baseline in the viewBox attribute (I've > explained in the function documentation how to achieve this). > > I was not initially planning to include the function because it only > works in certain special cases (though if you setup your SVG image > generation as I've described in the documentation it should work > correctly for all of your LaTeX fragments). However, I ultimately > decided it was beneficial to include it for several reasons: (1) it > would not be obvious for many users how to write this function on their > own, (2) by including it, others can improve upon it, and (3) I tried to > minimize corner cases by leaving the default value as 'center and having > the function return 'center whenever it detects an incorrect :ascent > value. I should also mention that I've tested this for different image scaling factors (`:image-size-adjust' in `org-preview-latex-process-alist') and it works regardless of the scale factor. That is, the baseline will be correctly aligned irrespective of the scale factor you set (though obviously the text median (https://en.wikipedia.org/wiki/Baseline_(typography))) will only match the surrounding text for the correct scaling factor. Matt