A year ago, I worked for a company doing .NET to create a customer report. They use DevExpress to generate a report based on customers' requirements. However, I realized the way it works is just painful and very time-consuming, because everytime they changed the requirement, we have to change a layout a bit due the the font and text data. At that time, I knew nothing a Latex, but I always think there must be a way to work smarter.
Today, while playing with TikZ package, I realized that Latex is just like another programming language, it's super powerful and flexible in term of drawing figure, positioning text, etc... But I'm not sure if we can use a variable inside Latex or not, for example, if I created a layout, says:

x^2 + 2x = A

Then is it possible for A to be a variable so that every time I need to pull out a new data from Database, I can just fit them in that particular position. I've just learned Latex for couple months, so there are many things that are new to me. In advance, I apologize if my question sounds a little insane or nonsense. Lastly, thank you for your time reading.

  • 1
    You are looking for the concept of TeX macros. You should look for \newcommand in your favorite LaTeX manual/documentation. – Caramdir Jul 24 '11 at 21:39

Best way in my opinion would be to use a template.tex:

$x^2 + 2x = \A$
This is some other data: \B.

And to produce a little document42.tex file for every document you want to generate, like this:


just fill the with appropriate data.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.