From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms13.migadu.com with LMTPS id kEsDHEflf2exegEA62LTzQ:P1 (envelope-from ) for ; Thu, 09 Jan 2025 15:03:35 +0000 Received: from aspmx1.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1.migadu.com with LMTPS id kEsDHEflf2exegEA62LTzQ (envelope-from ) for ; Thu, 09 Jan 2025 16:03:35 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=berkeley.edu header.s=google header.b=fB2dzic5; 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=reject) header.from=berkeley.edu ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1736435015; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=uFCV1yNbwluS+eqjrshFI2KRlAuarKkB6A9XisgFOwg=; b=g6aVKK3PuIf7cZ3E7tNaNuPYldxQj+svI8rvtmzZe7NE4gMWfwbc40nTKU1K7g/2swcsdl Hc8pIQuK0mK7MBoAhYa9E8vZPq88osF/dxg7TUrenhubb5A4gq9DmjhOgCneilPkW7JnAp 2tyZOInunDF7Yb/OPt6GsiNcOie6xc7aevv/F5PeM0GsVHcdk7OJvvovxD7rPpKGL3vlFF BXK2nfu5Cuh2CkUFNd3/ztcYOFla3YbZeD+gQiN7yHfB1EEC4pBXBdxPjUza4m535H/2zI h7qDjrZiCUuBYun8PIE+Dj7zoTGmu4kqgsZ+B+Y6ft7bc38rR83+l0jinf9GWw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=berkeley.edu header.s=google header.b=fB2dzic5; 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=reject) header.from=berkeley.edu ARC-Seal: i=1; s=key1; d=yhetil.org; t=1736435015; a=rsa-sha256; cv=none; b=G3bulALPUZpWYHO5M2SBouBwhW44NryEyOMMXYvELTTRidcUO4+IzQRYQ3cvq9zeZzb0bE olssPz1yHSeWfD635IZ5Cgzw53I7P4BBNEB3T115XxplpDFAAvUt1DV/gjiqNVXcXxQuH9 NqEp5G+nAHKXKAjTE/DfKDFI+Xt1vonj/ZAlA7tJu5yBlNXKPXOVau9p+1lpoYYzOj4wAe kmUAHyp7xdgpY+EAk7/Jagv2DzfxRu2IHLjryRRXbVpPp1st93eu6Vg97ScjmJWyoW1SPr Xq6NVw6rgajVgOMOVqrQ+Es3hH1F3X6St3ozZDF7gQ3on8nIcA3z9BtGNguv8w== 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 F2462971F4 for ; Thu, 09 Jan 2025 16:03:34 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tVu3W-0001OM-9W; Thu, 09 Jan 2025 10:02:42 -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 1tVu3U-0001OE-I5 for emacs-orgmode@gnu.org; Thu, 09 Jan 2025 10:02:40 -0500 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tVu3S-0001ll-AO for emacs-orgmode@gnu.org; Thu, 09 Jan 2025 10:02:40 -0500 Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-21634338cfdso23190245ad.2 for ; Thu, 09 Jan 2025 07:02:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=berkeley.edu; s=google; t=1736434956; x=1737039756; darn=gnu.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=uFCV1yNbwluS+eqjrshFI2KRlAuarKkB6A9XisgFOwg=; b=fB2dzic57UR14XLNeypJH6Lmo5t8fdBaGZ9P+vtnmzxRbnzYEXj2CRZtgpqtGq2D0j lp9A1yZhOn6JR1EALLFPdHL79UsaAdo4MaX9ePK3nLdY03gyOdm5006YeWA58+vMEKFb t63NctRSdMQYX5VS453Vu4aUQo/047QBnEw9MER9BbLHIm+ek6uFX9vA5S0YK6PnzQSS r1iSUJxDOPIGg2SqD8H39Y2Ik1ZKNEsnzCZUJ4aGhg3sdycMDorgZhazQfjoKLA4Jggp OeU65E/FADl4bIsbijgVPkmvjN2Kyn81bOqye9qpaToPzIJSrtcHYp539/MyEYqQAMdz rBtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736434956; x=1737039756; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uFCV1yNbwluS+eqjrshFI2KRlAuarKkB6A9XisgFOwg=; b=hY8UpNJqCE+aJGw0IjbYNPJuLv1dm3Amg55BN7p3kV1p0pYDEs9HhrHDFyCpQufCjZ K/IohGo+wr3D+0faUktYyrv+ZQhzZStQLD5PN4YlxUNNxZHvp1R3bSQV5ECPlDkPg095 +q3ipN1d7s1Zxv/4TReUTwN09MAEFJLrO93vk7QY/m8Iah5iK5N5FTrq/J27jif5DcvR rV6ROnNDECAm7mr+vRuRXH1C+G+7UvzsvMnaGRWoaqeK1VneKSQbK1/+lmY92Zs4XECl lh73mgSe67HQk7MF5OwJnjI/NLjs8VR1xs2mQf1saHeo9/ygzqVoIIlA1mitkEJxReiG B0yw== X-Gm-Message-State: AOJu0YwdvzhqYaPsVRzCBteKfgwU8pvCbiigU/VJleE8hS74OMU8f7QB q1RtVnAR+NZ+iZdv1dADNfrWYNOwjOdCSqj/Jb46wkhbgjwQ1fGQojQr1f4vNWJVy9MjqEKLZHB s9w== X-Gm-Gg: ASbGncvCEDa5bH5LHNUW5sZvykH+zwbdQVdYGx/tp2gVUAq3fhH7gDWIEy6fg7w4GFu oQaBws+53Y4wqijRKHFXRUgAwjO64LzwOhGpb0/SL2gG+h61ZG5hmvlUofqwEo5LH1yJkHUv2TM lsVJqcjupYpLZrKPbyV3Pe6aYhnb/jgQ/Kk0l7SG1NAJUJlEVffeKbkFzKVHjjMbAHgwlVKqm/4 MGWPE39TNWHhOYLSmZ/t1trlwJ2wwViVxDceSkgxYT48wsnZDHbVr+tBX0uW4+n5SaeKRuB7RMW buCTbUzwmYyMa3EASD8oWzOs6sM46cOe73C0xJVxd5LVgis= X-Google-Smtp-Source: AGHT+IH/vU4aDGmRI0wkKpkCrQBl0AES5pTa/vVKcBvx+hKESaRpldv52iVejihmIU0HaOhu59/NEw== X-Received: by 2002:aa7:820b:0:b0:72d:2444:da2d with SMTP id d2e1a72fcca58-72d2444dacemr6681918b3a.9.1736434953992; Thu, 09 Jan 2025 07:02:33 -0800 (PST) Received: from smtpclient.apple (157-131-199-171.fiber.dynamic.sonic.net. [157.131.199.171]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad831153sm36996468b3a.50.2025.01.09.07.02.33 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Jan 2025 07:02:33 -0800 (PST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3826.300.87.4.3\)) Subject: Re: How to specify column alignment in LaTeX table output? From: Richard H Stanton In-Reply-To: <87wmf4qoju.fsf@rensoliemans.nl> Date: Thu, 9 Jan 2025 07:02:22 -0800 Cc: emacs-orgmode@gnu.org Content-Transfer-Encoding: quoted-printable Message-Id: <9F2C7295-E505-47DA-BF76-078F0C28B9E6@berkeley.edu> References: <87wmf4qoju.fsf@rensoliemans.nl> To: Rens Oliemans X-Mailer: Apple Mail (2.3826.300.87.4.3) Received-SPF: pass client-ip=2607:f8b0:4864:20::630; envelope-from=rhstanton@berkeley.edu; helo=mail-pl1-x630.google.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.369, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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.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: -6.19 X-Spam-Score: -6.19 X-Migadu-Queue-Id: F2462971F4 X-Migadu-Scanner: mx10.migadu.com X-TUID: NdVobYms6QvK On Jan 9, 2025, at 2:17=E2=80=AFAM, Rens Oliemans = wrote: >=20 > Richard H Stanton writes: >=20 >> Here=E2=80=99s a table in my org document: >>=20 >> #+ATTR_LATEX: :align rrrr :options [htbp] >> #+begin_table >> |-------+--------+-----------+------------| >> | Tier | Number | Total | % of Total | >> |-------+--------+-----------+------------| >> | 1 | 4 | 8,700.00 | 57.39 | >> | 2 | 19 | 5,398.00 | 35.61 | >> | 3 | 24 | 1,061.40 | 7.00 | >> |-------+--------+-----------+------------| >> | Total | 47 | 15,159.40 | 100.00 | >> |-------+--------+-----------+------------| >> #+end_table >>=20 >> I want all the columns to be right-aligned (as they are in the org = document), but when exported to LaTeX/PDF, the =E2=80=9CTotal=E2=80=9D = column in the output table is left aligned instead. Here=E2=80=99s the = relevant section of the .tex document generated during PDF export: >=20 > Remove the #+begin_table and #+end_table parts: table isn't a valid = block type. > 'C-C C-,' (org-insert-structure-template) shows you what blocks are = valid. >=20 > A table is simply defined via lines starting with '|'. This should = work: >=20 > #+ATTR_LATEX: :align rrrr > |-------+--------+-----------+------------| > | Tier | Number | Total | % of Total | > |-------+--------+-----------+------------| > | 1 | 4 | 8,700.00 | 57.39 | > | 2 | 19 | 5,398.00 | 35.61 | > | 3 | 24 | 1,061.40 | 7.00 | > |-------+--------+-----------+------------| > | Total | 47 | 15,159.40 | 100.00 | > |-------+--------+-----------+------------| >=20 > Also, I think your :options is a bit weird. Your exported LaTeX code = seems fine, > but that's a side effect of you having the #+begin_table blocks, I = _think_ Org > creates a special 'table' environment based on your block name = ('table'), which > makes your :options work. See "(org) Special blocks in LaTeX export" = in the > manual. >=20 > To make your desired placement work with a "correct" table, see "(org) = Tables in > LaTeX export" and the documentation of ':placement': >=20 > =E2=80=98:float=E2=80=99 > =E2=80=98:placement=E2=80=99 > The table environments by default are not floats in LaTeX. To = make > them floating objects use =E2=80=98:float=E2=80=99 with one of = the following > options: =E2=80=98t=E2=80=99 (for a default =E2=80=98table=E2=80= =99 environment), =E2=80=98sideways=E2=80=99 (for a > =E2=80=98sidewaystable=E2=80=99 environment), = =E2=80=98multicolumn=E2=80=99 (to span the table > across multiple columns of a page in a =E2=80=98table*=E2=80=99 = environment) and > =E2=80=98nil=E2=80=99. In addition to these three values, = =E2=80=98:float=E2=80=99 can pass > through any arbitrary value, for example a user-defined float = type > with the =E2=80=98float=E2=80=99 LaTeX package. >=20 > LaTeX floats can also have additional layout =E2=80=98:placement= =E2=80=99 > attributes. These are the usual =E2=80=98[h t b p ! H]=E2=80=99= permissions > specified in square brackets. Note that for =E2=80=98:float = sideways=E2=80=99 > tables, the LaTeX export backend ignores =E2=80=98:placement=E2=80= =99 attributes. >=20 > I think that this org snippet is what you are looking for: >=20 > #+ATTR_LATEX: :align rrrr :float t :placement [htbp] > |-------+--------+-----------+------------| > | Tier | Number | Total | % of Total | > |-------+--------+-----------+------------| > | 1 | 4 | 8,700.00 | 57.39 | > | 2 | 19 | 5,398.00 | 35.61 | > | 3 | 24 | 1,061.40 | 7.00 | > |-------+--------+-----------+------------| > | Total | 47 | 15,159.40 | 100.00 | > |-------+--------+-----------+------------| >=20 > --=20 > Best, > Rens Thanks, Rens. That works and looks a lot neater than my version, which I = arrived at through trial and (mostly) error... I actually generate this table from a Python code block. In the past, = I=E2=80=99ve often run into problems with raw output (like this), where = running the code block multiple times causes the output to appear = multiple times, rather than overwriting. I found that using :wrap seems = to prevent this. I have no idea where =E2=80=9C:wrap table=E2=80=9D = comes from, but org exported this without error, so I stopped thinking = about it=E2=80=A6 Trying it with raw output just now, the table seems to = be overwritten just fine when I run the code block multiple times. So = maybe I don=E2=80=99t need to worry about this any more, but what are = the recommended headers for a Python code block that exports a table? = For example, ":results output raw=E2=80=9D and ":results output = drawer=E2=80=9D both seem to work (without :wrap), while =E2=80=9C:results= output=E2=80=9D puts everything in an example block, which then seems = to get exported verbatim, not as a LaTeX table. Best, Richard