From: "Juan Manuel Macías" <maciaschain@posteo.net>
To: "Thomas S. Dye" <tsd@tsdye.online>
Cc: Maxim Nikulin <manikulin@gmail.com>, orgmode <emacs-orgmode@gnu.org>
Subject: Re: Export LaTeX command inside figure environment
Date: Sun, 08 May 2022 16:12:38 +0000 [thread overview]
Message-ID: <87tua0nguh.fsf@posteo.net> (raw)
In-Reply-To: <87v8uga78j.fsf@tsdye.online> (Thomas S. Dye's message of "Sat, 07 May 2022 20:06:20 -1000")
Thomas S. Dye writes:
> It would be better to have a LaTeX attribute, say :commands, that
> places commands within \begin{figure} ... \end{figure}.
This is a possible solution from the LaTeX side, which would avoid
having to modify the Org code and can also be used to introduce more
complex arbitrary code into the figure environment. It consists of
defining a variable (for arbitrary code) and redefining the figure
environment to include that variable. Something like this:
#+NAME: preamble
#+begin_src latex :exports none
\usepackage{graphicx,xparse}
\def\myfigcode#1{#1}
\let\svfigure\figure
\let\endsvfigure\endfigure
\DeclareDocumentEnvironment{figure}{o}{%
\IfNoValueTF{#1}{%
\begin{svfigure}}
{\begin{svfigure}[#1]}
\myfigcode%
}
{\end{svfigure}}
#+end_src
#+begin_src latex :noweb yes :results raw
,#+LaTeX_HEADER: <<preamble>>
#+end_src
Here I use the dummy images from the graphicx package. Of course, then
it is necessary to apply a zero value to the variable again, or enclose
all in a \begingroup...\endgroup. It's a bit tricky and I haven't tried
it too much:
@@latex:\begingroup\def\myfigcode{{\centering\fbox{\textbf{Hello world!!!}}\par\vspace{5ex}}}@@
#+caption: This is a caption
#+ATTR_LaTeX: :placement [h] :width .5\linewidth
[[file:example-image-a.jpg]]
@@latex:\endgroup@@
#+caption: This is a caption
#+ATTR_LaTeX: :placement [h] :width .5\linewidth
[[file:example-image-b.jpg]]
A screenshot:
https://i.imgur.com/8JIU6nX.png
Best regards,
Juan Manuel
next prev parent reply other threads:[~2022-05-08 16:51 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-07 23:43 Export LaTeX command inside figure environment Thomas S. Dye
2022-05-08 0:30 ` Juan Manuel Macías
2022-05-08 0:57 ` Thomas S. Dye
2022-05-08 5:08 ` Max Nikulin
2022-05-08 6:06 ` Thomas S. Dye
2022-05-08 16:12 ` Juan Manuel Macías [this message]
2022-05-08 16:35 ` Max Nikulin
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=87tua0nguh.fsf@posteo.net \
--to=maciaschain@posteo.net \
--cc=emacs-orgmode@gnu.org \
--cc=manikulin@gmail.com \
--cc=tsd@tsdye.online \
/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).