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 ?
3 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.
- 5,473
-
I haven't try yet but according to
datatooluser guide, we cannot have paragraph break (and maybe no other command...) – JBOP Apr 19 '20 at 07:55 -
@JBOP With datatool you actually cannot have the token
\parbecause many of its macros are not defined in terms of\long. (An empty line in the .tex-input usually also yields the token\par.) But you can copy, e.g., via\let\parcopy=\parand use\parcopywhere paragraph-breaks are needed. Or\csname par\endcsname. The actual problem is: database-entries consisting of a paragraph contain sequences of many characters. Long sequences of many characters cannot be written as a single line of .tex-input in case the database is written to external file. – Ulrich Diez Jul 18 '22 at 14:01
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.
- 97
In case with "tex document" a document for compiling with LaTeX 2ε is meant:
As a variant of my answer to Using Latex code chunks as library - For reusing latex elements such as figures in multiple representations I can offer an interface where files with specifiable sections are of pattern
\filesection{⟨name of file-section⟩}
⟨code⟩
\endfilesection
%-------------------------------------------------------------
\filesection{⟨name of file-section⟩}
⟨code⟩
\endfilesection
%-------------------------------------------------------------
\filesection{⟨name of file-section⟩}
⟨code⟩
\endfilesection
%-------------------------------------------------------------
\endinput
You input these files with the command
\inputfilesection{⟨name of file⟩}{⟨name of file-section⟩}
The ⟨code⟩ of a file-section will be executed only if both the \inputfilesection-command and the \filesection-comand have the same ⟨name of file-section⟩-argument.
In this case ⟨code⟩ will be read under verbatim-catcode-régime. Then the result is passed to \scantokens for re-tokenization and normal processing.
Several \filesections can have the same ⟨name of file-section⟩. In this case all file-sections of the name in question occurring in the file are delivered by \inputfilesection.
CAVEATS I AM AWARE OF:
!!!Don't do \inputfilesection inside files that are called by \inputfilesection!!!
Here is a minimal working example tailored to your need of typesetting psalms.
On my system the example compiles without problems.
If you encounter problems/error-messages/undesired behavior, let me know about it.
%=================================================================================
%
% Via filecontents*-environment let's create an external text file
% `PsalmDatabase.tex` which contains \filesection-commands for denoting single
% portions of the file which can be imported into a document via the command
% \inputfilesection which in turn is defined in the code below.
%
% The external text file PsalmDatabase.tex is created on the fly via
% filecontents*- environment so that it is ensured that it is available when this
% example is compiled. Instead of doing it this way, you can also maintain
% PsalmDatabase.tex as a separate file which is stored in a place where it can
% be foud by LaTeX.
%
%\begin{filecontents*}[overwrite]{PsalmDatabase.tex}
\begin{filecontents*}{PsalmDatabase.tex}
\filesection{Psalm 1}
[This is whatsoever TeX-code for typesetting psalm 1.]
\section*{Psalm 1}
\begin{verbatim*}
Some verbatim material in
code for typesetting psalm 1.
\end{verbatim*}
\endfilesection
%-------------------------------------------------------------
\filesection{Psalm 2}
[This is whatsoever TeX-code for typesetting psalm 2.]
\section*{Psalm 2}
This is psalm 2.
This is psalm 2.
\endfilesection
%-------------------------------------------------------------
\filesection{Psalm 3}
[This is whatsoever TeX-code for typesetting psalm 2.]
\section{Psalm 3}
This is the third psalm.
\begin{verbatim}
Some verbatim material
in code for typesetting psalm 3.
\end{verbatim}
\endfilesection
%-------------------------------------------------------------
\endinput
\end{filecontents}
%=================================================================================
%
\makeatletter
@ifundefined{NewDocumentCommand}{\RequirePackage{xparse}}{}%
%///// begin of code that could go into a package / .sty-file//////////////////
\NewDocumentCommand\inputfilesection{mm}{%
\def@stringincommand{#2}%
\input{#1}%
}%
\newcommand@stringincommand{}%
\newcommand@stringinfile{}%
\NewDocumentCommand\filesection{m}{%
\begingroup
\let\do@makeother\dospecials
\do^^I%
\do^^M%
@filesection{#1}%
}%
\begingroup
\newcommand@filesection[2]{%
\endgroup
\def@filesection##1##2#1{%
\def@stringinfile{##1}%
\expandafter\endgroup
\ifx@stringinfile@stringincommand\expandafter@firstofone\else\expandafter@gobble\fi
{%
\begingroup
\newlinechar=\endlinechar
\scantokens\expandafter\expandafter\expandafter{%
\expandafter\expandafter\expandafter\endgroup
\UD@RemoveLeadingNTrailingCarriageReturn{##2}#2}%
}\ignorespaces
}%
}%
@firstofone{%
\let\do@makeother\dospecials
\catcode\{=1 % \catcode}=2 %
@filesection
}{\endfilesection}{\ignorespaces%}%
%=================================================================================
% Begin of code for removing one leading and one trailing explicit
% <carriage-return>-character-token of catcode 12(other) from verbatimized
% argument
%=================================================================================
@ifdefinable\UD@stopromannumeral{\chardef\UD@stopromannumeral=`^^00}%
%%-----------------------------------------------------------------------------
%% Check whether argument is empty:
%%.............................................................................
%% \UD@CheckWhetherNull{<Argument which is to be checked>}%
%% {<Tokens to be delivered in case that argument
%% which is to be checked is empty>}%
%% {<Tokens to be delivered in case that argument
%% which is to be checked is not empty>}%
%%
%% The gist of this macro comes from Robert R. Schneck's \ifempty-macro:
%% <https://groups.google.com/forum/#!original/comp.text.tex/kuOEIQIrElc/lUg37FmhA74J>
\newcommand\UD@CheckWhetherNull[1]{%
\romannumeral\expandafter@secondoftwo\string{\expandafter
@secondoftwo\expandafter{\expandafter{\string#1}\expandafter
@secondoftwo\string}\expandafter@firstoftwo\expandafter{\expandafter
@secondoftwo\string}\expandafter\UD@stopromannumeral@secondoftwo}{%
\expandafter\UD@stopromannumeral@firstoftwo}%
}%
%%-----------------------------------------------------------------------------
\begingroup
@makeother^^M%
@firstofone{%
\endgroup%
%%=============================================================================
%% Check whether_verbatimized_ argument has a leading explicit
%% <carriage-return>-character-token of catcode 12(other):
%%-----------------------------------------------------------------------------
%% \UD@CheckWhetherLeadingCarriageReturn{<Argument which is to be checked>}%
%% {<Tokens to be delivered in case
%% <argument which is to be checked>'s
%% 1st token is an explicit <carriage-
%% return>-character-token of
%% catcode 12(other)>}%
%% {<Tokens to be delivered in case
%% <argument which is to be checked>'s
%% 1st token is not an explicit
%% <carriage-return>-character-token of
%% catcode 12(other)>}%
\newcommand\UD@CheckWhetherLeadingCarriageReturn[1]{%
\UD@@CheckWhetherLeadingCarriageReturn\UD@SelDom#1\UD@SelDom^^M\UD@@SelDom%
}%
@ifdefinable\UD@@CheckWhetherLeadingCarriageReturn{%
\long\def\UD@@CheckWhetherLeadingCarriageReturn#1\UD@SelDom^^M#2\UD@@SelDom{%
\UD@CheckWhetherNull{#2}{@secondoftwo}{@firstoftwo}%
}%
}%
%%-----------------------------------------------------------------------------
%% Check whether_verbatimized_ argument having a leading explicit <carriage-
%% return>-character-token of catcode 12(other) consists only of such tokens:
%%-----------------------------------------------------------------------------
%% \UD@CheckWhetherOnlyCarriageReturn{<Argument which is to be checked and
%% which is known to have a leading explicit
%% <carriage-return>-character-token of
%% catcode 12(other)>}%
%% {<Tokens to be delivered in case <argument
%% which is to be checked> consists only
%% of explicit <carriage-return>-character-
%% tokens of catcode 12(other)>}%
%% {<Tokens to be delivered in case <argument
%% which is to be checked> does not consist
%% only of explicit <carriage-return>-
%% character-tokens of catcode 12(other)>}%
\newcommand\UD@CheckWhetherOnlyCarriageReturn[1]{%
\UD@CheckWhetherLeadingCarriageReturn{#1}{%
\expandafter\UD@CheckWhetherOnlyCarriageReturn%
\expandafter{\UD@@TrimLeadingCarriageReturn#1}%
}{%
\UD@CheckWhetherNull{#1}{@firstoftwo}{@secondoftwo}%
}%
}%
%%-----------------------------------------------------------------------------
%% Remove one leading explicit <carriage-return>-character-token of
%% catcode 12(other) from verbatimized argument:
%%-----------------------------------------------------------------------------
@ifdefinable\UD@@TrimLeadingCarriageReturn{%
\long\def\UD@@TrimLeadingCarriageReturn^^M{}%
}%
%%-----------------------------------------------------------------------------
%% Check whether_verbatimized_ argument has a trailing explicit
%% <carriage-return>-character-token of catcode 12(other):
%%-----------------------------------------------------------------------------
%% \UD@CheckWhetherTrailingCarriageReturn{<Argument which is to be checked>}%
%% {<Tokens to be delivered in case
%% <argument which is to be checked>'s
%% last token is an explicit <carriage-
%% return>-character-token of
%% catcode 12(other)>}%
%% {<Tokens to be delivered in case
%% <argument which is to be checked>'s
%% last token is not an explicit
%% <carriage-return>-character-token of
%% catcode 12(other)>}%
\newcommand\UD@CheckWhetherTrailingCarriageReturn[1]{%
\UD@@CheckWhetherTrailingCarriageReturn#1\UD@SelDom^^M\UD@SelDom\UD@@SelDom%
}%
@ifdefinable\UD@@CheckWhetherTrailingCarriageReturn{%
\long\def\UD@@CheckWhetherTrailingCarriageReturn#1^^M\UD@SelDom#2\UD@@SelDom{%
\UD@CheckWhetherNull{#2}{@secondoftwo}{@firstoftwo}%
}%
}%
%%-----------------------------------------------------------------------------
%% Remove one trailing explicit <carriage-return>-character-token of
%% catcode 12(other) from verbatimized argument:
%%-----------------------------------------------------------------------------
\newcommand\UD@TrimTrailingCarriageReturn[1]{%
\UD@@TrimTrailingCarriageReturn#1\UD@SelDom%
}%
@ifdefinable\UD@@TrimTrailingCarriageReturn{%
\long\def\UD@@TrimTrailingCarriageReturn#1^^M\UD@SelDom{#1}%
}%
%%-----------------------------------------------------------------------------
%% Remove one leading and one trailing explicit <carriage-return>-character-
%% token of catcode 12(other) from verbatimized argument if present.
%% In the edge case of the verbatimized argument consisting only of explicit
%% <carriage-return>-character-tokens of catcode 12(other) remove only one of
%% them.
%% Due to \romannumeral-expansion the result is delivered in 2 expansion-steps:
%%-----------------------------------------------------------------------------
\newcommand\UD@RemoveLeadingNTrailingCarriageReturn[1]{%
\romannumeral%
\UD@CheckWhetherLeadingCarriageReturn{#1}{%
\UD@CheckWhetherTrailingCarriageReturn{#1}{%
\UD@CheckWhetherOnlyCarriageReturn{#1}{%
\expandafter\UD@stopromannumeral\UD@@TrimLeadingCarriageReturn#1%
}{%
\expandafter\expandafter\expandafter\expandafter\expandafter%
\expandafter\expandafter\UD@stopromannumeral\expandafter%
\UD@TrimTrailingCarriageReturn\expandafter{\UD@@TrimLeadingCarriageReturn#1}%
}%
}{%
\expandafter\UD@stopromannumeral\UD@@TrimLeadingCarriageReturn#1%
}%
}{%
\UD@CheckWhetherTrailingCarriageReturn{#1}{%
\expandafter\expandafter\expandafter\UD@stopromannumeral%
\UD@TrimTrailingCarriageReturn{#1}%
}{\UD@stopromannumeral#1}%
}%
}%
}%
%================================================================================
% End of code for removing one leading and one trailing explicit
% <carriage-return>-character-token of catcode 12(other) from verbatimized
% argument
%================================================================================
%///// end of code that could go into a package / .sty-file////////////////////
\makeatother
%================================================================================
% A document where the command \inputfilesection, whose definition forms the code
% that could go into a package / .sty-file, is used for inputting sections/
% portions of the external file PsalmDatabase.tex
%
\documentclass{article}
\begin{document}
\noindent\textbf{Here comes Psalm 1:}\bigskip
\inputfilesection{PsalmDatabase.tex}{Psalm 1}
\bigskip\hrule\bigskip\noindent\textbf{That is Psalm 2:}\bigskip
\inputfilesection{PsalmDatabase.tex}{Psalm 2}
\bigskip\hrule\bigskip\noindent\textbf{Now let's have Psalm 3:}\bigskip
\inputfilesection{PsalmDatabase.tex}{Psalm 3}
\bigskip\hrule\bigskip\noindent\textbf{Here comes Psalm 1 again:}\bigskip
\inputfilesection{PsalmDatabase.tex}{Psalm 1}
\bigskip\hrule\bigskip\noindent\textbf{That is Psalm 2 again:}\bigskip
\inputfilesection{PsalmDatabase.tex}{Psalm 2}
\bigskip\hrule\bigskip\noindent\textbf{Now let's have Psalm 3 again:}\bigskip
\inputfilesection{PsalmDatabase.tex}{Psalm 3}
\end{document}
pdf-output looks like this:
If you wish to split this into several files, you can, e.g., do something like this:
File PsalmDatabase.tex:
\filesection{Psalm 1}
[This is whatsoever TeX-code for typesetting psalm 1.]
\section*{Psalm 1}
\begin{verbatim*}
Some verbatim material in
code for typesetting psalm 1.
\end{verbatim*}
\endfilesection
%-------------------------------------------------------------
\filesection{Psalm 2}
[This is whatsoever TeX-code for typesetting psalm 2.]
\section*{Psalm 2}
This is psalm 2.
This is psalm 2.
\endfilesection
%-------------------------------------------------------------
\filesection{Psalm 3}
[This is whatsoever TeX-code for typesetting psalm 2.]
\section{Psalm 3}
This is the third psalm.
\begin{verbatim}
Some verbatim material
in code for typesetting psalm 3.
\end{verbatim*}
\endfilesection
%-------------------------------------------------------------
\endinput
File inputfilesections.sty:
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{inputfilesections}[2022/07/18 v0.01 import portions of .tex-files]
\@ifundefined{NewDocumentCommand}{\RequirePackage{xparse}}{}%
\NewDocumentCommand\inputfilesection{mm}{%
\def\@stringincommand{#2}%
\input{#1}%
}%
\newcommand\@stringincommand{}%
\newcommand\@stringinfile{}%
\NewDocumentCommand\filesection{m}{%
\begingroup
\let\do\@makeother\dospecials
\do\^^I%
\do\^^M%
\@filesection{#1}%
}%
\begingroup
\newcommand\@filesection[2]{%
\endgroup
\def\@filesection##1##2#1{%
\def\@stringinfile{##1}%
\expandafter\endgroup
\ifx\@stringinfile\@stringincommand\expandafter\@firstofone\else\expandafter\@gobble\fi
{%
\begingroup
\newlinechar=\endlinechar
\scantokens\expandafter\expandafter\expandafter{%
\expandafter\expandafter\expandafter\endgroup
\UD@RemoveLeadingNTrailingCarriageReturn{##2}#2}%
}\ignorespaces
}%
}%
\@firstofone{%
\let\do\@makeother\dospecials
\catcode`\{=1 %
\catcode`\}=2 %
\@filesection
}{\endfilesection}{\ignorespaces%}%
%=================================================================================
% Begin of code for removing one leading and one trailing explicit
% <carriage-return>-character-token of catcode 12(other) from _verbatimized_
% argument
%=================================================================================
\@ifdefinable\UD@stopromannumeral{\chardef\UD@stopromannumeral=`\^^00}%
%%-----------------------------------------------------------------------------
%% Check whether argument is empty:
%%.............................................................................
%% \UD@CheckWhetherNull{<Argument which is to be checked>}%
%% {<Tokens to be delivered in case that argument
%% which is to be checked is empty>}%
%% {<Tokens to be delivered in case that argument
%% which is to be checked is not empty>}%
%%
%% The gist of this macro comes from Robert R. Schneck's \ifempty-macro:
%% <https://groups.google.com/forum/#!original/comp.text.tex/kuOEIQIrElc/lUg37FmhA74J>
\newcommand\UD@CheckWhetherNull[1]{%
\romannumeral\expandafter\@secondoftwo\string{\expandafter
\@secondoftwo\expandafter{\expandafter{\string#1}\expandafter
\@secondoftwo\string}\expandafter\@firstoftwo\expandafter{\expandafter
\@secondoftwo\string}\expandafter\UD@stopromannumeral\@secondoftwo}{%
\expandafter\UD@stopromannumeral\@firstoftwo}%
}%
%%-----------------------------------------------------------------------------
\begingroup
\@makeother\^^M%
\@firstofone{%
\endgroup%
%%=============================================================================
%% Check whether_verbatimized_ argument has a leading explicit
%% <carriage-return>-character-token of catcode 12(other):
%%-----------------------------------------------------------------------------
%% \UD@CheckWhetherLeadingCarriageReturn{<Argument which is to be checked>}%
%% {<Tokens to be delivered in case
%% <argument which is to be checked>'s
%% 1st token is an explicit <carriage-
%% return>-character-token of
%% catcode 12(other)>}%
%% {<Tokens to be delivered in case
%% <argument which is to be checked>'s
%% 1st token is not an explicit
%% <carriage-return>-character-token of
%% catcode 12(other)>}%
\newcommand\UD@CheckWhetherLeadingCarriageReturn[1]{%
\UD@@CheckWhetherLeadingCarriageReturn\UD@SelDom#1\UD@SelDom^^M\UD@@SelDom%
}%
\@ifdefinable\UD@@CheckWhetherLeadingCarriageReturn{%
\long\def\UD@@CheckWhetherLeadingCarriageReturn#1\UD@SelDom^^M#2\UD@@SelDom{%
\UD@CheckWhetherNull{#2}{\@secondoftwo}{\@firstoftwo}%
}%
}%
%%-----------------------------------------------------------------------------
%% Check whether_verbatimized_ argument having a leading explicit <carriage-
%% return>-character-token of catcode 12(other) consists only of such tokens:
%%-----------------------------------------------------------------------------
%% \UD@CheckWhetherOnlyCarriageReturn{<Argument which is to be checked and
%% which is known to have a leading explicit
%% <carriage-return>-character-token of
%% catcode 12(other)>}%
%% {<Tokens to be delivered in case <argument
%% which is to be checked> consists only
%% of explicit <carriage-return>-character-
%% tokens of catcode 12(other)>}%
%% {<Tokens to be delivered in case <argument
%% which is to be checked> does not consist
%% only of explicit <carriage-return>-
%% character-tokens of catcode 12(other)>}%
\newcommand\UD@CheckWhetherOnlyCarriageReturn[1]{%
\UD@CheckWhetherLeadingCarriageReturn{#1}{%
\expandafter\UD@CheckWhetherOnlyCarriageReturn%
\expandafter{\UD@@TrimLeadingCarriageReturn#1}%
}{%
\UD@CheckWhetherNull{#1}{\@firstoftwo}{\@secondoftwo}%
}%
}%
%%-----------------------------------------------------------------------------
%% Remove one leading explicit <carriage-return>-character-token of
%% catcode 12(other) from _verbatimized_ argument:
%%-----------------------------------------------------------------------------
\@ifdefinable\UD@@TrimLeadingCarriageReturn{%
\long\def\UD@@TrimLeadingCarriageReturn^^M{}%
}%
%%-----------------------------------------------------------------------------
%% Check whether_verbatimized_ argument has a trailing explicit
%% <carriage-return>-character-token of catcode 12(other):
%%-----------------------------------------------------------------------------
%% \UD@CheckWhetherTrailingCarriageReturn{<Argument which is to be checked>}%
%% {<Tokens to be delivered in case
%% <argument which is to be checked>'s
%% last token is an explicit <carriage-
%% return>-character-token of
%% catcode 12(other)>}%
%% {<Tokens to be delivered in case
%% <argument which is to be checked>'s
%% last token is not an explicit
%% <carriage-return>-character-token of
%% catcode 12(other)>}%
\newcommand\UD@CheckWhetherTrailingCarriageReturn[1]{%
\UD@@CheckWhetherTrailingCarriageReturn#1\UD@SelDom^^M\UD@SelDom\UD@@SelDom%
}%
\@ifdefinable\UD@@CheckWhetherTrailingCarriageReturn{%
\long\def\UD@@CheckWhetherTrailingCarriageReturn#1^^M\UD@SelDom#2\UD@@SelDom{%
\UD@CheckWhetherNull{#2}{\@secondoftwo}{\@firstoftwo}%
}%
}%
%%-----------------------------------------------------------------------------
%% Remove one trailing explicit <carriage-return>-character-token of
%% catcode 12(other) from _verbatimized_ argument:
%%-----------------------------------------------------------------------------
\newcommand\UD@TrimTrailingCarriageReturn[1]{%
\UD@@TrimTrailingCarriageReturn#1\UD@SelDom%
}%
\@ifdefinable\UD@@TrimTrailingCarriageReturn{%
\long\def\UD@@TrimTrailingCarriageReturn#1^^M\UD@SelDom{#1}%
}%
%%-----------------------------------------------------------------------------
%% Remove one leading and one trailing explicit <carriage-return>-character-
%% token of catcode 12(other) from _verbatimized_ argument if present.
%% In the edge case of the _verbatimized_ argument consisting only of explicit
%% <carriage-return>-character-tokens of catcode 12(other) remove only one of
%% them.
%% Due to \romannumeral-expansion the result is delivered in 2 expansion-steps:
%%-----------------------------------------------------------------------------
\newcommand\UD@RemoveLeadingNTrailingCarriageReturn[1]{%
\romannumeral%
\UD@CheckWhetherLeadingCarriageReturn{#1}{%
\UD@CheckWhetherTrailingCarriageReturn{#1}{%
\UD@CheckWhetherOnlyCarriageReturn{#1}{%
\expandafter\UD@stopromannumeral\UD@@TrimLeadingCarriageReturn#1%
}{%
\expandafter\expandafter\expandafter\expandafter\expandafter%
\expandafter\expandafter\UD@stopromannumeral\expandafter%
\UD@TrimTrailingCarriageReturn\expandafter{\UD@@TrimLeadingCarriageReturn#1}%
}%
}{%
\expandafter\UD@stopromannumeral\UD@@TrimLeadingCarriageReturn#1%
}%
}{%
\UD@CheckWhetherTrailingCarriageReturn{#1}{%
\expandafter\expandafter\expandafter\UD@stopromannumeral%
\UD@TrimTrailingCarriageReturn{#1}%
}{\UD@stopromannumeral#1}%
}%
}%
}%
%================================================================================
% End of code for removing one leading and one trailing explicit
% <carriage-return>-character-token of catcode 12(other) from _verbatimized_
% argument
\endinput
File document.tex:
\documentclass{article}
\usepackage{inputfilesections}
\begin{document}
\noindent\textbf{Here comes Psalm 1:}\bigskip
\inputfilesection{PsalmDatabase.tex}{Psalm 1}
\bigskip\hrule\bigskip\noindent\textbf{That is Psalm 2:}\bigskip
\inputfilesection{PsalmDatabase.tex}{Psalm 2}
\bigskip\hrule\bigskip\noindent\textbf{Now let's have Psalm 3:}\bigskip
\inputfilesection{PsalmDatabase.tex}{Psalm 3}
\bigskip\hrule\bigskip\noindent\textbf{Here comes Psalm 1 again:}\bigskip
\inputfilesection{PsalmDatabase.tex}{Psalm 1}
\bigskip\hrule\bigskip\noindent\textbf{That is Psalm 2 again:}\bigskip
\inputfilesection{PsalmDatabase.tex}{Psalm 2}
\bigskip\hrule\bigskip\noindent\textbf{Now let's have Psalm 3 again:}\bigskip
\inputfilesection{PsalmDatabase.tex}{Psalm 3}
\end{document}
If some of the code in your file-sections requires some package to be loaded in the document-preamble, the file PsalmDatabase.tex can contain a file-section "RequiredPackages" which in turn contains the corresponding \RequirePackage- or \usepackage-commands. This way, if some of the code in your filesections needs some packages, you don't need to remember loading these package. Instead, in the preamble of your document just do \inputfilesection{PsalmDatabase.tex}{RequiredPackages}.
- 28,770

\includeor\inputto input them. – Alan Munn Apr 18 '20 at 16:08psalm-x.texand 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 usedatatoolor similar processing to do the different versions. – Alan Munn Apr 18 '20 at 16:11\includeor\inputbut 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 ? – JBOP Apr 18 '20 at 16:17.texdocument. This is something you do only once. https://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. – Alan Munn Apr 18 '20 at 16:26\filesectionon its own which can be retrieved via\inputfilesection. – Ulrich Diez Apr 23 '22 at 15:44\usepackage{xparse) in order to have things like\NewDocumentCommandwork. (With up-to-date LaTeX 2e-kernel most of the facilities provided by xparse are included into the kernel.) – Ulrich Diez Jul 18 '22 at 13:40