emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* table as parameter for latex block
@ 2012-03-18  8:40 Martin Halder
  2012-03-18 18:29 ` Thomas S. Dye
  0 siblings, 1 reply; 5+ messages in thread
From: Martin Halder @ 2012-03-18  8:40 UTC (permalink / raw)
  To: emacs-orgmode

Hi all,

was trying to use a table as input for a latex block. Is there a way to directly reference parts of the table inside the block or do I have to specify each parameter as separate parameter ?

Thanks for help,
Martin

This is working:

#+tblname: data
| Name    | John Doe     |
| Address | Doestreet 42 |
| Country | Doecountry   |

#+name: invoice(name=data[0,1], address=data[1,1], country=data[2,1])
#+begin_src latex
name
address
country
#+end_src

#+RESULTS: invoice
#+BEGIN_LaTeX
John Doe
Doestreet 42
Doecountry
#+END_LaTeX

what I would like to do:

#+name: invoice(data=data)
#+begin_src latex
data[0,1]
data[1,1]
data[2,1]
#+end_src

or even better:

#+name: invoice(data=data)
#+begin_src latex
data['Name']
data['Adress']
data['Country']
#+end_src

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

* Re: table as parameter for latex block
  2012-03-18  8:40 table as parameter for latex block Martin Halder
@ 2012-03-18 18:29 ` Thomas S. Dye
  2012-03-18 19:10   ` Martin Halder
  0 siblings, 1 reply; 5+ messages in thread
From: Thomas S. Dye @ 2012-03-18 18:29 UTC (permalink / raw)
  To: Martin Halder; +Cc: emacs-orgmode

Martin Halder <martin.halder@gmail.com> writes:

> Hi all,
>
> was trying to use a table as input for a latex block. Is there a way to directly reference parts of the table inside the block or do I have to specify each parameter as separate parameter ?
>
> Thanks for help,
> Martin
Aloha Martin,

Can I ask why you want to use a table as input for a latex block?  An
alternative is to send the table to a source block in some other
language and then evaluate with :results latex.  The advantage is that
the other language can have loops and complex data types that make it
relatively easy to deal with tables.  It might be possible to do these
kinds of things with TeX, but it is likely to be difficult.

hth,
Tom

>
> This is working:
>
> #+tblname: data
> | Name    | John Doe     |
> | Address | Doestreet 42 |
> | Country | Doecountry   |
>
> #+name: invoice(name=data[0,1], address=data[1,1], country=data[2,1])
> #+begin_src latex
> name
> address
> country
> #+end_src
>
> #+RESULTS: invoice
> #+BEGIN_LaTeX
> John Doe
> Doestreet 42
> Doecountry
> #+END_LaTeX
>
> what I would like to do:
>
> #+name: invoice(data=data)
> #+begin_src latex
> data[0,1]
> data[1,1]
> data[2,1]
> #+end_src
>
> or even better:
>
> #+name: invoice(data=data)
> #+begin_src latex
> data['Name']
> data['Adress']
> data['Country']
> #+end_src
>
>
>
>

-- 
Thomas S. Dye
http://www.tsdye.com

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

* Re: table as parameter for latex block
  2012-03-18 18:29 ` Thomas S. Dye
@ 2012-03-18 19:10   ` Martin Halder
  2012-03-18 19:29     ` Thomas S. Dye
  0 siblings, 1 reply; 5+ messages in thread
From: Martin Halder @ 2012-03-18 19:10 UTC (permalink / raw)
  To: Thomas S. Dye; +Cc: emacs-orgmode


> Martin Halder <martin.halder@gmail.com> writes:
> 
>> Hi all,
>> 
>> was trying to use a table as input for a latex block. Is there a way to directly reference parts of the table inside the block or do I have to specify each parameter as separate parameter ?
>> 
>> Thanks for help,
>> Martin
> Aloha Martin,
> 
> Can I ask why you want to use a table as input for a latex block?  An
> alternative is to send the table to a source block in some other
> language and then evaluate with :results latex.  The advantage is that
> the other language can have loops and complex data types that make it
> relatively easy to deal with tables.  It might be possible to do these
> kinds of things with TeX, but it is likely to be difficult.
> 
> hth,
> Tom

Aloha Tom,

the reason was that I have a quite complex latex file in a src latex block (which I tangle)
and just wanted to replace some variables from a table.

But :results latex looks very interesting, will have a look if I can solve it with that one,
many thanks for the hint.

This is my use case, the example below was maybe too much simplified:

#begin_src latex
... weird latex code
	\put(-2,-50){
		\parbox{8cm}{
			\tiny{mycompany - mystree - mycountry}\\ \\
			\normalsize
			\textbf{company}\\
			street\\
			\textbf{country}
			\vspace{2mm}\\
		}
	}
... weird latex code
#end_src latex

