Re: How to expand macro in LaTeX export? How to use different options per export type?
Jean Louis writes: > Another issue related to this setup is that I would like: > > - for HTML export: title:t toc:t > > - for LaTeX PDF export: title:nil toc:nil > > Is there way to have options different for different exports? You can do it with a macro like this: #+MACRO: titletoc (eval (cond ((org-export-derived-backend-p org-export-current-backend 'latex) "#+OPTIONS: title:nil\n#+OPTIONS: toc:nil")((org-export-derived-backend-p org-export-current-backend 'html) "#+OPTIONS: title:t\n#+OPTIONS: toc:t"))) {{{titletoc}}} ... But maybe it would be better to use a block here: #+begin_src emacs-lisp :exports results :results raw (cond ((org-export-derived-backend-p org-export-current-backend 'latex) "#+OPTIONS: title:t\n#+OPTIONS: toc:t") ((org-export-derived-backend-p org-export-current-backend 'html) "#+OPTIONS: title:nil\n#+OPTIONS: toc:nil")) #+end_src Best regards, Juan Manuel
Re: How to expand macro in LaTeX export? How to use different options per export type?
Jean Louis, another thing that i find helpful in understanding the tao of export: if you haven't, look at the help string for the variable ~org-export-options-alist~: [C-h v org-export-options-alist]. cheers, Greg
Re: How to expand macro in LaTeX export? How to use different options per export type?
Jean Louis, when publishing, one presents a data structure ~org-publish-project-alist~ that defines the back ends and options for publishing actions. the options are here: https://orgmode.org/manual/Publishing-options.html#Publishing-options below is an example. as you can see, publishing to different back ends can have different values for a given option. (well, not that i do it that much here...) cheers, Greg (setq org-publish-project-alist '(("ess-org-html" :with-toc nil :base-directory "./" :publishing-directory "./artefacts" :exclude ".*" :include ("ess-org.org") :publishing-function org-html-publish-to-html) ("ess-org-pdf" :with-toc nil :base-directory "./" :publishing-directory "./artefacts" :exclude ".*" :include ("ess-org.org") :publishing-function org-latex-publish-to-pdf) ("ess-org-beamer-html" :with-toc nil :base-directory "./" :publishing-directory "./artefacts" :exclude ".*" :include ("ess-org-beamer.org") :publishing-function org-html-publish-to-html) ("ess-org-beamer-pdf" :with-toc nil :base-directory "./" :publishing-directory "./artefacts" :exclude ".*" :include ("ess-org-beamer.org") :publishing-function org-beamer-publish-to-pdf) ("ess-org" :components ("ess-org-html" "ess-org-pdf" "ess-org-beamer-html" "ess-org-beamer-pdf"
Re: How to expand macro in LaTeX export? How to use different options per export type?
* Greg Minshall [2021-03-31 14:33]: > Jean Louis, > > > Another issue related to this setup is that I would like: > > > > - for HTML export: title:t toc:t > > > > - for LaTeX PDF export: title:nil toc:nil > > > > Is there way to have options different for different exports? > > sometimes "publishing" gives me easier control over options than > "exporting". in case that might help. Greg, help me understand that. -- Jean Take action in Free Software Foundation campaigns: https://www.fsf.org/campaigns Sign an open letter in support of Richard M. Stallman https://rms-support-letter.github.io/
Re: How to expand macro in LaTeX export? How to use different options per export type?
> Another solution could be if a program in BEGIN_SRC block could > generate Org inline, so that it gets processed after generation. Or even an inline src block, e.g. src_elisp{...}, which checks the /backend/ for export and outputs accordingly. Search the mailing list as there have been examples along the way. I don't have anything at hand unfortunately. -- : Eric S Fraga via Emacs 28.0.50, Org release_9.4.4-254-g37749c
Re: How to expand macro in LaTeX export? How to use different options per export type?
Jean Louis, > Another issue related to this setup is that I would like: > > - for HTML export: title:t toc:t > > - for LaTeX PDF export: title:nil toc:nil > > Is there way to have options different for different exports? sometimes "publishing" gives me easier control over options than "exporting". in case that might help. cheers, Greg
Re: How to expand macro in LaTeX export? How to use different options per export type?
* Eric S Fraga [2021-03-31 13:46]: > On Wednesday, 31 Mar 2021 at 13:29, Jean Louis wrote: > > By doing this: > > > > @@latex:\def\version{@@ {{{version}}} @@latex:}@@ > > > > Then {{{version}}} will get expanded in the document, right? As I have > > hidden then only tags surrounding {{{version}}}. > > Yes. OK yet it is not doing what I need. The LaTeX definition of new command is there because I cannot expand macro in LaTeX export block. But nothing from that definition helps me in HTML. Another solution could be if a program in BEGIN_SRC block could generate Org inline, so that it gets processed after generation. Maybe I could verify if export backend is HTML and then produce lines: OPTION specific for HTML and NOT produce LaTeX related lines or if LaTeX export OPTION specific for LaTeX and NOT produce LaTeX related lines Would that decision be possible in source block? -- Jean Take action in Free Software Foundation campaigns: https://www.fsf.org/campaigns
Re: How to expand macro in LaTeX export? How to use different options per export type?
On Wednesday, 31 Mar 2021 at 13:29, Jean Louis wrote: > By doing this: > > @@latex:\def\version{@@ {{{version}}} @@latex:}@@ > > Then {{{version}}} will get expanded in the document, right? As I have > hidden then only tags surrounding {{{version}}}. Yes. >> Also, a macro can itself use the @@ directive to provide alternate >> versions for LaTeX and HTML, as in >> >> #+macro: blah @@html:some HTML codelatex: some LaTeX code@@ > > I have tried this: > > #+OPTIONS: @@html:title:t toc:t@@ @@latex:title:nil toc:nil@@ todo:nil > > But it is not working in options. It would be good if it works in OPTIONS. The reason it can work in the macro but not for options is that the macro is expanded into the text and then the text is processed as normal text so the @@ directives are processed. The options line does not go through the same processing. -- : Eric S Fraga via Emacs 28.0.50, Org release_9.4.4-254-g37749c
Re: How to expand macro in LaTeX export? How to use different options per export type?
* Eric S Fraga [2021-03-31 13:06]: > On Wednesday, 31 Mar 2021 at 12:40, Jean Louis wrote: > > But then the line with \def\version{ {{{version}}} } gets shown in > > HTML export, which is not what I want. How to resolve that? > > Can you surround the line with @@latex: ... @@? > > You might need to do @@latex:\def\version{@@ {{{version}}} > @@latex:}@@ I did not know this, it looks like a solution in sight. Thank you. By doing this: @@latex:\def\version{@@ {{{version}}} @@latex:}@@ Then {{{version}}} will get expanded in the document, right? As I have hidden then only tags surrounding {{{version}}}. > Also, a macro can itself use the @@ directive to provide alternate > versions for LaTeX and HTML, as in > > #+macro: blah @@html:some HTML codelatex: some LaTeX code@@ I have tried this: #+OPTIONS: @@html:title:t toc:t@@ @@latex:title:nil toc:nil@@ todo:nil But it is not working in options. It would be good if it works in OPTIONS. -- Jean Take action in Free Software Foundation campaigns: https://www.fsf.org/campaigns
Re: How to expand macro in LaTeX export? How to use different options per export type?
On Wednesday, 31 Mar 2021 at 12:40, Jean Louis wrote: > But then the line with \def\version{ {{{version}}} } gets shown in > HTML export, which is not what I want. How to resolve that? Can you surround the line with @@latex: ... @@? You might need to do @@latex:\def\version{@@ {{{version}}} @@latex:}@@ Also, a macro can itself use the @@ directive to provide alternate versions for LaTeX and HTML, as in #+macro: blah @@html:some HTML codelatex: some LaTeX code@@ > Another issue related to this setup is that I would like: I cannot help you with this unfortunately. -- : Eric S Fraga via Emacs 28.0.50, Org release_9.4.4-254-g37749c
How to expand macro in LaTeX export? How to use different options per export type?
In this following peculiar setup, I wish to publish the macro value {{{version}}} inside of the LaTeX source code export. That makes the first page how I need it, as it displays logo and other matters. But I cannot use macro replacements in src blocks, right? That is why I have defined \def\version{ {{{version}}} } that it gets expanded in LaTeX source code, that works fine, and all is good. But then the line with \def\version{ {{{version}}} } gets shown in HTML export, which is not what I want. How to resolve that? Possible solution would be: - to somehow be able to expand macros in LaTeX section? Is that possible? - to somehow hide \def\version{ {{{version}}} }in HTML. But I do not know how. Another issue related to this setup is that I would like: - for HTML export: title:t toc:t - for LaTeX PDF export: title:nil toc:nil Is there way to have options different for different exports? #+TITLE: My title #+MACRO: version Time-stamp: #+AUTHOR: Jean Louis #+SETUPFILE: /home/admin/Programming/git/org-html-themes/setup/theme-readtheorg.setup #+OPTIONS: title:nil toc:nil todo:nil \def\version{ {{{version}}} } #+BEGIN_EXPORT latex \begin{titlepage} \begin{center} {\Huge My title in LaTeX \\ Project by Jean Louis} %{\Large Some other title, maybe} \vspace{0.5cm} {\large Revision: \version{} } \includegraphics[width=12cm]{/home/graphics/my-logo.jpg} \end{center} \end{titlepage} \tableofcontents #+END_EXPORT -- Jean Take action in Free Software Foundation campaigns: https://www.fsf.org/campaigns