Friday, 15 January 2010

pdf - Insert values from a file in a latex document -


If there is a latex document, how can I read some key-values ​​from a file, insert them in the document?

Something like this:

Latex code:

  Customer ID: $ {customerID}  

text file :

  CustomerID = 123456  

and the resulting .pdf should have a Customer ID in the file.

We can always write a Perl script to extend ...

Defs.txt:

  customerID = 123456 Customer Tel = 22530000000  

doc.tex:

  \ documentclass { Article} \ start {document} latex customer ID: $ {customerID} and $ {address} costume tailfusion ID: $ {customerTel} \ end {document}  

perl script Tech- def:

  #! / Usr / bin / perl -n BEGIN {$ tex = 0;} If (not $ tex and /^(\w+)=(.*)/) {$ v {$ 1} = $ 2} If (/ \ Documentclass \ {/) {$ tex = 1} if ($ tex) {S / \ $ \ {(\ w +) \} / $ v {$ 1} || / GE "$ 1 ???"; Print}  

test (after chmod ...):

  $ tex-def defs.txt doc.tex \ documentclass {article} \ start {Document} Latex customer ID: 123456 and ??? Address cost telephone ID: 22530000000 \ end {document}  

No comments:

Post a Comment