From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id 6LaKJnDyKWMCXgAAbAwnHQ (envelope-from ) for ; Tue, 20 Sep 2022 19:03:44 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id WAOXJnDyKWNGJwEA9RJhRA (envelope-from ) for ; Tue, 20 Sep 2022 19:03:44 +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 4C97D33171 for ; Tue, 20 Sep 2022 19:03:44 +0200 (CEST) Received: from localhost ([::1]:37526 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oaget-00084x-BG for larch@yhetil.org; Tue, 20 Sep 2022 13:03:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57336) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oadGG-00022v-IQ for emacs-orgmode@gnu.org; Tue, 20 Sep 2022 09:26:05 -0400 Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]:55928) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oadGE-0003Dx-JX for emacs-orgmode@gnu.org; Tue, 20 Sep 2022 09:26:04 -0400 Received: by mail-pj1-x102c.google.com with SMTP id fs14so3026831pjb.5 for ; Tue, 20 Sep 2022 06:26:01 -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=LgjvG8m7yR94I5KgaGbWt6xrSSbN/48nH2I8cwbKxqA=; b=MkJnIu4JxYxOLJEWvchogTxUsOg/XnjeO+ApH+JDkkgQfk6iQ7E5YY0gS4IzKTPm87 +TJfv512DN9CvSb8ooq2IA1qDxiolBuPDQ3P1RVN65Lymxlex+3FXURxwgAGM0PsV9pc P5caEYzj/NWRAnEryZdU72eFAWEjts1OagDzPCAkUgHjuVe6z1dj8NWadzlMxWuCTezO GHSwVLDLyp9V1EnCwDtOwd5JvXWeOMTjzg8Iha4dfD22sw3v8DtnpR1ia3yqkOQbSA4T dg77bq468aAudnfEE11Q06gU/tlHAm1R8CjDLlUewfAHBLo5Mo0yLhD0HFTINqTUuWlm f/fg== 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=LgjvG8m7yR94I5KgaGbWt6xrSSbN/48nH2I8cwbKxqA=; b=dFp6iW63HBDjVQmoqQDMLvrFzsBa8wJqTilHta+CiE4lfmabnZYjNGoAzq7/cN9ntV Vqj9liB06uVz8RngCGv2OP8zy2ziwc7Bu589SKXeRNmpdI26Mw0VwdPpx9wmK4BeScuB rZkhOekwMVLhlXNTtEloOp2IZJdkjK4TfCG+f5cWRlA0KgA2tvlZtmXRM/JixljYm37U uBrkYNee1Lj5XFWwN6MENJ0yPtIKckmQEg4C9/cGPgmAuwCxL0BGtmq6nHnS5774UrEG oxkUeGNk2UEx1gRrd1/UiMeQhaLCFUoVr+w9KMLKm/YiFMBnvNmunWDBxJpQF72v6Frc HpMw== X-Gm-Message-State: ACrzQf1yFJVkUO8pSXIJfxpz0ytuA4QpQ1vpjrQzJYgGBUI4cOhXdo92 a1OYpXdKy3VGM8QV2kxjK+KJ59/ZFJk= X-Google-Smtp-Source: AMsMyM556+kT6mGIh7laGVSLlDcQ8mf+WpygoGfLQYD/wN6PPMuGUDEZRfdg4dxwlXEpT7VqOTl/wQ== X-Received: by 2002:a17:90a:8909:b0:203:ab27:a41 with SMTP id u9-20020a17090a890900b00203ab270a41mr3956225pjn.163.1663680360222; Tue, 20 Sep 2022 06:26:00 -0700 (PDT) Received: from localhost ([2409:8a70:2b5:ad00:8ec6:81ff:fe70:339d]) by smtp.gmail.com with ESMTPSA id g4-20020a1709026b4400b0017828ae6310sm1439074plt.2.2022.09.20.06.25.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Sep 2022 06:25:59 -0700 (PDT) From: Ihor Radchenko To: Juan Manuel =?utf-8?Q?Mac=C3=ADas?= Cc: orgmode Subject: Re: [Patch] Pre-/postpend arbitrary LaTeX code to a section In-Reply-To: <87o7vcsw8m.fsf@posteo.net> References: <87o7vcsw8m.fsf@posteo.net> Date: Tue, 20 Sep 2022 21:26:49 +0800 Message-ID: <87czbqyy5i.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::102c; envelope-from=yantar92@gmail.com; helo=mail-pj1-x102c.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=1663693424; 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=LgjvG8m7yR94I5KgaGbWt6xrSSbN/48nH2I8cwbKxqA=; b=T5VXuKp9klN81BMdWVQJwXAvxMm7h4G7bJD2Z1abvluBtn9sV72aSG3HnVU4zwbjVd66de y/+8ljK5NTEfUKn990h6SZbYwVGcIZAEj1moQbiUrqaXPCQEY0oD3etuKffRL37D02yHxC aa+EmyUV/DVLpXVnfhC+3NimuxG/Ra6+VrMIU0C1F7sLb8w7Y8OC+6FyQaJ4kq+iy/dhqZ 6X2YWxkuua9ni19J0ZgS0SjilUBqabCd+jqPY0a2h6N8SZSOQLUhpRXiq/zyeXZ5yLdNZM 8K3v073CWXSwFH22Kfgga/TV7h5aaO4km2n4cyYqXY22jALb7lSq3rR/9nVR3w== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1663693424; a=rsa-sha256; cv=none; b=KVXyQPIRyOY1CviUl8HUg5qQz32IBrrQC9B94MCeB05ri48gtbPgSquz7h1NV3jDCASLa7 iNTC5IfmlL2tg5CznaPnYg1tfrfUmtmLM0RaD6xPhqa9mohWigd71TwhGkg8r/AHrpvq5p 8IU47iThvznJzUfKecGQbEdvJ+BkLIGEGWi11qOgNMjiItKWYd6sykfVVy/5VI2fYLx02F 2i9MetoOgLt45VtDlZuOHfqa/wAvKECH8ILTMBpPoqCAuN9ILaNi2nVXqAZezmaRTmU/8V mFDzWtOpljCQzRXw3AyZr32TT2dDvVnOYQmZ++i/OlYtKe48trxDqbLbxQj2PQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=MkJnIu4J; 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: -1.83 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=MkJnIu4J; 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: 4C97D33171 X-Spam-Score: -1.83 X-Migadu-Scanner: scn1.migadu.com X-TUID: 4r6StY0pHA38 Juan Manuel Mac=C3=ADas writes: > I don't know if the following scenario usually appears in the workflow > of other Org users as well. Otherwise, I think this patch could be > ignored. > > In my workflow I often need to pre- or postpend some LaTeX code > immediately before or after a section. Consider the following example: > > ------------------ > * A section > > Lorem ipsum > > #+latex: \foo > > * Another section > > Lorem ipsum > ----------------- > > The \foo command affects the second section, but for Org it belongs to > the content of the first section. If I comment this section out or mark > it as non-exportable, then the LaTeX code has no effect. I think a > simple solution could be to have the PRESEC AND POSTSEC properties to > prepend or postpend arbitrary code to a section. These properties could be > extended with PRESEC+ and POSTSEC+. An example of use: 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. 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: >> The sectioning structure of the class is given by the elements >> following the header string. For each sectioning level, a number >> of strings is specified. A %s formatter is mandatory in each >> section string and will be replaced by the title of the section. >>=20 >> Instead of a cons cell (numbered . unnumbered), you can also >> provide a list of 2 or 4 elements, >>=20 >> (numbered-open numbered-close) >>=20 >> or >>=20 >> (numbered-open numbered-close unnumbered-open unnumbered-close) >>=20 >> providing opening and closing strings for a LaTeX environment >> that should represent the document section. The opening clause >> should have a %s to represent the section title. >>=20 >> Instead of a list of sectioning commands, you can also specify >> a function name. That function will be called with two >> parameters, the (reduced) level of the headline, and a predicate >> non-nil when the headline should be numbered. It must return >> a format string in which the section title will be added. What about allowing to customize these open/close statements on per-heading level during export? This will be more consistent with the existing ox-latex structure. --=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