dcpurton / biblatex-sbl

Society of Biblical Literature (SBL) style files for biblatex
25 stars 6 forks source link

Support related:quotedin #103

Open dcpurton opened 5 years ago

dcpurton commented 5 years ago

See https://sblhs2.com/2019/03/28/snippet-text-collections/

These kind of entries could be supported using a related entry.

Something like this MWE:

\documentclass{article}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@series{ACCS,
  series = {Ancient Christian Commentary on Scripture},
  shortseries = {ACCS},
  options = {skipbib}
}
@book{edwards:1999,
  editor = {Edwards, Mark J.},
  title = {Galatians, Ephesians, Philippians},
  series = {\citeseries{ACCS} New Testament},
  number = {8},
  location = {Downers Grove, IL},
  publisher = {InterVarsity Press},
  date = {1999}
}
@classictext{victorinus:ephesians,
  author = {Victorinus, Marius},
  title = {Epistle to the Ephesians},
  related = {edwards:1999},
  relatedtype = {quotedin}
}
@classictext{theodoret:galatians,
  author = {Theodoret},
  title = {Epistle to the Galatians},
  related = {edwards:1999},
  relatedtype = {quotedin},
}
\end{filecontents}
\usepackage[style=sbl]{biblatex}
\usepackage[colorlinks]{hyperref}
\addbibresource{\jobname.bib}
\newcommand*{\begrelateddelimquotedin}{\addcomma\space}

\makeatletter

% Handle options

\pretocmd{\blx@opt@citetracker@true}
  {\def\blx@entrytracker{\blx@xsanitizeafter\blx@entrytracker@global}}{}{}
\pretocmd{\blx@opt@citetracker@false}
  {\let\blx@entrytracker\relax}{}{}
\pretocmd{\blx@opt@citetracker@context}
  {\def\blx@entrytracker{\blx@xsanitizeafter\blx@entrytracker@context}}{}{}
\pretocmd{\blx@opt@citetracker@strict}
  {\def\blx@entrytracker{%
     \blx@ifcitesingle{\blx@xsanitizeafter\blx@entrytracker@global}{}}}{}{}
\pretocmd{\blx@opt@citetracker@constrict}
  {\def\blx@entrytracker{%
     \blx@ifcitesingle{\blx@xsanitizeafter\blx@citetracker@context}{}}}{}{}

% Macros

\def\blx@entrytracker@global#1{%
  \ifbool{citetracker}
    {\edef\blx@tempa{#1}%
     \xifinlistcs\blx@tempa{blx@bsee@\the\c@refsection}
       {}
       {\listcsxadd{blx@bsee@\the\c@refsection}\blx@tempa}}
    {}}

\def\blx@entrytracker@context#1{%
  \ifbool{citetracker}
    {\edef\blx@tempa{#1}%
     \iftoggle{blx@footnote}
       {\xifinlistcs\blx@tempa{blx@fsee@\the\c@refsection}
          {}
          {\listcsxadd{blx@fsee@\the\c@refsection}\blx@tempa}}
       {\xifinlistcs\abx@temp@entrykey{blx@bsee@\the\c@refsection}
          {}
          {\listcsxadd{blx@bsee@\the\c@refsection}\blx@tempa}}}
    {}}

\def\blx@citetracker@global{%
  \blx@xsanitizeafter\blx@entrytracker@global{\abx@field@entrykey}}

\def\blx@citetracker@context{%
  \blx@xsanitizeafter\blx@entrytracker@context{\abx@field@entrykey}}

\newbibmacro*{related:quotedin}[1]{%
  \entrydata*{#1}{%
    \edef\abx@field@setkey{\thefield{clonesourcekey}}%
    \ifentryseen{\thefield{clonesourcekey}}
      {\blx@citetracker}
      {\bibhypertarget{\thefield{clonesourcekey}}{}%
       \blx@entrytracker{\thefield{clonesourcekey}}}%
    \usedriver
      {\renewbibmacro*{related:init}{}}
      {\ifbibliography
         {\thefield{entrytype}}
         {cite:\thefield{entrytype}}}%
  \blx@citetracker}%
  \newunit
  \printfield{postnote}}
\renewbibmacro*{cite}{%
  \boolfalse{suppresspostnote}%
  \boolfalse{usevolpostnotedelim}%
  \global\togglefalse{usingibid}%
  \global\togglefalse{inentrytype}%
  \global\toggletrue{blx@testpostnotedelim}%
  \ifciteseen
    {\iffieldequalstr{relatedtype}{quotedin}
       {}
       {\global\toggletrue{relatedseen}}}
    {\global\togglefalse{relatedseen}}%
  \ifciteseen{}{\iffieldundef{pages}{}{\booltrue{suppresspostnote}}}%
  \iffieldundef{shorthand}
    {\ifciteseen{}{\bibhypertarget{\thefield{entrykey}}{}}}
    {}%
  \printtext{%
    \ifboolexpr{%
        test {\ifciteibid}
        and
        not test {\iffirstonpage}
    }
      {\usebibmacro{cite:ibid}}
      {\usebibmacro{ifciteuseshorthand}
         {\usebibmacro{cite:shorthand}}
         {\usedriver{%
            \ifboolexpr{
              togl {bbx:related}
              and
              test {\iffieldequalstr{relatedtype}{quotedin}}
            }
              {\savefield{postnote}{\blx@tempa}%
               \iffieldundef{altpostnote}
                 {\clearfield{postnote}%
                  \global\booltrue{suppresspostnote}}
                 {\savefield{altpostnote}{\blx@tempb}%
                  \restorefield{postnote}{\blx@tempb}}%
               \restorefield{altpostnote}{\blx@tempa}}
              {}}{cite:\thefield{entrytype}}%
          \ifcsstring{blx@shorthand}{intro}
            {\usebibmacro{shorthandintro}}
            {}}}}}
\makeatother
\DefineBibliographyStrings{american}{%
  quotedin = {quoted in}
}

\ExecuteBibliographyOptions{citetracker=true}

\begin{document}
\null\vfill

\citefullauthor{victorinus:ephesians} writes, ``The true way of Israel
consists of living according to the
Spirit.'' \autocite[(1.2.12)129]{victorinus:ephesians}

Filler text \autocite[(5.13)77]{theodoret:galatians}.

\printbiblist{abbreviations}
\printbibliography
\end{document}
dcpurton commented 5 years ago

Some support may yet be added directly to biblatex. See https://github.com/plk/biblatex/issues/902