Cheers,
Martin

> 
>> 
>> This is working:
>> 
>> #+tblname: data
>> | Name    | John Doe     |
>> | Address | Doestreet 42 |
>> | Country | Doecountry   |
>> 
>> #+name: invoice(name=data[0,1], address=data[1,1], country=data[2,1])
>> #+begin_src latex
>> name
>> address
>> country
>> #+end_src
>> 
>> #+RESULTS: invoice
>> #+BEGIN_LaTeX
>> John Doe
>> Doestreet 42
>> Doecountry
>> #+END_LaTeX
>> 
>> what I would like to do:
>> 
>> #+name: invoice(data=data)
>> #+begin_src latex
>> data[0,1]
>> data[1,1]
>> data[2,1]
>> #+end_src
>> 
>> or even better:
>> 
>> #+name: invoice(data=data)
>> #+begin_src latex
>> data['Name']
>> data['Adress']
>> data['Country']
>> #+end_src
>> 
>> 
>> 
>> 
> 
> -- 
> Thomas S. Dye
> http://www.tsdye.com

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

* Re: table as parameter for latex block
  2012-03-18 19:10   ` Martin Halder
@ 2012-03-18 19:29     ` Thomas S. Dye
  2012-03-18 19:55       ` Martin Halder
  0 siblings, 1 reply; 5+ messages in thread
From: Thomas S. Dye @ 2012-03-18 19:29 UTC (permalink / raw)
  To: Martin Halder; +Cc: emacs-orgmode

Martin Halder <martin.halder@gmail.com> writes:

>> Martin Halder <martin.halder@gmail.com> writes:
>> 
>>> Hi all,
>>> 
>>> was trying to use a table as input for a latex block. Is there a way to directly reference parts of the table inside the block or do I have to specify each parameter as separate parameter ?
>>> 
>>> Thanks for help,
>>> Martin
>> Aloha Martin,
>> 
>> Can I ask why you want to use a table as input for a latex block?  An
>> alternative is to send the table to a source block in some other
>> language and then evaluate with :results latex.  The advantage is that
>> the other language can have loops and complex data types that make it
>> relatively easy to deal with tables.  It might be possible to do these
>> kinds of things with TeX, but it is likely to be difficult.
>> 
>> hth,
>> Tom
>
> Aloha Tom,
>
> the reason was that I have a quite complex latex file in a src latex block (which I tangle)
> and just wanted to replace some variables from a table.
>
> But :results latex looks very interesting, will have a look if I can solve it with that one,
> many thanks for the hint.
>
> This is my use case, the example below was maybe too much simplified:
>
> #begin_src latex
> ... weird latex code
> 	\put(-2,-50){
> 		\parbox{8cm}{
> 			\tiny{mycompany - mystree - mycountry}\\ \\
> 			\normalsize
> 			\textbf{company}\\
> 			street\\
> 			\textbf{country}
> 			\vspace{2mm}\\
> 		}
> 	}
> ... weird latex code
> #end_src latex

Aloha Martin,

Here is the basic idea in pseudo python.  

#begin_src python :results output latex
 ... weird latex code
s = ''' 	\\put(-2,-50){
 		\\parbox{8cm}{
 			\\tiny{%s - %s - %s}\\\\ \\\\
 			\\normalsize
 			\\textbf{%s}\\\\
 			street\\\\
 			\\textbf{%s}
 			\\vspace{2mm}\\\\
 		}
 	}''' % (mycompany, mystree, mycountry, company, country)
print s
 ... weird latex code
#end_src python

hth,
Tom

>
> Cheers,
> Martin
>
>> 
>>> 
>>> This is working:
>>> 
>>> #+tblname: data
>>> | Name    | John Doe     |
>>> | Address | Doestreet 42 |
>>> | Country | Doecountry   |
>>> 
>>> #+name: invoice(name=data[0,1], address=data[1,1], country=data[2,1])
>>> #+begin_src latex
>>> name
>>> address
>>> country
>>> #+end_src
>>> 
>>> #+RESULTS: invoice
>>> #+BEGIN_LaTeX
>>> John Doe
>>> Doestreet 42
>>> Doecountry
>>> #+END_LaTeX
>>> 
>>> what I would like to do:
>>> 
>>> #+name: invoice(data=data)
>>> #+begin_src latex
>>> data[0,1]
>>> data[1,1]
>>> data[2,1]
>>> #+end_src
>>> 
>>> or even better:
>>> 
>>> #+name: invoice(data=data)
>>> #+begin_src latex
>>> data['Name']
>>> data['Adress']
>>> data['Country']
>>> #+end_src
>>> 
>>> 
>>> 
>>> 
>> 
>> -- 
>> Thomas S. Dye
>> http://www.tsdye.com
>

-- 
T.S. Dye & Colleagues, Archaeologists
735 Bishop St, Suite 315, Honolulu, HI 96813
Tel: 808-529-0866, Fax: 808-529-0884
http://www.tsdye.com

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

* Re: table as parameter for latex block
  2012-03-18 19:29     ` Thomas S. Dye
