emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* #+LATEX_HEADER:\newcommand{\orgtitle}{{{{TITLE}}}}
@ 2014-03-18  1:14 Luke Crook
  2014-03-18 15:22 ` #+LATEX_HEADER:\newcommand{\orgtitle}{{{{TITLE}}}} Bastien
  0 siblings, 1 reply; 16+ messages in thread
From: Luke Crook @ 2014-03-18  1:14 UTC (permalink / raw)
  To: emacs-orgmode


I'm looking for a quick and dirty way to use the org-mode variables within 
Latex.

I thought the following might work;

#+TITLE: A nice title

#+LATEX_HEADER: \newcommand{\orgtitle}{{{{TITLE}}}}

And then in the .tex file;

\orgtitle{}


Suggestions?
Thanks

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

* Re: #+LATEX_HEADER:\newcommand{\orgtitle}{{{{TITLE}}}}
  2014-03-18  1:14 #+LATEX_HEADER:\newcommand{\orgtitle}{{{{TITLE}}}} Luke Crook
@ 2014-03-18 15:22 ` Bastien
  2014-03-18 17:14   ` #+LATEX_HEADER:\newcommand{\orgtitle}{{{{TITLE}}}} Luke Crook
  0 siblings, 1 reply; 16+ messages in thread
From: Bastien @ 2014-03-18 15:22 UTC (permalink / raw)
  To: Luke Crook; +Cc: emacs-orgmode

Hi Luke,

Luke Crook <luke@balooga.com> writes:

> #+LATEX_HEADER: \newcommand{\orgtitle}{{{{TITLE}}}}

My understanding is that Org's macros cannot be used
within #+... options.

HTH,

-- 
 Bastien

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

* Re: #+LATEX_HEADER:\newcommand{\orgtitle}{{{{TITLE}}}}
  2014-03-18 15:22 ` #+LATEX_HEADER:\newcommand{\orgtitle}{{{{TITLE}}}} Bastien
@ 2014-03-18 17:14   ` Luke Crook
  2014-03-18 20:33     ` #+LATEX_HEADER:\newcommand{\orgtitle}{{{{TITLE}}}} Luke Crook
  0 siblings, 1 reply; 16+ messages in thread
From: Luke Crook @ 2014-03-18 17:14 UTC (permalink / raw)
  To: emacs-orgmode

Bastien <bzg <at> gnu.org> writes:

> 
> Hi Luke,
> 
> Luke Crook <luke <at> balooga.com> writes:
> 
> > #+LATEX_HEADER: \newcommand{\orgtitle}{{{{TITLE}}}}
> 
> My understanding is that Org's macros cannot be used
> within #+... options.
> 
> HTH,
> 


Bastien, thanks.  That would certainly explain it.  I think I will try to 
define my own class.

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

* Re: #+LATEX_HEADER:\newcommand{\orgtitle}{{{{TITLE}}}}
  2014-03-18 17:14   ` #+LATEX_HEADER:\newcommand{\orgtitle}{{{{TITLE}}}} Luke Crook
@ 2014-03-18 20:33     ` Luke Crook
  2014-03-18 20:43       ` #+LATEX_HEADER:\newcommand{\orgtitle}{{{{TITLE}}}} Bastien
  2014-03-19  8:34       ` #+LATEX_HEADER:\newcommand{\orgtitle}{{{{TITLE}}}} Eric S Fraga
  0 siblings, 2 replies; 16+ messages in thread
From: Luke Crook @ 2014-03-18 20:33 UTC (permalink / raw)
  To: emacs-orgmode


I tried creating a custom class and then tried creating a custom style.  But 
I found the easiest to be the following;


#+AUTHOR: <author>
#+LATEX_HEADER: \newcommand{\orgauthor}{<author>}

#+EMAIL:  <email>
#+LATEX_HEADER: \newcommand{\orgemail}{<email>}

#+TITLE: <Title>
#+LATEX_HEADER: \newcommand{\orgtitle}{<Title>}

