Customizing biblatex citation with entry type for ICD-206 standards

biblatexbiblatex-chicagocitingfootcite

Background

I am writing a Turabian-styled thesis and use the biblatex-chicago package for my citations and bibliography generation. Citations are all footnotes, but unclassified sources are cited in Chicago style and classified sources have to follow ICD 206 D.3.a.(6).(a)-(i) for Source Reference Citation (SRC). This means there are extra fields and the order is different between unclassified and classified citations.

Source Reference Citation (SRC) Order:

  1. Portion Marking that presents the classification of the SRC; I.E. (U) or (S)
  2. Identification of the information originator (author, producer, owner, publishing office)
  3. Unambiguous source identifier or document number
  4. Portion marked classification of the document title
  5. Document title, with volume and issue number, if applicable
  6. Date of publication or access
  7. Page number, if applicable
  8. Classification of the information extracted from the source
  9. Overall classification of the source document
  10. Source descriptor portion marking, if applicable
  11. Source descriptor statement, if applicable

How I Think It Works

I can think of three ways to accomplish this.

  1. Use one of the other @categories and put the information in the wrong sections just to get the order correct in the citation.

  2. Use a keyword in the .bib entry that cues biblatex to order entry differently.

  3. Create a new entry type called @src that has the categories I need and orders them properly.

Option 1 would just be using @misc and the notes field to input my own long string.

refs.bib

@misc{sourceReference1,
  author = {{(U) Smith, John}},
  notes  = {{12345678; (U) The Title...; 17 March 2022; Unclassified; Super Secret}},
}

@article{chicagoReference1,
  title       = {Has the ODNI Improved US Intelligence Analysis?},
  author      = {Gentry, John A},
  year        = {2015},
  publisher   = {Taylor \& Francis}
}

This would come close, producing something like:

  1. (U) Smith, John. 12345678; (U) The Title…; 17 March 2022;
    Unclassified; Super Secret

  2. John A. Gentry, "Has the ODNI Improved US Intelligence Analysis?"
    (Taylor & Francis, 2015)

Ideally, option 3 would be cleanest if it is possible. For example:

refs.bib:

@src{sourceReference1,
  src_class   = {U},              % Classification of the entire SRC
  originator  = {Smith, John},    % Originator, author, producer, owner, etc
  identifier  = {12345678},       % Unambiguous source identifier
  title_class = {U},              % Classification of the title
  title       = {The Title...},   % Title of the document
  date        = {2022-03-17},     % Date of publication
  page        = {},               % Page number, if applicable
  info_class  = {Unclassified},   % Classification of the information extracted
  doc_class   = {Super Secret},   % Classification of the source document
  descriptor  = {},               % Source descriptor, if applicable
  keywords    = {classified}      % To separate out in the bibliography
}

@article{chicagoReference1,
  title       = {Has the ODNI Improved US Intelligence Analysis?},
  author      = {Gentry, John A},
  year        = {2015},
  publisher   = {Taylor \& Francis}
}

master.tex:

\documentclass{turabian-researchpaper}

\usepackage[utf8]{inputenc}
\usepackage[pass,letterpaper]{geometry}
\usepackage{setspace}
\usepackage{biblatex-chicago}
    \addbibresource{refs.bib}

\begin{document}

This is a test.
\footcite{SourceReference1}.    %This won't work because a @SRC is made up right now
This is also a test. 
\footcite{chicagoReference1}

\clearpage
\printbibliography

\end{document}

This should produce two footnotes:

  1. (U) Smith, John; 12345678; (U) The Title…; 17 March 2022;
    Unclassified; Super Secret

  2. John A. Gentry, "Has the ODNI Improved US Intelligence Analysis?"
    (Taylor & Francis, 2015)

The first footnote would be in a different order than the other one, because the other one is the standard biblatex-chicago style. To make things easier, I put the "@src" information in order in the .bib file. In the actual bibliography I would separate them using keywords, I know how to do that separately.

Any ideas of how or if possible to accomplish this?

Thank you!

Best Answer

How can I create entirely new data types with BibLaTeX/Biber? has a guide to defining new entry types in biblatex.

In principle that guide can be used for all biblatex styles, but integrating the new type into the style so that everything works seamlessly can be a bit of a challenge especially with a complex style such as biblatex-chicago.

The following code seems to work OK-ish with biblatex-chicago.

The main obstacle to using the code from How can I create entirely new data types with BibLaTeX/Biber? directly was that biblatex-chicago needs specific drivers for citations as well, so that each \DeclareBibliographyDriver{<new type>} needs a corresponding \DeclareBibliographyDriver{cite:<new type>} for citations.

\begin{filecontents}{stackexchange.dbx}
\DeclareDatamodelEntrytypes{stackexchange}
\DeclareDatamodelFields[type=field,datatype=literal]{
  sitekey,
  sitetopic,
}
\DeclareDatamodelFields[type=list,datatype=name]{
  askp,
  ansp,
}
\DeclareDatamodelFields[type=field, datatype=date, skipout]{
  askdate,
  ansdate,
  askeditdate,
  anseditdate}
