0

I would like to use several bibleref styles in the same document because some time I need abbreviated reference (e.g. jerusalem style), and at some other places I need to cite a reference in a more literal manner (e.g. default style).

It is possible to achieve it by changing the style locally:

\documentclass[a4paper]{article}
\usepackage[T1]{fontenc} 
\usepackage[utf8]{inputenc}
\usepackage{bibleref}
% \usepackage{indextools}
% \makeindex

\biblerefstyle{jerusalem}

\begin{document}
A reference with the style defined globally: \bibleverse{Gn}(1:1-3)

A reference using another style to make it appear as text:
\biblerefstyle{default}\bibleverse{Gn}(1:1-3)\biblerefstyle{jerusalem}

Again, a reference with the style defined globally: \bibleverse{Gn}(1:1-3)

% \printindex
\end{document}

code result But it would be convenient to define a command such as \bibleversetxt which would locally change the styles automatically. Because of the parsing of parentheses, the following obviously doesn't work:

\newcommand{\bibleversetxt}[1]{%
  \biblerefstyle{default}\bibleverse{#1}\biblerefstyle{jerusalem}}%

Any idea of how to achieve that?


Note: if one uses indexing (\ibibleverse instead of \bibleverse), another problem arises since the reference will appear in the index on both styles: index image

If the solution could also address this issue that would be awesome! Thanks.

3

I'm not actually a bible enthusiast.

But I like the TeXnical challenge. ;-)

\documentclass[a4paper]{article}
\usepackage[T1]{fontenc} 
\usepackage[utf8]{inputenc}
\usepackage{bibleref}[2018/07/31]
\usepackage{indextools}
\usepackage{verbatim} % just for printing the index-files verbatim
%\usepackage{hyperref}
\makeindex


\makeatletter

% Patch for bibleref  2018/07/31 1.20 (NLCT and MR)
%
% Attempt at separating style for textual reference from style for reference in the index
% by introducing \biblerefindexstyle.
%
% \biblerefindexstyle sets the style for index-entries.
%
% This is a quick and dirty approach: With those macros that trigger processing of
% index-entries I inserted local scopes via \begingroup..\endgroup.
% Within these local scopes \biblerefstyle gets executed with the value provided as
% \biblerefindexstyle right before creating the index entries.
%
% I cannot guarantee that everything will work out correctly as I did not have
% time for in-depth study of the code.

\newcommand\@@biblerefindexstyle{}%
\newcommand\biblerefindexstyle[1]{%
  \renewcommand\@@biblerefindexstyle{#1}%
}%
\renewcommand*{\@end@@bibleverse}{%
  \if@bv@idx
    \begingroup
    \biblerefstyle{\@@biblerefindexstyle}%
    \expandafter\@do@bibleref@map\@@bv@idxsort\relax
    \ifx\@bv@idxentry\@empty
      \def\@bv@tmp{\@bv@mainidxentry}%
    \else
      \def\@bv@tmp{\@bv@mainidxentry!\@bv@chidxsort @\@bv@idxentry}%
    \fi
    \edef\@bv@tmpc{\@bv@idxpgformat}%\@bv@tmpa and \@bv@tmpb are tokens
    \ifx\@empty\@bv@tmpc%
      \@do@biblerefindex%
          {\@@bv@idxsort\relax @\@bv@tmp}%
    \else%
        \@do@biblerefindex%
            {\@@bv@idxsort\relax @\@bv@tmp|\@bv@idxpgformat}%
    \fi%
    \endgroup
    \@bv@idxfalse
  \fi
  \@bv@restore
  \bbl@ifunset{bbl@active@\string:}%
  {}%
  {\shorthandon:}%
}%
\renewcommand*{\@bible@verse}[1]{%
  \bbl@ifunset{bbl@active@\string:}%
    {}%
    {\shorthandoff:}%
  \@ifundefined{br@#1}%
  {%
    \PackageError{bibleref}{Unknown book '#1'}{}%
  }%
  {%
    \begingroup
    \biblerefstyle{\@@biblerefindexstyle}%
    \@bv@idxsort{\csname br@#1\endcsname}%
    \endgroup
    \def\@bv@chidxsort{}%
    \BRbooktitlestyle{\csname br@#1\endcsname}%
    \begingroup
    \biblerefstyle{\@@biblerefindexstyle}%
    \let\@bv@org@bookof\BRbookof
    \let\@bv@org@booknumberstyle\BRbooknumberstyle
    \let\@bv@org@epistletothe\BRepistletothe
    \let\@bv@org@epistlenumberstyle\BRepistlenumberstyle
    \def\BRbookof{\string\BRbookof\space}%
    \def\BRbooknumberstyle{\string\BRbooknumberstyle\space}%
    \def\BRepistletothe{\string\BRepistletothe\space}%
    \def\BRepistlenumberstyle{\string\BRepistlenumberstyle\space}%
    \@ifundefined{bri@#1}%
    {%
      \protected@edef\@bv@mainidxentry{%
         \protect\BRbooktitlestyle{\csname br@#1\endcsname}}%
    }%
    {%
      \protected@edef\@bv@mainidxentry{%
         \protect\BRbooktitlestyle{\csname bri@#1\endcsname}}%
    }%
    \let\BRbookof\@bv@org@bookof
    \let\BRbooknumberstyle\@bv@org@booknumberstyle
    \let\BRepistletothe\@bv@org@epistletothe
    \let\BRepistlenumberstyle\@bv@org@epistlenumberstyle
    \expandafter\endgroup
    \expandafter\def\expandafter\@bv@mainidxentry\expandafter{\@bv@mainidxentry}%
  }%
  \new@ifnextchar(%
    {\BRbkchsep\@bibleverse}%
    {\@end@@bibleverse}%
}%
\makeatletter

% Facilities for applying styles in local scopes only:

\newenvironment{biblerefscope}[1]{\biblerefstyle{#1}}{}%
\newcommand\UseBiblerefstyle[2]{\begingroup\biblerefstyle{#1}#2\endgroup}%
\newenvironment{biblerefindexscope}[1]{ \biblerefindexstyle{#1}}{}%
\newcommand\UseBiblerefindexstyle[2]{\begingroup\biblerefindexstyle{#1}#2\endgroup}%

% Set the global styles:

\biblerefstyle{jerusalem}
\biblerefindexstyle{default}

\begin{document}

References with the style defined globally: \\
\ibibleverse{Gn}(1:1-3)\\
\ibiblechvs{IICo}({12}:10-14)\\
\ibiblevs{Ex}({20}:15-17)

References using another style to make them appear as text:\\
\begin{biblerefscope}{default}%
\ibibleverse{Gn}(1:1-3)\\
\ibiblechvs{IICo}({12}:10-14)\\
\ibiblevs{Ex}({20}:15-17)
\end{biblerefscope}%

Again references with the style defined globally:\\
\ibibleverse{Gn}(1:1-3)\\
\ibiblechvs{IICo}({12}:10-14)\\
\ibiblevs{Ex}({20}:15-17)

References using another style to make them appear as text:\\
\UseBiblerefstyle{default}{%
  \ibibleverse{Gn}(1:1-3)\\
  \ibiblechvs{IICo}({12}:10-14)\\
  \ibiblevs{Ex}({20}:15-17)
}%

Again, a reference with the style defined globally:\\
\ibibleverse{Gn}(1:1-3)\\
\ibiblechvs{IICo}({12}:10-14)\\
\ibiblevs{Ex}({20}:15-17)

\printindex

\vfill
\leavevmode
\kern-\parindent
\kern-1in\kern-\hoffset\kern-\evensidemargin
\hbox to\paperwidth{\hrulefill}
\vfill
\begingroup\centering This is the .idx-file:\bigskip\par\endgroup
\leavevmode
\kern-\parindent
\kern-1in\kern-\hoffset\kern-\evensidemargin
\vbox{\hsize=\paperwidth\relax\centering
\fbox{\vbox{\hsize=.9\paperwidth \tiny\verbatiminput{\jobname.idx}}}\par}%
\vfill
\leavevmode
\kern-\parindent
\kern-1in\kern-\hoffset\kern-\evensidemargin
\hbox to\paperwidth{\hrulefill}
\vfill
\begingroup\centering This is the .ind-file:\bigskip\par\endgroup
\leavevmode
\kern-\parindent
\kern-1in\kern-\hoffset\kern-\evensidemargin
\vbox{\hsize=\paperwidth\relax\centering
\fbox{\vbox{\hsize=.4\paperwidth \tiny\verbatiminput{\jobname.ind}}}\par}%
\vfill
\end{document}

enter image description here

enter image description here

  • Thank you! This is a bit too complicated for me to understand everything, but it does the job! @Maïeul, maybe would you be interested to include something like this in the package? – Tobard Aug 14 '18 at 14:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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