schochastics / quarto-cv

Templates to create CVs/Resumes with Quarto
MIT License
110 stars 11 forks source link

Possibility to include bibliography #1

Closed lorenzoFabbri closed 12 months ago

lorenzoFabbri commented 12 months ago

@schochastics I am trying to include my bibliography from a bib file.

At first I added bibliography: bibliography.bib to the YAML, and then

---
nocite: |
  @*
---

::: {#refs}
:::

to the body of the document. But I get this error:

! LaTeX Error: Environment CSLReferences undefined.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.262 \begin{CSLReferences}
                           {1}{0} 

I then added this to template.tex:

$if(csl-refs)$
  \newlength{\cslhangindent}
  \setlength{\cslhangindent}{1.5em}
  \newenvironment{CSLReferences}%
    {$if(csl-hanging-indent)$
      \setlength{\parindent}{0pt}%
      \everypar{\setlength{\hangindent}{\cslhangindent}}\ignorespaces
    $endif$}%
  {\par}
$endif$

which seems to work with the default stype, but if I change the csl (to e.g., AMA 11) it does not anymore.

> R.version
               _                           
platform       x86_64-pc-linux-gnu         
arch           x86_64                      
os             linux-gnu                   
system         x86_64, linux-gnu           
status                                     
major          4                           
minor          3.1                         
year           2023                        
month          06                          
day            16                          
svn rev        84548                       
language       R                           
version.string R version 4.3.1 (2023-06-16)
nickname       Beagle Scouts   
schochastics commented 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.

lorenzoFabbri commented 12 months ago

I tried to play around with citations.tex and biblio.tex but I keep getting the following error:

LaTeX Error: Environment CSLReferences undefined.
schochastics commented 12 months ago

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.

cjdbarlow commented 11 months ago

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}
:::