# What's the best way to arrange LaTeX documents?

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.

-
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 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:

 \enverse{verse0001,verse0002..verse1000}


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

 \latinverse{verse0001,verse0002..verse1000}


The author comments can be done similarly:

 \author@name@i{comments0001,...,comments1000}


and

\author@name@ii


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:

\addenglish{verse-3}{verse1......}


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

\documentclass[11pt]{book}
\usepackage{lstdoc,lipsum,filecontents}
\begin{filecontents*}{verylongverse.tex}
\lipsum[5]
\end{filecontents*}
\begin{document}
\makeatletter
\def\enverse{}
\let\sort\lst@BubbleSort
}
\long\expandafter\def\csname#1\endcsname{\textbf{#1}: #2}
\sort\enverse
}
\def\PrintEnglishVerses{%
\@for \next:=\enverse\do{%
\csname\next\endcsname}
}
%example

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).