\documentclass{article}
\usepackage{array,calc,fancyvrb}

\usepackage[deffolder=exmpldefs,ignorecfg,
    useverses=verses]{fetchbibpes}

\title{Illustrating the \textsf{fetchbibpes} package}
\author{D. P. Story}
\date{\today}

\addtoBibles{ASV}
\useBookStyle{abbr=long,roman=false}

\addtolength{\marginparwidth}{6pt}
\providecommand\meta[1]{\textsl{\texttt{#1}}}
\def\ameta#1{$\langle\meta{#1}\rangle$}
\providecommand\marg[1]{%
  {\ttfamily\char`\{}\meta{#1}{\ttfamily\char`\}}}
\def\cs#1{{\ttfamily\char`\\#1}}

\begin{document}

\maketitle

\section{The fetch commands}

This package defines two fetching commands, the syntax for these are,
\begin{quote}\ttfamily
   \string\fetchverse[\ameta{opts}]\marg{\meta{book}\symbol{32}\meta{ch}:\meta{vrs}}\\[3pt]
   \string\fetchverses*[\ameta{opts}]\marg{\meta{book}\symbol{32}\meta{ch}:\meta{vrs}} or\\[3pt]
   \string\fetchverses*[\ameta{opts}]\marg{\meta{book}\symbol{32}\meta{ch}:\meta{vrs\ensuremath{{}_1}}-\upshape[\meta{vrs\ensuremath{{}_2}}\upshape]}
\end{quote}
The \texttt{*} parameter is optional, when present the book and verse
references are shown, otherwise they are not.

\verb!\fetchverses*{Gen 1:1-2}! produces ``\fetchverses*{Gen 1:1-2}'' While
\verb!\fetchverses{Gen 1:1-2}! produces ``\fetchverses{Gen 1:1-2}'' Notice in
the first case \texttt{(Gen 1:1-2)} is included with the passage.

With the \ameta{opts} optional arguments, you can typeset the
passage reference in various styles.

There are options for abbreviating the passage reference, as you see below,
different methods are used. An option for capitalizing the passage reference, and formatting
to your heart's desire.

\section{Formatting of passage references}

The default passage reference format was illustrated in the previous section,
we present variations in this section.

\medskip\noindent
\fetchverse[caps,format={\bfseries\sffamily},abbr=none,from*=KJV]{Gen 1:1}

\medskip\noindent
\fetchverse[delims,caps,format={\bfseries\sffamily},abbr=none,transl=(KJV)]{Gen 1:1}

\medskip\noindent
\fetchverse[delims,caps,format={\bfseries\sffamily},abbr=none,from=ISV,transl=(ISV)]{Gen 1:1}

\medskip\noindent
The passage reference may be placed at the end of the passage using the \texttt{citetend}
option. The \cs{priorRefSpc} may be used here to aid placement.
\begin{quote}
\priorRefSpc{\fbFillRght}\afterBookSpc{\ }\fetchverses*[showfirst,citeatend]{Gen 1:1-3}

\priorRefSpc{\fbFitItIn}\afterBookSpc{\nobreak\ }
\fetchverses*[showfirst,citeatend]{Gen 1:1-3}
\end{quote}

\noindent
\verb|\fetchverse[abbr=none,delims={According to }{,},|\\\null
\qquad\verb|enclosewith=\quote]{Gen 1:1}|\\[3pt]
\fetchverse[abbr=none,delims={According to }{,},enclosewith=\quote]{Gen 1:1}

\section{Various abbreviations for books}

\useBookStyle{abbr=none,roman=true}

Here we don't use an abbreviation (full book names are used) and we use
roman numerals for the book number. (I Corinthians versus 1 Corinthians).

\medskip\noindent
\fetchverse{1Co 1:1}

\useBookStyle{abbr=short,roman=false}


\medskip\noindent
\fetchverses*[useperiod=false]{1Co 1:1-5}

\begin{itemize}
\item\fetchverse{Gen 1:11} (This verse is undefined, if you want to
    reference it you need to included it in one of the \textsf{DEF} files.)

\item \fetchverse{Gen 1:10}

\item \fetchverse[from*=ISV]{Gen 1:10}
\end{itemize}

\section{Special formatting a long passage}

%\newcommand{\verseFmt}[1]{${}^{\fb@sc{#1}}$}
\newlength\verseBoxLength
\settowidth{\verseBoxLength}{\normalsize\normalfont0000}
\renewcommand{\verseFmt}[1]{\par\noindent\makebox[\verseBoxLength][c]{#1}}
\afterRef{\par\kern3pt}

In the next passage, I've changed the formatting style of the multiple
passages, it looks more like my own Bible given to me back in the 1980's.

\begin{quote}
\fetchverses*[showfirst,delims,caps,format={\bfseries\sffamily},abbr=none]{Gen 1:1-10}
\end{quote}

\medskip\noindent Now we switch back to the default presentation style
by expanding the command pair \verb|\afterRef{}\verseFmtReset|, needed only if a change
in format occurred outside a group.

\afterRef{}\verseFmtReset

\begin{quote}
\fetchverses*[abbr=none]{Gen 1:2-3}
\end{quote}

\noindent
\fetchverse{Mat 2:1}

\begin{quote}
\fetchverses*[abbr=none]{Mat 2:1-6}
\end{quote}

\noindent
In this next passage, \texttt{KJV+} is used, which includes \textsl{Strong's
Concordance} numbers.\\[3pt]
\fetchverses*[useperiod=false,abbr=short,from*=KJV+]{Rom 1:1}


\paragraph*{Period or no Period.} When an abbreviation is used, you can include
or exclude the period (1 Co. versus 1 Co).
\begin{quote}
\verb|\fetchverse[abbr=long]{1Co 1:1}|\\[3pt]
\fetchverse[abbr=long]{1Co 1:1}

\verb|\fetchverse[abbr=long,useperiod=false]{1Co 1:1}|\\[3pt]
\fetchverse[abbr=long,useperiod=false]{1Co 1:1}
\end{quote}

\section{Side-by-side comparison of passages}

\newlength\fvlength
\begin{flushleft}
\footnotesize \tabcolsep=3pt %.5\columnsep
\setlength{\fvlength}{.5\linewidth-\tabcolsep}
\renewcommand{\verseFmt}[1]{\par\noindent\makebox[\verseBoxLength][c]{{#1}}}%
\settowidth{\verseBoxLength}{000}%\medskip\noindent
\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}>{\footnotesize}p{\fvlength}>{\footnotesize}p{\fvlength}@{}}
\multicolumn{2}{@{}>{\normalsize}c@{}}{\textbf{\textsf{I Kings 1:1-5}:} A Comparison of Versions}\\[3pt]
\multicolumn{1}{@{}>{\small}c@{}}{King James Version (KJV)}&%
\multicolumn{1}{@{}>{\small}c@{}}{International Standard Version (ISV)}\\[3pt]
\fetchverses[showfirst]{1Ki 1:1}&\fetchverses[showfirst,from=ISV]{1Ki 1:1}\\
\fetchverses[showfirst]{1Ki 1:2}&\fetchverses[showfirst,from=ISV]{1Ki 1:2}\\
\fetchverses[showfirst]{1Ki 1:3}&\fetchverses[showfirst,from=ISV]{1Ki 1:3}\\
\fetchverses[showfirst]{1Ki 1:4}&\fetchverses[showfirst,from=ISV]{1Ki 1:4}\\
\fetchverses[showfirst]{1Ki 1:5}&\fetchverses[showfirst,from=ISV]{1Ki 1:5}%
\end{tabular*}
\end{flushleft}

\verseFmtReset

\section{Roman versus arabic numbers}

\begin{itemize}
      \item \fetchverse{1Co 1:1}
      \item \fetchverse[roman]{1Co 1:1}
\end{itemize}

\section{Adding Bibles}

The next example uses \verb~\addtoBibles{ASV}~ in the preamble. The
\textsf{fetchbibpes} package only recognizes three Bible translations, KJV,
KJV+, and ISV, as values of the \texttt{from} or \texttt{from*} key. If you
reference a Bible other than these three, the KJV is used and a warning
appears in the {\TeX} log. However, you can add to the selection of Bibles
with the \texttt{\string\addtoBibles} command in the preamble. I downloaded
the American Standard Version (ASV), copied the first ten verses from
Genesis, and created the \texttt{Gen-ASV.def} file. After placing
\verb~\addtoBibles{ASV}~ in the preamble, I can fetch the verses in the usual
way: \verb!\fetchverses*[from*=ASV]{Gen 1:1-10}!, as seen below with the
passage reference in the margin.

\useBookStyle{abbr,roman=false}

\def\mpfmt#1{\afterRef{{}}\marginpar{\small\raggedright#1}}

\medskip\noindent
\fetchverses*[showfirst,priorref=\mpfmt,delims,from*=ASV]{Gen 1:1-5}

\section{Marginal  notes}

By ``clever'' manipulation of the parameters, you can make
marginal notes of the verses. We declare,
\begin{Verbatim}[xleftmargin=\leftmargini,fontsize=\small]
\fbMarNotesOn
\verseCmts
{%
    {In the beginning}   % v1
    {Earth void}         % v2
    {Light!}             % v3
    {}                   % v4
    {First day}          % v5
}
\end{Verbatim}
\fbMarNotesOn
\verseCmts
{%
    {In the beginning}   % v1
    {Earth void}         % v2
    {Light!}             % v3
    {}                   % v4
    {First day}          % v5
}
\afterRef{\par\kern3pt}

\noindent
We use the \texttt{fpquote} environment with \texttt{rightmargin=0pt}.
\begin{fpquote}[rightmargin=0pt]\marginparpush0pt
\fetchverses*[showfirst,delims,caps,format={\bfseries\sffamily},abbr=none]{Gen 1:1-5}
\end{fpquote}
\afterRef{}\verseCmts{}\fbMarNotesOff

\medskip\noindent Or, with a little more effort, place passage and reference within the margins.
\fbMarNotesOn
\verseCmts{%
    {In the beginning God creates the heaven and the earth\dots}
    {Earth void}
    {Light!}
    {}
    {First day}
}
\newlength\fbrightmargin \fbrightmargin=80pt
\newlength\vrseNumlength
\settowidth\vrseNumlength{\verseFmt{0}}
\renewcommand{\fbMarParFmt}[1]{\marginpar{\footnotesize
    \makebox[0pt][r]{\verseFmt{\vrseNum}%
    \parbox[t]{\fbrightmargin}{\raggedright\strut#1\strut}%
    \hspace{\marginparsep}}\hfill}}
\afterRef{\par\kern3pt}
\begin{fpquote}[leftmargin=0pt,rightmargin=\marginparsep+\fbrightmargin+\vrseNumlength]
\marginparpush0pt
\fetchverses*[showfirst,delims,caps,format={\bfseries\sffamily},abbr=none]{Gen 1:1-5}
\end{fpquote}
\fbResetMarParFmt\verseCmts{}\afterRef{}\fbMarNotesOff


%\newpage
\noindent
We now test the inverse lookup of the full book names (e.g., Genesis $\rightarrow$ Gen)

\medskip\noindent\verb~\fetchverse{Genesis 1:1}~\\
\fetchverse{Genesis 1:1}

\medskip\noindent\verb~\fetchverses{Genesis 1:1-4}~\\
\fetchverses{Genesis 1:1-4}

\medskip\noindent\verb~\fetchverses{ICorinthians 1:1-3}~\\
\fetchverses{ICorinthians 1:1-3}

\end{document}
