emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] Restrict include to some backend


From: Clément Pit--Claudel
Subject: Re: [O] Restrict include to some backend
Date: Tue, 6 Sep 2016 09:59:58 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0

Hi Fabrice,

I've run into this issue recently (while writing my first large document in 
Org).  I couldn't find a good natice solution, so I used a rather unpleasant 
trick, and I've been meaning to write emacs-orgmode about it since then.

In my documents I have a BEGIN_ONLY environment that I use like this:

#+begin_export html
#+include foo.py src python
#+end_export

#+begin_export latex
This is processed as *regular* ~org-mode~ code, but only when exporting to 
LaTeX.
#+end_export

I remove the blocks based on the current backend using a crude pre-processing 
step in Emacs lisp. I can share the code if you're in a hurry, but maybe this 
idea can also be integrated to Org itself?

For the record, here are places where this was useful:

* Some complex math was improperly rendered by MathJax; I made SVG images of it 
and declared a macro that inserted the actual math in LaTeX mode, and the SVG 
in HTML mode. To get backend-dependent macro definitions, I used BEGIN_ONLY 
blocks.

* I wanted to set the TOC depth only for the HTML version; I used 
    #+BEGIN_ONLY html
    #+TOC: headlines 2
    #+END_ONLY html

* In HTML mode listings are labeled as "listings," but in TeX mode they are 
listed as "figures"; I used a backend-dependent macro definition to smoothe out 
the difference.

* I split a figure in two in HTML, while using two subfigures in LaTeX

* I included PDF figures in LaTeX and SVG figures in HTML in some places

* I have my own custom-written citation processor for HTML; I included the "* 
Bibliography" header only in the HTML, since LaTeX inserted it by itself.

Cheers,
Clément.

On 2016-09-06 01:13, Fabrice Popineau wrote:
> Hi,
> 
> Maybe there is an obvious answer but I wonder how to restrict
> including a file to some backend. The following doesn't work:
> 
> #+begin_export latex
> #+include foo.py src python
> #+end_export
> 
> (Not that I expected it to actually work, but it shows the goal)
> Any idea ? Thanks for your help.
> 
> Fabrice

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]