Closed lorenzoFabbri closed 12 months ago
I do recall that I had issues with bib too. Not sure if I tried it but you could try adding https://github.com/quarto-dev/quarto-cli/blob/main/src/resources/formats/pdf/pandoc/biblio.tex to the end of the tex template. This is the standard quarto part for bib.
I tried to play around with citations.tex
and biblio.tex
but I keep getting the following error:
LaTeX Error: Environment CSLReferences undefined.
Having looked into this again now, I remember why I did not implement native bib support. It is a pain. I got something to work like this:
Add this in template.tex
just before the footer.
$if(natbib)$
$if(bibliography)$
$if(biblio-title)$
$if(has-chapters)$
\renewcommand\bibname{$biblio-title$}
$else$
\renewcommand\refname{$biblio-title$}
$endif$
$endif$
$if(beamer)$
\begin{frame}[allowframebreaks]{$biblio-title$}
\bibliographytrue
$endif$
\bibliography{$for(bibliography)$$bibliography$$sep$,$endfor$}
$if(beamer)$
\end{frame}
$endif$
$endif$
$endif$
$if(biblatex)$
$if(beamer)$
\begin{frame}[allowframebreaks]{$biblio-title$}
\bibliographytrue
\printbibliography[heading=none]
\end{frame}
$else$
\printbibliography$if(biblio-title)$[title=$biblio-title$]$endif$
$endif$
$endif$
$if(nocite-ids)$
\nocite{$for(nocite-ids)$$it$$sep$, $endfor$}
$endif$
This goes in the header of template.tex
$if(natbib)$
\usepackage[$natbiboptions$]{natbib}
\bibliographystyle{$if(biblio-style)$$biblio-style$$else$plainnat$endif$}
$endif$
and this into the yaml header:
cite-method: natbib
btw, your error message somehow also points to pandoc being outdated. Not sure how much of a problem this is.
For anyone coming here with the same issue: I implemented the templates for non-academic cvs. But if their are more who want this feature, I will reconsider and try to have a robust way to include bib files.
I wanted to do a similar thing with the modern2-cv
style, this was my solution. No change to the latex template required. I haven't tested with other styles.
Add to the yaml:
bibliography: works.bib #or whatever
citeproc: true
csl: vancouver.csl #download desired style from https://github.com/citation-style-language/styles
Add to the body of the .qmd:
## Publications
---
nocite: |
@*
---
::: {#refs}
:::
@schochastics I am trying to include my bibliography from a
bib
file.At first I added
bibliography: bibliography.bib
to the YAML, and thento the body of the document. But I get this error:
I then added this to
template.tex
:which seems to work with the default stype, but if I change the
csl
(to e.g., AMA 11) it does not anymore.