#+DATE:  <Date>
#+LATEX_HEADER: \newcommand{\orgdate}{<Date>}

Then in my custom Latex title page;

#+LATEX_HEADER: \input{template}


I use \orgauthor{} etc. for the relevant fields.

Works very well, apart from the duplication of author, email, date etc.

It would be great if org-mode added support for substitution to the #+ 
fields.

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

* Re: #+LATEX_HEADER:\newcommand{\orgtitle}{{{{TITLE}}}}
  2014-03-18 20:33     ` #+LATEX_HEADER:\newcommand{\orgtitle}{{{{TITLE}}}} Luke Crook
@ 2014-03-18 20:43       ` Bastien
  2014-03-19 15:02         ` #+LATEX_HEADER:\newcommand{\orgtitle}{{{{TITLE}}}} Nicolas Goaziou
  2014-03-19  8:34       ` #+LATEX_HEADER:\newcommand{\orgtitle}{{{{TITLE}}}} Eric S Fraga
  1 sibling, 1 reply; 16+ messages in thread
From: Bastien @ 2014-03-18 20:43 UTC (permalink / raw)
  To: Luke Crook; +Cc: emacs-orgmode

Luke Crook <luke@balooga.com> writes:

> It would be great if org-mode added support for substitution to the #+ 
> fields.

Nicolas, what do you think?

-- 
 Bastien

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

* Re: #+LATEX_HEADER:\newcommand{\orgtitle}{{{{TITLE}}}}
  2014-03-18 20:33     ` #+LATEX_HEADER:\newcommand{\orgtitle}{{{{TITLE}}}} Luke Crook
  2014-03-18 20:43       ` #+LATEX_HEADER:\newcommand{\orgtitle}{{{{TITLE}}}} Bastien
@ 2014-03-19  8:34       ` Eric S Fraga
  2014-03-19 10:30         ` #+LATEX_HEADER:\newcommand{\orgtitle}{{{{TITLE}}}} Rasmus
  2014-03-19 16:51         ` #+LATEX_HEADER:\newcommand{\orgtitle}{{{{TITLE}}}} Luke Crook
  1 sibling, 2 replies; 16+ messages in thread
From: Eric S Fraga @ 2014-03-19  8:34 UTC (permalink / raw)
  To: Luke Crook; +Cc: emacs-orgmode

Luke Crook <luke@balooga.com> writes:

> I tried creating a custom class and then tried creating a custom style.  But 
> I found the easiest to be the following;
>
>
> #+AUTHOR: <author>
> #+LATEX_HEADER: \newcommand{\orgauthor}{<author>}

[...]

> Works very well, apart from the duplication of author, email, date etc.

You could always use the new command in the org directive, assuming you
only use LaTeX export:

#+LATEX_HEADER: \newcommand{\orgauthor}{<author>}
#+AUTHOR: \orgauthor

This would avoid duplication.
-- 
: Eric S Fraga (0xFFFCF67D), Emacs 24.3.1, Org release_8.2.5h-660-gef207f

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

* Re: #+LATEX_HEADER:\newcommand{\orgtitle}{{{{TITLE}}}}
  2014-03-19  8:34       ` #+LATEX_HEADER:\newcommand{\orgtitle}{{{{TITLE}}}} Eric S Fraga