@ 2012-03-18 19:55       ` Martin Halder
  0 siblings, 0 replies; 5+ messages in thread
From: Martin Halder @ 2012-03-18 19:55 UTC (permalink / raw)
  To: Thomas S. Dye; +Cc: emacs-orgmode

> Martin Halder <martin.halder@gmail.com> writes:
> 
>>> Martin Halder <martin.halder@gmail.com> writes:
>>> 
>>>> Hi all,
>>>> 
>>>> was trying to use a table as input for a latex block. Is there a way to directly reference parts of the table inside the block or do I have to specify each parameter as separate parameter ?
>>>> 
>>>> Thanks for help,
>>>> Martin
>>> Aloha Martin,
>>> 
>>> Can I ask why you want to use a table as input for a latex block?  An
>>> alternative is to send the table to a source block in some other
>>> language and then evaluate with :results latex.  The advantage is that
>>> the other language can have loops and complex data types that make it
>>> relatively easy to deal with tables.  It might be possible to do these
>>> kinds of things with TeX, but it is likely to be difficult.
>>> 
>>> hth,
>>> Tom
>> 
>> Aloha Tom,
>> 
>> the reason was that I have a quite complex latex file in a src latex block (which I tangle)
>> and just wanted to replace some variables from a table.
>> 
>> But :results latex looks very interesting, will have a look if I can solve it with that one,
>> many thanks for the hint.
>> 
>> This is my use case, the example below was maybe too much simplified:
>> 
>> #begin_src latex
>> ... weird latex code
>> 	\put(-2,-50){
>> 		\parbox{8cm}{
>> 			\tiny{mycompany - mystree - mycountry}\\ \\
>> 			\normalsize
>> 			\textbf{company}\\
>> 			street\\
>> 			\textbf{country}
>> 			\vspace{2mm}\\
>> 		}
>> 	}
>> ... weird latex code
>> #end_src latex
> 
> Aloha Martin,
> 
> Here is the basic idea in pseudo python.  
> 
> #begin_src python :results output latex
> ... weird latex code
> s = ''' 	\\put(-2,-50){
> 		\\parbox{8cm}{
> 			\\tiny{%s - %s - %s}\\\\ \\\\
> 			\\normalsize
> 			\\textbf{%s}\\\\
> 			street\\\\
> 			\\textbf{%s}
> 			\\vspace{2mm}\\\\
> 		}
> 	}''' % (mycompany, mystree, mycountry, company, country)
> print s
> ... weird latex code
> #end_src python
> 
> hth,
> Tom

Aloha Tom,

great, thanks. This one is working. Did not think about sending the whole file through python.

Cheers,
Martin

>> 
>> Cheers,
>> Martin
>> 
>>> 
>>>> 
>>>> This is working:
>>>> 
>>>> #+tblname: data
>>>> | Name    | John Doe     |
>>>> | Address | Doestreet 42 |
>>>> | Country | Doecountry   |
>>>> 
>>>> #+name: invoice(name=data[0,1], address=data[1,1], country=data[2,1])
>>>> #+begin_src latex
>>>> name
>>>> address
>>>> country
>>>> #+end_src
>>>> 
>>>> #+RESULTS: invoice
>>>> #+BEGIN_LaTeX
>>>> John Doe
>>>> Doestreet 42
>>>> Doecountry
>>>> #+END_LaTeX
>>>> 
>>>> what I would like to do:
>>>> 
>>>> #+name: invoice(data=data)
>>>> #+begin_src latex
>>>> data[0,1]
>>>> data[1,1]
>>>> data[2,1]
>>>> #+end_src
>>>> 
>>>> or even better:
>>>> 
>>>> #+name: invoice(data=data)
>>>> #+begin_src latex
>>>> data['Name']
>>>> data['Adress']
>>>> data['Country']
>>>> #+end_src
>>>> 
>>>> 
>>>> 
>>>> 
>>> 
>>> -- 
>>> Thomas S. Dye
>>> http://www.tsdye.com
>> 
> 
> -- 
> T.S. Dye & Colleagues, Archaeologists
> 735 Bishop St, Suite 315, Honolulu, HI 96813
> Tel: 808-529-0866, Fax: 808-529-0884
> http://www.tsdye.com

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

end of thread, other threads:[~2012-03-18 19:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-18  8:40 table as parameter for latex block Martin Halder
2012-03-18 18:29 ` Thomas S. Dye
2012-03-18 19:10   ` Martin Halder
2012-03-18 19:29     ` Thomas S. Dye
2012-03-18 19:55       ` Martin Halder

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