From: "Berry, Charles" <ccberry@health.ucsd.edu>
To: "Sébastien Gendre" <seb@k-7.ch>
Cc: emacs-orgmode <emacs-orgmode@gnu.org>
Subject: Re: Using Org-mode macros as LaTeX macros
Date: Sat, 1 Jun 2024 18:06:55 +0000 [thread overview]
Message-ID: <ECE5257B-228D-4102-869C-549988AC6E94@health.ucsd.edu> (raw)
In-Reply-To: <87mso4lvfc.fsf@k-7.ch>
Sebastien,
One way to propagate values prior to export is to use named src blocks and noweb references to them.
For example, the following code:
---
#+name: orga-def
#+begin_src latex :exports none
my old school
#+end_src
#+begin_src latex :noweb yes
\begin{titlepage}
Some custom LaTeX here
This is my school:
<<orga-def>>
\end{titlepage}
\newcommand{\orga}{
<<orga-def>>
}
#+end_src
----
will export as
---
\begin{titlepage}
Some custom LaTeX here
This is my school:
my old school
\end{titlepage}
\newcommand{\orga}{
my old school
}
---
if the latex is activated in `org-babel-load-languages`. You can customize this easily.
Or you just can `(require 'ob-latex)`.
You can preview the latex produced by eval-ing the src block or executing `org-babel-expand-src-block` (C-c C-v C-v) to see the latex produced.
Note that I added newlines around `<<orga-def>>` which was not necessary for this example, but if multi-line codes are used in the `orga-def` block, noweb will prefix/postfix each line and that could be a headache. See `Noweb Replacement Syntax` in the manual for more detail on prefixing.
HTH,
Chuck
> On Jun 1, 2024, at 5:05 AM, Sébastien Gendre <seb@k-7.ch> wrote:
>
>
> I need to have an Org document that could be used as easily as possible
> by anyone else. Sadly, having to define new Emacs function could be too
> much for what my school ask.
prev parent reply other threads:[~2024-06-01 18:08 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-01 5:48 Using Org-mode macros as LaTeX macros Sébastien Gendre
2024-06-01 7:36 ` Bruno Barbier
2024-06-01 12:05 ` Sébastien Gendre
2024-06-01 18:06 ` Berry, Charles [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ECE5257B-228D-4102-869C-549988AC6E94@health.ucsd.edu \
--to=ccberry@health.ucsd.edu \
--cc=emacs-orgmode@gnu.org \
--cc=seb@k-7.ch \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).