@ 2014-03-19 10:30         ` Rasmus
  2014-03-19 17:03           ` #+LATEX_HEADER:\newcommand{\orgtitle}{{{{TITLE}}}} Luke Crook
  2014-03-19 16:51         ` #+LATEX_HEADER:\newcommand{\orgtitle}{{{{TITLE}}}} Luke Crook
  1 sibling, 1 reply; 16+ messages in thread
From: Rasmus @ 2014-03-19 10:30 UTC (permalink / raw)
  To: emacs-orgmode

Eric S Fraga <e.fraga@ucl.ac.uk> writes:

> Luke Crook <luke@balooga.com> writes:
>
>> I tried creating a custom class and then tried creating a custom style.  But 
>> I found the easiest to be the following;
>>
>>
>> #+AUTHOR: <author>
>> #+LATEX_HEADER: \newcommand{\orgauthor}{<author>}
>
> [...]
>
>> Works very well, apart from the duplication of author, email, date etc.
>
> You could always use the new command in the org directive, assuming you
> only use LaTeX export:
>
> #+LATEX_HEADER: \newcommand{\orgauthor}{<author>}
> #+AUTHOR: \orgauthor
>
> This would avoid duplication.

I've used this snip to recover such fields

\makeatletter
\let\Title\@title
\let\Author\@author
\let\Date\@date
\makeatother


Obviously, this is only good for LaTeX. 

-- 
There are known knowns; there are things we know that we know

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

* Re: #+LATEX_HEADER:\newcommand{\orgtitle}{{{{TITLE}}}}
  2014-03-18 20:43       ` #+LATEX_HEADER:\newcommand{\orgtitle}{{{{TITLE}}}} Bastien
@ 2014-03-19 15:02         ` Nicolas Goaziou
  2014-03-19 15:35           ` #+LATEX_HEADER:\newcommand{\orgtitle}{{{{TITLE}}}} Bastien
  0 siblings, 1 reply; 16+ messages in thread
From: Nicolas Goaziou @ 2014-03-19 15:02 UTC (permalink / raw)
  To: Bastien; +Cc: emacs-orgmode, Luke Crook

Hello,

Bastien <bzg@gnu.org> writes:

> Luke Crook <luke@balooga.com> writes:
>
>> It would be great if org-mode added support for substitution to the #+ 
>> fields.
>
> Nicolas, what do you think?

In the current model, macros are considered part of Org syntax, like,
e.g., text markup. One advantage is that they can be parsed, so you can
get information about them with tools like `org-element-context'.
Though,, the obvious limitation is that they can only exist wherever Org
syntax is defined. In particular, you wouldn't (at least, I hope) expect
bold text in a LATEX keyword (or an example block...) to be recognized.
There is no macro here either, and macros behaviour is consistent with
other Org syntax.

It wasn't always the case. Before Org 8.0, as already written on this
ML, macros were, in some sense, more powerful as you could write one
almost anywhere (even though "almost" was hard to define and explain).
The manual also specified that they could be used to build complex
constructs. I changed the model.

Indeed, since Babel was introduced in Org, macros have been, at best, an
awkward way to hack an Org document (e.g., definition are only one line
long, they are hard to edit). Nowadays, Babel is really the way to go
for this task: you can use the language of your choice, definitions are
easily editable, and so on. Thus, it is acceptable to limit a bit macros
as no user is deprived from total control over its documents. In that
scheme, macros are still useful in the most simple cases, e.g., as small
placeholders in the middle of the document, so they are still
implemented, in a limited and somewhat protected environment.

I think it somehow strikes a balance between ease of use and power, as
both needs are covered. I understand that it is tempting to merge the
two concepts, and it is partly possible since macros can contain Babel
code themselves, but I strongly believe that these tools must focus on
their own niche. Or, to put it differently, I don't think that macros
should overlap too much with Babel.

Here, the OP wants to build conditional LaTeX code within the Org
document. This is far beyond macros' scope. I suggest to rely on Babel
code for the task, or even a filter, instead. In any case, there's no
need to extend macros past their current limitation.


Regards,

-- 
Nicolas Goaziou

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

* Re: #+LATEX_HEADER:\newcommand{\orgtitle}{{{{TITLE}}}}
  2014-03-19 15:02         ` #+LATEX_HEADER:\newcommand{\orgtitle}{{{{TITLE}}}} Nicolas Goaziou
@ 2014-03-19 15:35           ` Bastien
  2014-03-19 16:00             ` #+LATEX_HEADER:\newcommand{\orgtitle}{{{{TITLE}}}} Nicolas Goaziou
  0 siblings, 1 reply; 16+ messages in thread
From: Bastien @ 2014-03-19 15:35 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: emacs-orgmode, Luke Crook

Hi Nicolas,

thanks for the thorough answer, I agree.

