4

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
  • 1
    You are looking for the concept of TeX macros. You should look for \newcommand in your favorite LaTeX manual/documentation.
    – Caramdir
    Commented Jul 24, 2011 at 21:39

1 Answer 1

4

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

\documentclass{paper}
\begin{document}
$x^2 + 2x = \A$
This is some other data: \B.
\end{document}

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

\def\A{…}
\def\B{…}
\input{template}

just fill the with appropriate data.

4

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .