I would like to create a book (to be exact a psalter). Basically it is a database issue. I have on one hand a tex document (to be exact currently it's still a word document) with all the psalms and on the other the book I want where I want to insert selected psalm from the first document. I don't know how to start to keep it simple. I look to datatool but can a psalm be an entry ? Or Should a create a document for each psalm that will be called ? If yes, how can I do it quickly ? Can I call the psalm base on its title in the document containing all the psalm ?
2 Answers
A database can contain whatever you want as data associated to a key. Even a longish text. Just need a database (-style package, you presumably just have a single key --psalm number/name-- and associated data --text--) package to handles that.
The Linux (BSD original, some work on porting to other platforms) strfile(1)
utility (part of fortune-mod here) takes files made of paragraphs and creates a file indexed with the paragraphs for random access, you'd need to hack it to add a key. It could give some inspiration.
Or kludge up a script in some scripting language that reads text with some marker like %% identifier
lines, and reads a file containing something like:
identifier1
Lorem ispum dolor sit amet, ...
%
identifier2
Sed ut perspiciatis unde omnis iste natus error sit...
looks up the identifier and replaces by the following text.
-
I haven't try yet but according to
datatool
user guide, we cannot have paragraph break (and maybe no other command...)– JBOPApr 19, 2020 at 7:55
I have found a solution to call the psalm I need from a master file composed of all the palms. So, in a .tex file, I have the "database" containing all the psalms. Each psalm is within a command which serve as a identifier. Here is an example:
\newcommand{\PsalmI}{%
Lorem ipsum...
}
\newcommand{\PsalmII}{%
Sed ut perspiciatis unde omnis iste natus error sit...
}
In order to call the psalm, I need to call the macro \PsalmI
for example.
However, as the psalm I called based on the content of another databased, I have created another command \Psalmus
which name depends on the variable:
\newcommand{\Psalmus}[1]{\csname Psalm#1\endcsname}
To call the psalm, I just need to call it through the macro: \Psalmus{II}
for example. This calls the macro \PsalmII
and displays the second psalm.
This solution is based on Ulrike Fischer's solution to this topic.
\include
or\input
to input them.psalm-x.tex
and then use a loop overx
, but this is really a matter of whether you want a 3 line master document or a 150 line master document. If you do need mix and match versions, then just keep a database of the filenames and usedatatool
or similar processing to do the different versions.\include
or\input
but that mean I need to create a a document for each psalm that is to say 150 documents... Is there an easy way to create those documents ?.tex
document. This is something you do only once. xkcd.com/1205 Since you're converting from Word, I would recommend using a unicode engine like XeLaTeX or LuaLaTeX. But I suspect there may be more issues lurking in the conversion than in the creating 150 files.