all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* How to expand macro in LaTeX export? How to use different options per export type?
@ 2021-03-31  9:40 Jean Louis
  2021-03-31 10:03 ` Eric S Fraga
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Jean Louis @ 2021-03-31  9:40 UTC (permalink / raw)
  To: Org mailing list

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: <Wednesday, March 31 2021, 10:10>
#+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



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: How to expand macro in LaTeX export? How to use different options per export type?
  2021-03-31  9:40 How to expand macro in LaTeX export? How to use different options per export type? Jean Louis
@ 2021-03-31 10:03 ` Eric S Fraga
  2021-03-31 10:29   ` Jean Louis
  2021-03-31 11:32 ` Greg Minshall
  2021-04-03 21:57 ` Juan Manuel Macías
  2 siblings, 1 reply; 11+ messages in thread
From: Eric S Fraga @ 2021-03-31 10:03 UTC (permalink / raw)
  To: Org mailing list

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 code@@@@latex: 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


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: How to expand macro in LaTeX export? How to use different options per export type?
  2021-03-31 10:03 ` Eric S Fraga
@ 2021-03-31 10:29   ` Jean Louis
  2021-03-31 10:45     ` Eric S Fraga
  0 siblings, 1 reply; 11+ messages in thread
From: Jean Louis @ 2021-03-31 10:29 UTC (permalink / raw)
  To: Org mailing list

* Eric S Fraga <e.fraga@ucl.ac.uk> [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 code@@@@latex: 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



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: How to expand macro in LaTeX export? How to use different options per export type?
  2021-03-31 10:29   ` Jean Louis
@ 2021-03-31 10:45     ` Eric S Fraga
  2021-03-31 11:04       ` Jean Louis
  0 siblings, 1 reply; 11+ messages in thread
From: Eric S Fraga @ 2021-03-31 10:45 UTC (permalink / raw)
  To: Org mailing list

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 code@@@@latex: 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


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: How to expand macro in LaTeX export? How to use different options per export type?
  2021-03-31 10:45     ` Eric S Fraga
@ 2021-03-31 11:04       ` Jean Louis
  2021-03-31 12:30         ` Eric S Fraga
  0 siblings, 1 reply; 11+ messages in thread
From: Jean Louis @ 2021-03-31 11:04 UTC (permalink / raw)
  To: Org mailing list

* Eric S Fraga <e.fraga@ucl.ac.uk> [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



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: How to expand macro in LaTeX export? How to use different options per export type?
  2021-03-31  9:40 How to expand macro in LaTeX export? How to use different options per export type? Jean Louis
  2021-03-31 10:03 ` Eric S Fraga
@ 2021-03-31 11:32 ` Greg Minshall
  2021-03-31 20:04   ` Jean Louis
  2021-04-03 21:57 ` Juan Manuel Macías
  2 siblings, 1 reply; 11+ messages in thread
From: Greg Minshall @ 2021-03-31 11:32 UTC (permalink / raw)
  To: Jean Louis; +Cc: Org mailing list

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


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: How to expand macro in LaTeX export? How to use different options per export type?
  2021-03-31 11:04       ` Jean Louis
@ 2021-03-31 12:30         ` Eric S Fraga
  0 siblings, 0 replies; 11+ messages in thread
From: Eric S Fraga @ 2021-03-31 12:30 UTC (permalink / raw)
  To: Org mailing list

> 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


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: How to expand macro in LaTeX export? How to use different options per export type?
  2021-03-31 11:32 ` Greg Minshall
@ 2021-03-31 20:04   ` Jean Louis
  2021-04-01  3:47     ` Greg Minshall
  2021-04-01  4:44     ` Greg Minshall
  0 siblings, 2 replies; 11+ messages in thread
From: Jean Louis @ 2021-03-31 20:04 UTC (permalink / raw)
  To: Greg Minshall; +Cc: Org mailing list

* Greg Minshall <minshall@umich.edu> [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/



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: How to expand macro in LaTeX export? How to use different options per export type?
  2021-03-31 20:04   ` Jean Louis
@ 2021-04-01  3:47     ` Greg Minshall
  2021-04-01  4:44     ` Greg Minshall
  1 sibling, 0 replies; 11+ messages in thread
From: Greg Minshall @ 2021-04-01  3:47 UTC (permalink / raw)
  To: Jean Louis; +Cc: Org mailing list

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"))))


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: How to expand macro in LaTeX export? How to use different options per export type?
  2021-03-31 20:04   ` Jean Louis
  2021-04-01  3:47     ` Greg Minshall
@ 2021-04-01  4:44     ` Greg Minshall
  1 sibling, 0 replies; 11+ messages in thread
From: Greg Minshall @ 2021-04-01  4:44 UTC (permalink / raw)
  To: Jean Louis; +Cc: Org mailing list

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


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: How to expand macro in LaTeX export? How to use different options per export type?
  2021-03-31  9:40 How to expand macro in LaTeX export? How to use different options per export type? Jean Louis
  2021-03-31 10:03 ` Eric S Fraga
  2021-03-31 11:32 ` Greg Minshall
@ 2021-04-03 21:57 ` Juan Manuel Macías
  2 siblings, 0 replies; 11+ messages in thread
From: Juan Manuel Macías @ 2021-04-03 21:57 UTC (permalink / raw)
  To: Jean Louis; +Cc: orgmode

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 


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2021-04-03 21:58 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-03-31  9:40 How to expand macro in LaTeX export? How to use different options per export type? Jean Louis
2021-03-31 10:03 ` Eric S Fraga
2021-03-31 10:29   ` Jean Louis
2021-03-31 10:45     ` Eric S Fraga
2021-03-31 11:04       ` Jean Louis
2021-03-31 12:30         ` Eric S Fraga
2021-03-31 11:32 ` Greg Minshall
2021-03-31 20:04   ` Jean Louis
2021-04-01  3:47     ` Greg Minshall
2021-04-01  4:44     ` Greg Minshall
2021-04-03 21:57 ` Juan Manuel Macías

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.