Can we sum it up as "Macros are only available in headlines and
paragraphs", for the sake of clarifying the Macro section in the
manual?

Also, it seems that macros are only fontified in headlines and
paragraphs, which matches the short description above.  Is there
any false positives/negatives you can think of?

Thanks,

-- 
 Bastien

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

* Re: #+LATEX_HEADER:\newcommand{\orgtitle}{{{{TITLE}}}}
  2014-03-19 15:35           ` #+LATEX_HEADER:\newcommand{\orgtitle}{{{{TITLE}}}} Bastien
@ 2014-03-19 16:00             ` Nicolas Goaziou
  2014-03-19 16:10               ` #+LATEX_HEADER:\newcommand{\orgtitle}{{{{TITLE}}}} Bastien
  0 siblings, 1 reply; 16+ messages in thread
From: Nicolas Goaziou @ 2014-03-19 16:00 UTC (permalink / raw)
  To: Bastien; +Cc: emacs-orgmode, Luke Crook

Bastien <bzg@gnu.org> writes:

> thanks for the thorough answer, I agree.

Champagne! ;)

> Can we sum it up as "Macros are only available in headlines and
> paragraphs", for the sake of clarifying the Macro section in the
> manual?

The manual states:

  "in paragraphs, verse blocks, table cells and some keywords"

"some keywords" implicitly refers to AUTHOR, DATE, TITLE and CAPTION.

As you noticed, secondary strings are omitted in the manual, but still
valid locations: titles in headlines or inlinetasks, inline footnotes,
and plain list item tags.

I think that's all.


Regards,

-- 
Nicolas Goaziou

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

* Re: #+LATEX_HEADER:\newcommand{\orgtitle}{{{{TITLE}}}}
  2014-03-19 16:00             ` #+LATEX_HEADER:\newcommand{\orgtitle}{{{{TITLE}}}} Nicolas Goaziou
@ 2014-03-19 16:10               ` Bastien
  2014-03-19 21:23                 ` #+LATEX_HEADER:\newcommand{\orgtitle}{{{{TITLE}}}} Nicolas Goaziou
  0 siblings, 1 reply; 16+ messages in thread
From: Bastien @ 2014-03-19 16:10 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: emacs-orgmode, Luke Crook

Nicolas Goaziou <n.goaziou@gmail.com> writes:

> Bastien <bzg@gnu.org> writes:
>
>> thanks for the thorough answer, I agree.
>
> Champagne! ;)

Hehe.

>> Can we sum it up as "Macros are only available in headlines and
>> paragraphs", for the sake of clarifying the Macro section in the
>> manual?
>
> The manual states:
>
>   "in paragraphs, verse blocks, table cells and some keywords"
>
> "some keywords" implicitly refers to AUTHOR, DATE, TITLE and
> CAPTION.

Oops, I checked a (very) old version of the manual without noticing,
sorry for the noise.

> As you noticed, secondary strings are omitted in the manual, but still
> valid locations: titles in headlines or inlinetasks, inline footnotes,
> and plain list item tags.

Any reason not to mention secondary strings?

In this particular case, mentioning headlines and plain list items
would be useful, otherwise careful readers* may assume that macros
are not available there.

* I've met some.

Not a big deal anyway,

-- 
 Bastien

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

* Re: #+LATEX_HEADER:\newcommand{\orgtitle}{{{{TITLE}}}}
  2014-03-19  8:34       ` #+LATEX_HEADER:\newcommand{\orgtitle}{{{{TITLE}}}} Eric S Fraga
  2014-03-19 10:30         ` #+LATEX_HEADER:\newcommand{\orgtitle}{{{{TITLE}}}} Rasmus
