TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am very new to LaTeX. First question I have is can latex do this?

  1. I have ~1000 verses
  2. Each verse has its meaning in English and Sanskrit.
  3. three authors commentaries on each verse.

When I finish typing, I want to be able to generate following pdfs.

  1. Only verses as a pdf
  2. Verses with english meaning as pdf
  3. Verses with Sanskrit meaning as pdf
  4. Verses with Meaning & commentaries as a pdf.

If LaTeX can do this then, please tell me how should I arrange my documents to avoid lot of copy pasting later. enter image description here

share|improve this question
Can you show us a document with 1 verse, its meanings and commentaries? – Alan Munn Mar 14 '12 at 1:57
I have added image to the question with the outlet of the text. Commentary 1 and 3 are identical just in the image but it would not be in real life. and highlight if first line in commentary is more of ms paint issue its not needed. – Raama Mar 14 '12 at 13:37
This answer shows something similar. There I used a CSV file to keep all the verses and translations and the datatool package to display and manipulate them. It was aimed at a word-by-word gloss style, but the basic idea could easily adapted to your purpose. – Alan Munn Mar 14 '12 at 15:41

You can think of your Project as being some form of a dictionary and to manage a dictionary you will need a database. Here you have many choices and they depend on your knowledge of a computer language that you are comfortable with. Another issue to consider is if you will insert the notes yourself or other people will assist you.

I will assume no prior computer programming knowledge but a willingness to invest your time in effortful learning of TeX/LaTeX. The basic approach in building a TeX database was described in Managing hundreds of separate components in a large document

In the comments of the above post, it was suggested by predrag that a versioning control system be introduced. If you are not familiar with one I would either recommend either Git with github or fossil. When Predrag recommended the latter this was new to me as well. Fossil has a great advantage besides its ease of use; for one it has a built-in wiki, which can be invaluable on its own for a Project like yours or a thesis and can be published on the web very easily if you will have collaborators. It took me about 5 minutes to set it up on windows (which I normally battle with). As I had WAMP installed for other work it worked well with localhost.

Now let us consider how to organize the information and the TeX database.

We will keep an index for each record in lists. For example the english verses can be saved in a list such as:


Similarly the other language verses can be also be stored in list:


The author comments can be done similarly:




If you have more authors this can be extended at a later stage. Building flexibility into the system at this stage is important.

To add english verses, sanskrit and commentary you will type:


Here is a MWE for english verses only, the rest is similar and you can extend.

\long\expandafter\def\csname#1\endcsname{\textbf{#1}: #2}
  \@for \next:=\enverse\do{%
% print the activities

Of course it will be preferable if you had a small GUI (graphical user interface) for entering the records rather than typing it out \addenglish, although you can alias the commands to shorter versions. In this case I would also let go of the TeX database and use ansqlite database with a browser front end and only describe the typesetting macros. Using Lua for this might be a good idea as it opens up many more opportunities to use LuaLaTeX. Whatever you decide spent a week or two preparing and trying things out before you commit to a final solution.

(Alternative solution brew for the brave. Use LuaLaTeX. Use luasqlite3 and sqlite3 to store the records. Create a lua GUI interface using wxLua for ease of capturing, export to LaTeX. If you get it working please let us know).

share|improve this answer
Thanks for your elaborate answer. I had to read it few times to understand it, but looks like I begin to appreciate what you re saying. If I run into implementation then I will ask for more help. Thank you – Raama Mar 16 '12 at 12:24

In my opinion these tasks should not be processed by a typesetting language like LaTeX. It is a task beyond the actual typesetting scope, I would recommend to outsource it. For example:

  1. Save each component in an extra file, e.g. verse/verse001.txt, meanE/meanE001.txt, meanS/meanS001.txt, commE/commE001.txt, commS/commS001.txt. These could also be .tex files or .md.
  2. Merge these files in any order, e.g. to display verse, english meaning and commetory for verse number 023 into a single file, type

    cat verse/verse023.txt meanE/meanE023.txt commE/commE023.txt >> vmEc023.txt

    You could run a bash script to loop through all numbers, or wildcards like verse/* to include all matching files.

  3. Use pandoc to convert the file to a pdf:

    pandoc -s -S vmEc023.txt -o vmEc023.pdf

Step 2 is actually redundant since pandoc is able to accept multiple space-seperated files as input.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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