Add support for biblatex-chicago as a cite-method? #2117
Replies: 3 comments 7 replies
-
It seems you got everything you need to write a format extension which will do exactly what you want. |
Beta Was this translation helpful? Give feedback.
-
Oooh I just came across this commit (07fe91d) that provides an undocumented (at least at Quarto.org) option for format:
pdf:
biblio-config: false
cite-method: biblatex The I'll work up an example of a working format that can handle both regular biblatex styles like But it seems like |
Beta Was this translation helpful? Give feedback.
-
Given the existence of the 1: Copy a template partial that is included in the preamble (i.e. before 2: Add a conditional statement to the partial file that will add $if(biblatex)$
% ----------
% BibLaTeX
% ----------
$if(biblatex-chicago)$
\usepackage[$if(biblio-style)$$biblio-style$,$endif$$for(biblatexoptions)$$biblatexoptions$$sep$,$endfor$]{biblatex-chicago}
$else$
\usepackage[$if(biblio-style)$style=$biblio-style$,$endif$$for(biblatexoptions)$$biblatexoptions$$sep$,$endfor$]{biblatex}
$endif$
\addbibresource{$bibliography$}
$endif$ 3: Configure the YAML like so: format:
pdf:
biblio-config: false # No default \usepackage[]{biblatex}
template-partials: # Use the updated partial file
- "path/to/title.tex"
cite-method: biblatex # Use biblatex
biblatex-chicago: true # Enable biblatex-chicago
biblio-style: authordate # Use the author-date style (or notes)
biblatexoptions: # Set any other Chicago-specific options
- backend=biber
- isbn=false 4: That's it! You can see a working version of this at a custom format I made (YAML settings; custom partial) |
Beta Was this translation helpful? Give feedback.
-
Currently there are three possible options allowed in
cite-method
when using the PDF or LaTeX format: citeproc, natbib, and biblatex. Using any other option produces an error:This is ordinarily totally fine—most biblatex styles are supported by defining the
style
option inbiblatexoptions
. For instance, this YAML:…generates this LaTeX output using the default Quarto template:
…and similar styles can be defined, like
style=mla
,style=nature
,style=ieee
, and so on. Most biblatex styles follow the same pattern:However, one of the more popular biblatex styles,
biblatex-chicago
, does not recommend or use this same pattern. Because Chicago is a super complex citation system, the package authors decided to simplify its core options into a package with a different name/alias:biblatex-chicago
:Theoretically there is a way to use the different Chicago styles by loading just
\usepackage{biblatex}
, but this is not recommended—see this StackExchange answer and sections 4.5.1 and 5.5.1 in the manual. In general, these two commands are 90% equivalent (using thebiblatex-chicago
package does a bunch of other changes behind the scenes too):Those options can all be set in the YAML section of a Quarto document,
but (1) that's a ton of options, and (2) even with all those options, the resulting style still isn't exactly what
\usepackage[style=authordate]{biblatex-chicago}
produces, sincebiblatex-chicago.sty
makes a bunch of other adjustments too.In an effort to make as few changes to the Quarto/pandoc LaTeX template as possible (i.e. not providing my own modified
template.tex
and instead relying on a handful of custom partials or preexisting YAML options that set pandoc template variables), I've been playing with different ways to getbiblatex-chicago
to play nicely with Quarto, but so far haven't found a way.Here's what I've tried:
1. Use
cite-method: biblatex-chicago
This would be a simple (perhaps simplest?) approach? If it were somehow possible to add
biblatex-chicago
as an acceptablecite-method
in YAML, and then add something like this in the main template:…then everything could be configured through YAML:
However, the
biblio.tex
template would also need to be adjusted, since it currently uses this to generate\printbibliography
:Since Pandoc template conditionals don't seem to support an OR operator, a parallel if statement for
$if(biblatex-chicago)$
would also have to be added, which isn't great 🤷2. Load
biblatex-chicago
using theinclude-in-header
optionAnother approach I tried was putting the command for loading
biblatex-chicago
in a separate .tex file and injecting that into the preamble:This successfully adds
\usepackage{biblatex-chicago}
to the LaTeX file, but becausebiblatex-chicago
is really just a fancy/complex alias for the regular biblatex package, and because the template already loaded biblatex earlier in the document due tocite-method: biblatex
, it causes a package conflict error:…since you can't load the same package twice
So that doesn't work 🤷
3. Don't use
cite-method: biblatex
but do loadbiblatex-chicago
using theinclude-in-header
optionTo force the template to not emit
\usepackage[...]{biblatex}
, I omittedcite-method
in the YAML:That, however, automatically triggers
citeproc
and Pandoc's CSL-based handling of citations, and adds theCSLReferences
environment at the end to contain all the citeproc-processed references, bypassingbiblatex-chicago
completely.I tried to stop that by adding
citeproc: false
to the YAML, and that did indeed stop the CSL processing, but it also stopped all citation processing completely—citation keys in the rendered document remained like@citekey
.So that also won't work.
4. Use a Lua filter?
I then got desperate and tried to see if I could create a Lua filter that would find/replace
{biblatex}
with{biblatex-chicago}
, given some sort of YAML flag:That way, all the conditional parts of the template that depend on
$if(biblatex)$
would still work, but the auto-generated\usepackage[...]{biblatex}
command would get replaced with\usepackage[...]{biblatex-chicago}
.But it seems like pandoc's Lua filter system can only access the AST of the markdown file, not anything in the template or preamble, so this is also a no-go.
5. Make a copy of
template.tex
Creating a copy of
template.tex
and adding\usepackage[...]{biblatex-chicago}
myself definitely works, but then I lose all future changes to Quarto's version of the file.6. Give up and just use the CSL version of Chicago
This would also work, though the CSL version of Chicago isn't as complete as
biblatex-chicago
(i.e. handling specific types of magazines, historical archives, etc.)Ultimately, I guess I'm just trying to find a way to use
\usepackage[...]{biblatex-chicago}
instead of\usepackage[...]{biblatex}
with minimal manual template overrides, relying on the Quarto/pandoc template as much as possible. I'm not sure what the best approach for any of this is—or if it even lies in the scope of Quarto (or if it's more of a pandoc issue?). Chicago is a popular citation style (it's Quarto's default when using CSL)—it would be neat/maybe important to support it through biblatex too.Beta Was this translation helpful? Give feedback.
All reactions