\DeclareDatamodelFields[type=field, datatype=verbatim]{
  askid,
  askpid,
  anspid,
  ansid,
}
\DeclareDatamodelEntryfields[stackexchange]{
  sitekey,
  sitetopic,
  askid,
  askp,
  askpid,
  ansp,
  anspid,
  ansid,
  askyear,
  askmonth,
  askday,
  ansyear,
  ansmonth,
  ansday,
  askedityear,
  askeditmonth,
  askeditday,
  ansedityear,
  anseditmonth,
  anseditday,
  title}
\end{filecontents}
\documentclass[english]{article}
\usepackage{babel}
\usepackage{csquotes}
\usepackage[datamodel=stackexchange,backend=biber]{biblatex-chicago}
\usepackage{hyperref}



\begin{filecontents*}{english-stack.lbx}
  \ProvidesFile{english-stack.lbx}[2014/05/07 english with additions for stackexchange]
  \InheritBibliographyExtras{english}
  \NewBibliographyString{asked,answered,edited}
  \DeclareBibliographyStrings{%
    inherit   = {english},
    asked     = {{asked}{asked}},
    answered  = {{answered}{answered}},
    edited    = {{edited}{edited}},
  }
\end{filecontents*}
\DeclareLanguageMapping{english}{english-stack}

\DeclareFieldFormat[stackexchange]{title}{\mkbibquote{#1\isdot}}
\DeclareFieldFormat{askpid}{%
  \mkbibparens{\ifhyperref
    {\href{http://tex.stackexchange.com/users/#1}{\nolinkurl{#1}}}
    {\nolinkurl{#1}}}}

\DeclareFieldFormat{anspid}{%
  \mkbibparens{\ifhyperref
    {\href{http://tex.stackexchange.com/users/#1}{\nolinkurl{#1}}}
    {\nolinkurl{#1}}}}

\DeclareFieldFormat{askid}{%
  \mkbibparens{\ifhyperref
    {\href{http://tex.stackexchange.com/q/#1}{\nolinkurl{#1}}}
    {\nolinkurl{#1}}}}

\DeclareFieldFormat{ansid}{%
  \mkbibparens{\ifhyperref
    {\href{http://tex.stackexchange.com/a/#1}{\nolinkurl{#1}}}
    {\nolinkurl{#1}}}}

\newbibmacro*{stackexchangequestion}{%
  \printfield{title}%
  \setunit{\addspace}%
  \printfield{askid}%
}

\newbibmacro*{stackexchangeask}{%
  \bibstring{asked}%
  \setunit{\addspace}%
  \printaskdate%
  \iffieldundef{askedityear}%
    {}
    {\printtext[parens]{%
       \bibstring{edited}%
       \setunit{\addspace}%
       \printaskeditdate}}%
  \setunit{\addspace}%
  \bibstring{byauthor}%
  \setunit{\addspace}%
  \printnames{askp}%
  \setunit{\addspace}%
  \printfield{askpid}%
}

\newbibmacro*{stackexchangeans}{%
  \bibstring{answered}%
  \setunit{\addspace}%
  \printansdate%
  \iffieldundef{ansedityear}
    {}
    {\printtext[parens]{%
       \bibstring{edited}%
       \setunit{\addspace}%
       \printanseditdate}}%
  \setunit{\addspace}%
  \bibstring{byauthor}%
  \setunit{\addspace}%
  \printnames{ansp}%
  \setunit{\addspace}%
  \printfield{anspid}%
}

\newbibmacro*{stackexchangesite}{%
  \printfield{sitetopic}}

\DeclareBibliographyDriver{stackexchange}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{stackexchangequestion}%
  \newunit\newblock
  \usebibmacro{stackexchangeask}%
  \newunit\newblock
  \usebibmacro{stackexchangeans}%
  \newunit\newblock
  \usebibmacro{stackexchangesite}%
  \newunit\newblock
  \usebibmacro{finentry}}



\DeclareBibliographyDriver{cite:stackexchange}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{stackexchangequestion}%
  \newunit\newblock
  \usebibmacro{stackexchangeask}%
  \newunit\newblock
  \usebibmacro{stackexchangeans}%
  \newunit\newblock
  \usebibmacro{stackexchangesite}%
  \newunit\newblock
  \usebibmacro{finentry}}


\begin{filecontents*}{\jobname.bib}
@stackexchange{se:l3help,
  sitetopic = {tex},
  title   = {What can \textit{I} do to help the \LaTeX3 Project},
  askdate = {2012-02-26},
  askid   = {45838},
  askp    = {Brent Longorough},
  askpid  = {344},
  ansp    = {Frank Mittelbach},
  anspid  = {10109},
  ansdate = {2012-03-01},
  ansid   = {46427},
}
\end{filecontents*}
\addbibresource{\jobname.bib}
\addbibresource{biblatex-examples.bib}

\begin{document}
Lorem\autocite{se:l3help}
ipsum\autocite{sigfridsson}
Lorem\autocite{se:l3help}
ipsum\autocite{sigfridsson}
\printbibliography
\end{document}

As mentioned in the comments \DeclareBibliographyAlias{cite:stackexchange}{stackexchange} might be cheaper than having to copy the entire driver definition if they are the same, but I believe there are subtle differences between citations and references in Chicago style, so you may have to have two independent declarations after all.

Related Question