From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?UTF-8?Q?Cl=c3=a9ment_Pit--Claudel?= Subject: Re: Restrict include to some backend Date: Tue, 6 Sep 2016 09:59:58 -0400 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="udEPs7CiQaioCVhmaVkjmoimEFqVnVo6C" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:38413) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bhGv5-0007cx-N9 for emacs-orgmode@gnu.org; Tue, 06 Sep 2016 10:00:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bhGv0-00073w-QN for emacs-orgmode@gnu.org; Tue, 06 Sep 2016 10:00:10 -0400 Received: from mout.kundenserver.de ([217.72.192.73]:62495) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bhGv0-00072S-Gg for emacs-orgmode@gnu.org; Tue, 06 Sep 2016 10:00:06 -0400 Received: from [18.189.118.169] ([18.189.118.169]) by mrelayeu.kundenserver.de (mreue101) with ESMTPSA (Nemesis) id 0MV4mL-1bZpBB3oeT-00YQIP for ; Tue, 06 Sep 2016 16:00:05 +0200 In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: emacs-orgmode@gnu.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --udEPs7CiQaioCVhmaVkjmoimEFqVnVo6C Content-Type: multipart/mixed; boundary="BD2VFGQ2GHIIrnucghxQ8wTeS7u8C7Xxc"; protected-headers="v1" From: =?UTF-8?Q?Cl=c3=a9ment_Pit--Claudel?= To: emacs-orgmode@gnu.org Message-ID: Subject: Re: [O] Restrict include to some backend References: In-Reply-To: --BD2VFGQ2GHIIrnucghxQ8wTeS7u8C7Xxc Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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 unpl= easant 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 t= o LaTeX. #+end_export I remove the blocks based on the current backend using a crude pre-proces= sing step in Emacs lisp. I can share the code if you're in a hurry, but m= aybe 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 u= sed BEGIN_ONLY blocks. * I wanted to set the TOC depth only for the HTML version; I used=20 #+BEGIN_ONLY html #+TOC: headlines 2 #+END_ONLY html * In HTML mode listings are labeled as "listings," but in TeX mode they a= re listed as "figures"; I used a backend-dependent macro definition to sm= oothe 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 th= e "* Bibliography" header only in the HTML, since LaTeX inserted it by it= self. Cheers, Cl=C3=A9ment. On 2016-09-06 01:13, Fabrice Popineau wrote: > Hi, >=20 > Maybe there is an obvious answer but I wonder how to restrict > including a file to some backend. The following doesn't work: >=20 > #+begin_export latex > #+include foo.py src python > #+end_export >=20 > (Not that I expected it to actually work, but it shows the goal) > Any idea ? Thanks for your help. >=20 > Fabrice --BD2VFGQ2GHIIrnucghxQ8wTeS7u8C7Xxc-- --udEPs7CiQaioCVhmaVkjmoimEFqVnVo6C Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJXzsvjAAoJEPqg+cTm90wj0qIQAIPtb6paBHTv2vznlqexEAYt T7tAVa8N7WE4YDOW4C3cyT2ujcCj9I6AJDmh7UtkdCkk4G8Q90W/26UIjJEw9kyv JVfiKFmUXPSZ7t7qZ/c5axKGUH58MVaBv4LZVn4r5CPENO4SbWLD3bZZKOoovwhx adWItxpL/COmrZpEz6Axzc7yqr3Cj4LLofLJLUbXRUPvlwqsSqA+q8UjsHTU5YKf i0c8G2e+NWXQ27kbBvRnLtQNx6oxGFFd9bI0l4dDPzAGROsW4P7GrOaG2moL0ImX aqCZcoYm3a7jd2tyMxob331ovdDwD6KWSqKTMfZYYPyHVlW6R47dgZk39RTk4tdh DkeWlX2CXUbf9+BkJj5ivHdxtEL7bJs9hgD3nfEaiIaGrjdA0D3Eh12uO+xA9rPc bGTNOzVibbMPCPgml2o1BcqMtMnKkD5VLhJiSV2CwpgkMy7Dzmo9nWfeZg2R9CB5 fgG18ftprWIAXMhqu3QmiH587kgmkfD/ccT0aqmZIotHnoq2/EjZCS0vx64+CeIT j4MFmFTaiyoEi78PprtN3YW7hAxVRw3tGPoKfCLpK8c8YqX4c0mXN1lDqKdbfzoB EgQ3FZTm49dDFOUSmYaN/8o0tQCT9Wk7RQO8C8MosRsO7DHK6kvajiflWZ9xqxvi jYusUVavKMn8N4FDpYxS =cIa/ -----END PGP SIGNATURE----- --udEPs7CiQaioCVhmaVkjmoimEFqVnVo6C--