2

Here's my needs. I have a latex file or template, some content of this file(say company name) needs to be changed according to different companies. I want to write a shell script satisfying this need, help me auto compilation and generating the corresponding pdf file.

Is anyone having similar experiences before? Thanks!

  • 4
    This question appears to be off-topic because it is about shell scripting rather than TeX. – cfr Jul 16 '14 at 03:03
  • Use sed and/or gawk. But this is not a TeX question and would be better asked elsewhere. – cfr Jul 16 '14 at 03:04
  • 1
    You do not need a shell script for this. There are more than one on-topic LaTeX solutions for this. – Fran Jul 16 '14 at 03:53
  • Following up on what @Fran said, you might want to look at: http://tex.stackexchange.com/questions/5228/can-one-tex-file-output-to-multiple-pdf-files But yeah, as things stand, I'm voting to close as off-topic, since the question is explicitly about shell scripting. – Adam Liter Jul 16 '14 at 04:00
  • (If you rephrase the question to ask what *TeX-related ways you can achieve the same result as some shell script might, the powers that be may vote to reopen the question.) Another possibility: create a .csv file and then use datatool or csvsimple to spit out several identical files mutatis mutandis. – jon Jul 16 '14 at 04:58

2 Answers2

2

A childplay for the textmerg package. A simple example:

You have this text file called data.dat where every tree lines of text contain the name, surname and name company:

David
Smith
Tipix

Edoardo
Vinchenzo
Pizzaboom

And a simple template file.tex:

\documentclass{article}
\usepackage{textmerg} 

\begin{document}

\Fields{\Name\Surname\Company} 

\Merge{data.dat}{ 

Dear Mr. \Name{} \Surname{},

Your company \Company{} has .... 

\bigskip\hrule\bigskip 

 }

\end{document}

Then, compiled as usual (pdflatex file.tex) the result is:

MWE

Fran
  • 80,769
1

Have a look at the most rated answer here. There is a description how to inject a switch for an if clause. You could inject your names in a script somehow like this:

pdflatex -jobname outputname "\def\name{Hello world} \input{foo.tex}"

You choose output name and Hello world in your script.