[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Patch] Pre-/postpend arbitrary LaTeX code to a section
From: |
Ihor Radchenko |
Subject: |
Re: [Patch] Pre-/postpend arbitrary LaTeX code to a section |
Date: |
Tue, 20 Sep 2022 21:26:49 +0800 |
Juan Manuel Macías <maciaschain@posteo.net> 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.
>>
>> Instead of a cons cell (numbered . unnumbered), you can also
>> provide a list of 2 or 4 elements,
>>
>> (numbered-open numbered-close)
>>
>> or
>>
>> (numbered-open numbered-close unnumbered-open unnumbered-close)
>>
>> 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.
>>
>> 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.
--
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
- [Patch] Pre-/postpend arbitrary LaTeX code to a section, Juan Manuel Macías, 2022/09/18
- Re: [Patch] Pre-/postpend arbitrary LaTeX code to a section, Max Nikulin, 2022/09/18
- Re: [Patch] Pre-/postpend arbitrary LaTeX code to a section, Fraga, Eric, 2022/09/19
- Re: [Patch] Pre-/postpend arbitrary LaTeX code to a section,
Ihor Radchenko <=
- Re: [Patch] Pre-/postpend arbitrary LaTeX code to a section, Juan Manuel Macías, 2022/09/20
- Re: [Patch] Pre-/postpend arbitrary LaTeX code to a section, Daniel Fleischer, 2022/09/21
- Re: [Patch] Pre-/postpend arbitrary LaTeX code to a section, Juan Manuel Macías, 2022/09/21
- Re: [Patch] Pre-/postpend arbitrary LaTeX code to a section, Fraga, Eric, 2022/09/21
- Re: [Patch] Pre-/postpend arbitrary LaTeX code to a section, Ihor Radchenko, 2022/09/22
- Re: [Patch] Pre-/postpend arbitrary LaTeX code to a section, Max Nikulin, 2022/09/21