@ 2014-03-19 16:51         ` Luke Crook
  1 sibling, 0 replies; 16+ messages in thread
From: Luke Crook @ 2014-03-19 16:51 UTC (permalink / raw)
  To: emacs-orgmode

Eric S Fraga <e.fraga <at> ucl.ac.uk> writes:

> You could always use the new command in the org directive, assuming you
> only use LaTeX export:
> 
> #+LATEX_HEADER: \newcommand{\orgauthor}{<author>}
> #+AUTHOR: \orgauthor
> 
> This would avoid duplication.

Brilliant!! Thank you.

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

* Re: #+LATEX_HEADER:\newcommand{\orgtitle}{{{{TITLE}}}}
  2014-03-19 10:30         ` #+LATEX_HEADER:\newcommand{\orgtitle}{{{{TITLE}}}} Rasmus
@ 2014-03-19 17:03           ` Luke Crook
  2014-03-19 23:25             ` #+LATEX_HEADER:\newcommand{\orgtitle}{{{{TITLE}}}} Rasmus
  0 siblings, 1 reply; 16+ messages in thread
From: Luke Crook @ 2014-03-19 17:03 UTC (permalink / raw)
  To: emacs-orgmode

Rasmus <rasmus <at> gmx.us> writes:

> 
> I've used this snip to recover such fields
> 
> \makeatletter
> \let\Title\ <at> title
> \let\Author\ <at> author
> \let\Date\ <at> date
> \makeatother
> 
> Obviously, this is only good for LaTeX. 
> 

How would I implement this?  Is including in the .tex file sufficient?  
Having these in the Org-mode file itself?  When I try in the .tex file, it 
appears almost verbatim as;

Title <at> title
Author <at> author

I cannot get the substitution to work.

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

* Re: #+LATEX_HEADER:\newcommand{\orgtitle}{{{{TITLE}}}}
  2014-03-19 16:10               ` #+LATEX_HEADER:\newcommand{\orgtitle}{{{{TITLE}}}} Bastien
@ 2014-03-19 21:23                 ` Nicolas Goaziou
  2014-03-21  9:04                   ` #+LATEX_HEADER:\newcommand{\orgtitle}{{{{TITLE}}}} Bastien
  0 siblings, 1 reply; 16+ messages in thread
From: Nicolas Goaziou @ 2014-03-19 21:23 UTC (permalink / raw)
  To: Bastien; +Cc: emacs-orgmode, Luke Crook

Bastien <bzg@altern.org> writes:

> Nicolas Goaziou <n.goaziou@gmail.com> writes:
>
>> As you noticed, secondary strings are omitted in the manual, but still
>> valid locations: titles in headlines or inlinetasks, inline footnotes,
>> and plain list item tags.
>
> Any reason not to mention secondary strings?

No reason besides clarity, maybe. A long list of locations could be
confusing.

> In this particular case, mentioning headlines and plain list items
> would be useful, otherwise careful readers* may assume that macros
> are not available there.

What about excluding most tempting locations instead?

  "...

  which can be referenced with {{{name(arg1, arg2)}}}.

  These references, called macros, can be inserted anywhere Org markup
  is recognized. In particular, this excludes all keywords but CAPTION,
  TITLE, AUTHOR and EMAIL, source blocks, example blocks and comments.

  In addition to user-defined macros..."


Regards,

-- 
Nicolas Goaziou

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

* Re: #+LATEX_HEADER:\newcommand{\orgtitle}{{{{TITLE}}}}
  2014-03-19 17:03           ` #+LATEX_HEADER:\newcommand{\orgtitle}{{{{TITLE}}}} Luke Crook
