From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id iFUjIq7RKmOISwEAbAwnHQ (envelope-from ) for ; Wed, 21 Sep 2022 10:56:14 +0200 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 yHM+Ia7RKmOW+AAAG6o9tA (envelope-from ) for ; Wed, 21 Sep 2022 10:56:14 +0200 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 09D9DC4D4 for ; Wed, 21 Sep 2022 10:56:13 +0200 (CEST) Received: from localhost ([::1]:47644 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oavWe-0003Ex-3l for larch@yhetil.org; Wed, 21 Sep 2022 04:56:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55334) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oavVT-0003Ea-V1 for emacs-orgmode@gnu.org; Wed, 21 Sep 2022 04:54:59 -0400 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]:35509) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oavVR-0002bH-O1 for emacs-orgmode@gnu.org; Wed, 21 Sep 2022 04:54:59 -0400 Received: by mail-pl1-x62d.google.com with SMTP id t3so4983961ply.2 for ; Wed, 21 Sep 2022 01:54:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:from:to:cc:subject:date; bh=9g+ipLglIZUiaSmX28rR0LHk1WKlvLNyKP9XUCWfe9k=; b=B8zshw0D/eFG6pBrE8IhOZv7eaNrYvHDXpTx1QtjdDV0jXFbTQfTzVsTxw0fkbC/ad JG0GobdC0/Mmf7HM+/Wll8g4p36a+KvfIWw79uud6YRlnfukrm4QS/yFjokPS4yEG0WO uij+gADBSGNzLkw6/pbm9sPSI/y5mFDzaj4P7mMwz0Fn73q43wbgYTK50MfawTo2BT2n ccFPwsDfAKlw684w7EvRpqK80Lm+KG8cUpGhG06/z08yEcD5JluOl0iO9tlqKI9ox5ha fgRZbISnS0uubIhnrri8DCBUkGdISr+F2iR/0BdEv8GgdhZOOG+92LNQ1VsWSnRSn+8R F9ag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=9g+ipLglIZUiaSmX28rR0LHk1WKlvLNyKP9XUCWfe9k=; b=WnaRvNlaAC/tj5nZjgN9D+ctcvz/EuaoG3YclyfYqv4I0hd4IPBrylpRwm1DH2s8EO GMqsLd0F1dYHMV7aM3+pvZtYmsHD3mZxxwfbKUuUoJkNDyJrFtRom855I0uPNPPoO5Fg SEd6+8WtnM7SFR3n14ixdd+68lyT4XivGIkJHnfRXpWfJN4O1y2+D9mjlJK+DeLxRVRd +yR9B17y1jE0frpsRs5hQyPNC4zgelUpeTZwoi2PvrufBx/GnpPOourXFl/2FxlPjCHc IDww7VJLMkHjt6P42RPj0VUyADoGvvOWc1nXrO3eqMaa8d59q86CjbmDeBSdS6/nzvD4 K2YA== X-Gm-Message-State: ACrzQf2T2DwcIjyQ+vs5l4fkVsvokFGJo+yhFtpGvJgHcfCVkhzbnMsk +FNzL0BVtYrKvNOARy+3/Jc= X-Google-Smtp-Source: AMsMyM4kKRJe0l6pW4YPfeROj70ERgSRlKfM199dtIY4secMZkrEtkEZHZBZZzFLgQIxDNosfR0PHg== X-Received: by 2002:a17:902:7c8f:b0:176:cdd8:7258 with SMTP id y15-20020a1709027c8f00b00176cdd87258mr3599667pll.49.1663750495994; Wed, 21 Sep 2022 01:54:55 -0700 (PDT) Received: from localhost ([2409:8970:a80:3a4:8ec6:81ff:fe70:339d]) by smtp.gmail.com with ESMTPSA id s22-20020a17090b071600b002009c05b802sm1380693pjz.2.2022.09.21.01.54.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Sep 2022 01:54:54 -0700 (PDT) From: Ihor Radchenko To: Juan Manuel =?utf-8?Q?Mac=C3=ADas?= , Daniel Fleischer Cc: orgmode Subject: Re: [Patch] Pre-/postpend arbitrary LaTeX code to a section In-Reply-To: <87sfkmdkxa.fsf@posteo.net> References: <87o7vcsw8m.fsf@posteo.net> <87czbqyy5i.fsf@localhost> <87sfkmdkxa.fsf@posteo.net> Date: Wed, 21 Sep 2022 16:55:48 +0800 Message-ID: <878rmdxg17.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=2607:f8b0:4864:20::62d; envelope-from=yantar92@gmail.com; helo=mail-pl1-x62d.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 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_ENVFROM_END_DIGIT=0.25, 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.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-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1663750574; 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=9g+ipLglIZUiaSmX28rR0LHk1WKlvLNyKP9XUCWfe9k=; b=sOL30JTGV/BbCITCeqQ4AVIwPQOpFiSJe8yXeQabZ9uDXjGwKgxELRKFBAREZsKgyMrpbZ eYkUJf5tCvsjby8b2H1IsH8Hm4jjAzl3XhAsPkZAVIatrsF9wqZrGCwh7xtFt+GXhgfstH 4TGyFdbNf9RXZpZb4xl2w/r/31r8TkZGXJwjMcIwEYbUDnRir+RYf1umZvG5GYeLe4I0pR 7qmauxnhSirrF0w+KVz596fxJtu/ear6CalxI/EHePKJacnab5sebMwkNId8gHyiJ3GIow M6oomat+E7DKaft+1WshWUHwEANoF+WQbQToeRAOIpxtqPwa53mmMz6UrKwpPA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1663750574; a=rsa-sha256; cv=none; b=tXZJUaANRBpZA91ljk/L7AfgZ7uov4DyBCYMg7TswBmd8Hm/cnWnlDRBaE8EHG9Af8UZ/s mbk99f/nMGRElkHpazKdw5iA1MOi6O3b6cP7/BdxuQhmMYR5LEtYdvmc+eu736tStyNHCJ gXJx+9i65GkD0k7caIfw9sknRrL0XUpGOs6/6VemhOxFbXOLa4VunVPCvIwN5590FRKImm XFHUjMBGeUDG2Tlu+dnorxMDsree0+D3aQLVj9WKleTxWNwKRgHOfdFqCTsE/zZ2h/aGTb KSoXw93JKq2d8KVrtoW64Spb+QypaPKtbf0gmjKGBaVeYuQCaBJUKXX2QitGCQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=B8zshw0D; dmarc=pass (policy=none) header.from=gmail.com; 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: -3.34 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=B8zshw0D; dmarc=pass (policy=none) header.from=gmail.com; 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: 09D9DC4D4 X-Spam-Score: -3.34 X-Migadu-Scanner: scn1.migadu.com X-TUID: 1cWi4GCpVCAn Adding Daniel Fleischer (the ox-latex maintainer) to this exchange. Juan Manuel Mac=C3=ADas writes: > Ihor Radchenko writes: > >> I do not like this idea. >> Please remember that headlines may be exported as parts, sections, >> subsections, list items, or paragraphs depending on the headline level. >> Arbitrary pre/post commands may unexpectedly break things during export. > > I don't see why, if the user knows LaTeX and knows what he/she is doing. > Sometimes it's just adding an "\addtocontents" just before the > section/subsection,etc. The property that adds the string before and the > property that adds the string after are understood to affect the entire > heading at the current level and its contents, including lower levels. > For example, if someone wants the current heading (and all its > sublevels) not to be included in the TOC but to be included in the > headers of the pages, it would suffice to (I keep here the original name > of the properties that I proposed in the patch, but I think Maxim's > proposed name is more accurate): > > ----------------------------------- > > * Section > :PROPERTIES: > :presec: \setcounter{secnumdepth}{0} > :presec+: \addtocontents{toc}{\protect\setcounter{tocdepth}{0}\ignores= paces} > :postsec: \setcounter{secnumdepth}{2} > :postsec+: \addtocontents{toc}{\protect\setcounter{tocdepth}{2}\ignores= paces} > :END: > Lorem ipsum dolor. There is nothing wrong about this, but I feel that this kind of approach is encouraging to shoot your own leg a bit too much. It will be better if Org provides a semantics that is facilitating more safe approach. More below. > Which would pass to LaTeX as: > > \setcounter{secnumdepth}{0} \addtocontents{toc}{\protect\setcounter{tocde= pth}{0}\ignorespaces} > > \section{Section} > Lorem ipsum dolor. > \subsection{Subsection one} > lorem > \subsection{Subsection two} > ipsum > > \setcounter{secnumdepth}{2} \addtocontents{toc}{\protect\setcounter{tocde= pth}{2}\ignorespaces} > ---------------------------------- > > (The above can even be simplified from LaTeX by defining a simple > environment, but I've exemplified it like this to make it look better). > > In what situations might this return unexpected results? It may produce unexpected results if "Section" heading is demoted all the way to paragraph. Also, :presec/:postsec property names are confusing --- it is unclear if they are specific to LaTeX. (when about, say, Beamer) >> However, I do agree that per-heading control over latex export is >> currently cumbersome. >> >> The canonical ox-latex approach to customize headline export is >> org-latex-classes variable. This variable defines (among other things) >> pre/post commands during headline export: > > Apologies in advance if I misunderstood what you're suggesting, but > isn't the "org-latex-classes" property supposed to affect the structure > of the entire document? What I'm proposing here is rather something > specific to particular headings (and its entire content), like the > ":ALT_TITLE:" property. If I understand correctly, what you are > suggesting is that org-latex-classes can have "local values" for > specific headings, if such headings are 'marked' with some property? Yes, org-latex-classes is controlling the entire document. What I am proposing (as an alternative) is subtree-level equivalent of org-latex-classes that is also close to org-latex-classes semantics. More concretely, I mean something like * Section :PROPERTIES: :attr_latex: :prepend "section" \setcounter{secnumdepth}{0} :attr_latex+: :prepend "section" \addtocontents{toc}{\protect\setcounter{= tocdepth}{0}\ignorespaces} :attr_latex+: :append "section" \setcounter{secnumdepth}{2} :attr_latex+: :append "section" \addtocontents{toc}{\protect\setcounter{t= ocdepth}{2}\ignorespaces} :END: I suggest to use more canonical attr_latex that explicitly limits the export backend. Further, it mentions a regexp limiting the applicable LaTeX environment ("section"). In other environments, the code will be omitted. --=20 Ihor Radchenko, Org mode contributor, Learn more about Org mode at https://orgmode.org/. Support Org development at https://liberapay.com/org-mode, or support my work at https://liberapay.com/yantar92