emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [O] macro expansion in #+begin_latex


From: Robert Klein
Subject: Re: [O] macro expansion in #+begin_latex
Date: Sun, 14 Jun 2015 11:53:50 +0200

Hi,

On Sun, 14 Jun 2015 11:14:13 +0200
wero_sacero <address@hidden> wrote:

> Thank you for the reply.
> 
> But I don't think it's a good idea. For example: what can I do if want
> to put a text like the title of my file in the latex header? is there
> an other way?
> 
> I know I can use the address@hidden function of latex, it works. but I need
> it also for email, date, etc.. macro would be exactly what I want, but
> maybe someone has thought something better!
> 

I have a set-up to be able to use title, author etc. in LaTeX blocks.

Every one of those documents has a (filled out) header like:

#+TITLE: 
#+AUTHOR: Robert Klein
#+EMAIL: address@hidden
#+KEYWORDS: 
#+DESCRIPTION: 
#+LaTeX_HEADER: \newcommand{\mySubtitle}{}
#+LaTeX_HEADER: \newcommand{\myProducer}{org-mode / pdflatex}

Further down I #include a largish file with my standard settings which
has the following in it:

#+name: docinfo
#+begin_src elisp :exports none
  (let ((props (org-export-get-environment)))
    (concat  "#+LaTeX_HEADER: \\newcommand{\\myTitle}{"
             (org-element-interpret-data
              (plist-get props :title))
             "}\n"
             "#+LaTeX_HEADER: \\newcommand{\\myAuthor}{"
             (org-element-interpret-data
              (plist-get props :author))
             "}\n"
             "#+LaTeX_HEADER: \\newcommand{\\myDate}{"
             (org-element-interpret-data
              (plist-get props :date))
             "}\n"
             "#+LaTeX_HEADER: \\newcommand{\\myCreator}{"
             (org-element-interpret-data
              (plist-get props :creator))
             "}\n"
             "#+LaTeX_HEADER: \\newcommand{\\myKeywords}{"
             (org-element-interpret-data
              (plist-get props :keywords))
             "}\n"
             "#+LaTeX_HEADER: \\newcommand{\\mySubject}{"
             (org-element-interpret-data
              (plist-get props :description))
             "}\n"))
#+end_src

#+CALL: docinfo() :exports results :results raw



So, further down I can use all those \myTitle etc. commands in LaTeX,
e.g.:

#+LaTeX_HEADER: % Hyperref PDF Info
#+LaTeX_HEADER: \hypersetup{
#+LaTeX_HEADER:   pdfinfo={
#+LaTeX_HEADER:     Author={\myAuthor},
#+LaTeX_HEADER:     Title={\myTitle},
#+LaTeX_HEADER:     Subject={\mySubject},
#+LaTeX_HEADER:     Keywords={\myKeywords},
#+LaTeX_HEADER:     Creator={\myCreator},
#+LaTeX_HEADER:     Producer={\myProducer}
#+LaTeX_HEADER:   }}



I also use document-wide properties for data org doesn't
handle, e.g.

# note: classify as `open access', `internal', `confidential'
#+Property: documenttype   form sheet
#+Property: classification open access

though I don't use it in a LaTeX block but in a elisp block w/ org
output:

#+name: dochead
#+header: :var trustlevel=(org-entry-get nil "classification" t)
#+header: :var doctype=(org-entry-get nil "documenttype" t)
#+begin_src elisp :exports none :results value raw
  (let ((props (org-export-get-environment)))
    (concat "#+ATTR_HTML: :rules all\n"
            "#+ATTR_LATEX: :environment tabu :align ll|ll :booktabs
            t :width \\textwidth\n"
            "| Document Type:   | " doctype
            " | Classification: | " trustlevel " |\n"
            "| Document Title: | " (org-element-interpret-data
                                    (plist-get props :title))
            " | Author: | " (org-element-interpret-data
                                           (plist-get props :author))
                                           " |\n"))

#+end_src
#+Call: dochead() :exports results :results raw


I use this code to generate output intended for both HTML and LaTeX, so
I can't use the \myXXX commands above (and, I'm creating org code here
to be exported in the course of the current export).



I won't claim this is `something better' than using {{{title}}} or so,
but once I had the set-up working I'm happy with it.

Best regards
Robert




> Thanks again!
> 
> Wero
> 
> 2015-06-13 18:58 GMT+02:00, Nicolas Goaziou <address@hidden>:
> > Hello,
> >
> > wero_sacero <address@hidden> writes:
> >
> >> hi, is there anybody that know why in the lastest version of
> >> org-mode exporting in latex, the macro like {{{title}}} is not
> >> expanded if it is put in a begin_latex?
> >>
> >> In version 7.9... it was working, and I think it should work also
> >> now.
> >>
> >> Can anyone explain me if it is a non-feature or a bug?
> >
> > It is a non-feature. Macro are not allowed in raw or verbatim
> > environments.
> >
> > Regards,
> >
> > --
> > Nicolas Goaziou
> >
> 




reply via email to

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