@ 2014-03-19 23:25             ` Rasmus
  0 siblings, 0 replies; 16+ messages in thread
From: Rasmus @ 2014-03-19 23:25 UTC (permalink / raw)
  To: emacs-orgmode

Luke Crook <luke@balooga.com> writes:

> Rasmus <rasmus <at> gmx.us> writes:
>
>> 
>> I've used this snip to recover such fields
>> 
>> \makeatletter
>> \let\Title\ <at> title
>> \let\Author\ <at> author
>> \let\Date\ <at> date
>> \makeatother
>> 
>> Obviously, this is only good for LaTeX. 
>> 
>
> How would I implement this?  Is including in the .tex file sufficient?  
> Having these in the Org-mode file itself?  When I try in the .tex file, it 
> appears almost verbatim as;

For some reason your "@" (the sign from email address) becomes "<at>".
It needs to be "@".  See the gmane version if you are in doubt.

Here's a working example.

#+TITLE: title
#+AUTHOR: name
#+LATEX: \newcommand{\myname}{\Author}
Remember to escape latex macros like
~\myname~ as ~@@latex:\myname@@~ in Org to get "\myname"


* make some latex commands                                         :noexport:
# Local Variables:
# org-latex-title-command: "\\makeatletter\n \
# \\let\\Title\\@title\n \
# \\let\\Author\\@author\n \
# \\let\\Date\\@date\\makeatother\n \
# \\maketitle"
# End:



-- 
In theory, practice and theory are the same. In practice they are not

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

* Re: #+LATEX_HEADER:\newcommand{\orgtitle}{{{{TITLE}}}}
  2014-03-19 21:23                 ` #+LATEX_HEADER:\newcommand{\orgtitle}{{{{TITLE}}}} Nicolas Goaziou
@ 2014-03-21  9:04                   ` Bastien
  0 siblings, 0 replies; 16+ messages in thread
From: Bastien @ 2014-03-21  9:04 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: emacs-orgmode, Luke Crook

Hi Nicolas,

Nicolas Goaziou <n.goaziou@gmail.com> writes:

> What about excluding most tempting locations instead?

I pushed a change, mixing this suggestion and the suggestion
to be more explicit about where it is allowed:

http://orgmode.org/cgit.cgi/org-mode.git/commit/?id=343a6dd0

Luke, let's us know if it is clearer.

-- 
 Bastien

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

end of thread, other threads:[~2014-03-21  9:05 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-18  1:14 #+LATEX_HEADER:\newcommand{\orgtitle}{{{{TITLE}}}} Luke Crook
2014-03-18 15:22 ` #+LATEX_HEADER:\newcommand{\orgtitle}{{{{TITLE}}}} Bastien
2014-03-18 17:14   ` #+LATEX_HEADER:\newcommand{\orgtitle}{{{{TITLE}}}} Luke Crook
2014-03-18 20:33     ` #+LATEX_HEADER:\newcommand{\orgtitle}{{{{TITLE}}}} Luke Crook
2014-03-18 20:43       ` #+LATEX_HEADER:\newcommand{\orgtitle}{{{{TITLE}}}} Bastien
2014-03-19 15:02         ` #+LATEX_HEADER:\newcommand{\orgtitle}{{{{TITLE}}}} Nicolas Goaziou
2014-03-19 15:35           ` #+LATEX_HEADER:\newcommand{\orgtitle}{{{{TITLE}}}} Bastien
2014-03-19 16:00             ` #+LATEX_HEADER:\newcommand{\orgtitle}{{{{TITLE}}}} Nicolas Goaziou
2014-03-19 16:10               ` #+LATEX_HEADER:\newcommand{\orgtitle}{{{{TITLE}}}} Bastien
2014-03-19 21:23                 ` #+LATEX_HEADER:\newcommand{\orgtitle}{{{{TITLE}}}} Nicolas Goaziou
2014-03-21  9:04                   ` #+LATEX_HEADER:\newcommand{\orgtitle}{{{{TITLE}}}} Bastien
2014-03-19  8:34       ` #+LATEX_HEADER:\newcommand{\orgtitle}{{{{TITLE}}}} Eric S Fraga
2014-03-19 10:30         ` #+LATEX_HEADER:\newcommand{\orgtitle}{{{{TITLE}}}} Rasmus
2014-03-19 17:03           ` #+LATEX_HEADER:\newcommand{\orgtitle}{{{{TITLE}}}} Luke Crook
2014-03-19 23:25             ` #+LATEX_HEADER:\newcommand{\orgtitle}{{{{TITLE}}}} Rasmus
2014-03-19 16:51         ` #+LATEX_HEADER:\newcommand{\orgtitle}{{{{TITLE}}}} Luke Crook

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).