1

All of the threads I can find about Citations and LaTeX are about citing directly in LaTeX. I'm using a template to convert Obsidian markdown files to PDF via LaTeX (and Pandoc).

Is there a way to e.g. use \cite{@citekey} from Zotero so LaTeX automatically handles citations?

So that I'd write text in Obsidian, "quote bla bla"^[@Smith2022, 15] and it gets rendered via LaTeX and the Libary.bib file as something like "quote bla bla"^[Smith 2022, 15] (with "^[]" being a footnote here).

Optimally, this would then also create a full note in Chicago author-date format in the Bibliography section. Similar to how the Microsoft Word plugin that creates a bibliography from used citations.

Edit: My test .latex file:

\begin{filecontents}{foo.bib}
@article{foo, 
    author={dingle}, 
    tile={Foo is funny}, 
    year={2022}, 
}
@article{anotherkey,
  author = {Writer, A.},
  year = {2011},
  title = {Headline},
  publisher = {Publication},
}
\end{filecontents}



\documentclass{article}

% Load BibLaTeX and set the style to Author-Year
\usepackage[style=authoryear]{biblatex}

% Tell BibLaTeX to use the file `example.bib` for the bibliography database
\addbibresource{foo.bib}    

\begin{document}

    Cite a reference \cite[]{foo}

    Force a citation to be made via footnote \footcite{anotherkey}

    \printbibliography

\end{document}

foo.bib is in the same folder as my .latex file, and currently includes:

@article{foo, 
    author={foo}, 
    tile={Foo is funny}, 
    year={2022}, 
}
@article{anotherkey,
  author = {Writer, A.},
  year = {2011},
  title = {Headline},
  publisher = {Publication},
}

@ARTICLE{Gill,
   author    = "A. E. Gill",
   title     = "Some Simple Solutions for Heat-Induced Tropical Circulation",
   journal   = "Quart. J. R. Met. Soc.",
   volume    = 106,
   year      = 1980,
   pages     = "447-462",
}

2 Answers 2

1

I don't understand what problem you have with this, but I hope that a minimal example can solve any problem. Said, you have this foo.md file:

foo @foo and [@foo]

By default, pandoc is not aware that you are citing anything, so conversion from markdown to LaTeX produce just plain text:

foo @foo and {[}@foo{]} 

But if you inform to pandoc that you are using a bibtex bibliography (Zotero can do that) with --bibliography foo.bib, where foo.bib is:

@article{foo, 
    author={foo}, 
    tile={Foo is funny}, 
    year={2022}, 
}

Then the result is

foo foo (2022) and (foo 2022)

\hypertarget{references}{%
\section*{References}\label{references}}
\addcontentsline{toc}{section}{References}

\hypertarget{refs}{}
\begin{cslreferences}
\leavevmode\hypertarget{ref-foo}{}%
foo. 2022. ``Foo is funny.''
\end{cslreferences}

So the references section is already included. Now, you only need to convert it again with the -s option (standalone) to have a compilable file and not only the chunk showed here, i.e.:

pandoc -s  -f markdown -t latex foo.md  --bibliography foo.bib -o foo.tex

... or to have directly the pdf:

pandoc -s  -f markdown -t pdf  foo.md  --bibliography foo.bib -o foo.pdf

If you want the references generated by LaTeX and not by pandoc, then you can add the option --biblatex to produce that LaTeX text:

foo \textcite{foo} and \autocite{foo}

Or --natbib where the result is:

foo \citet{foo} and \citep{foo}

And of course, add also -s and -bibliography foo.bib to make a complete latex file.

Note that here the references are no included but the LaTeX code to produce the references (also different in each case) using bibtex or biber, so you cannot obtain directly the PDF version from pandoc using natbib or biblatex options. If you have not a clear idea of how compile these versions with LaTeX, see here.

For instance, with natbib the result should be:

foo foo [2022] and [foo, 2022]

References

foo. Foo is funny. 2022.

But better than messing with pandoc's options directly, add a YAML header an use a capable interpreter. For example, with quarto render foo.qmd in the prompt system, where foo.qmd file is:

---
format:
  pdf:
    biblio-style: apa
    cite-method: biblatex
bibliography: foo.bib
---

foo @foo and  [@foo] 

The result is this foo.pdf:

mwe

You can also do render quarto files from VScode and Rstudio with a single click.

4
  • I really appreciate your effort, but I'm still struggling. I'm wondering if I'm missing any packages, because the rendered references and bibliography do not show up. I've tried following along this post because it seems similar to your solution: andreasmhallberg.github.io/managing-citations-in-latex But I've still got nothing. I'll edit my post to add the entirety of my current test .latex file. Thank you so much for your help! Dec 7, 2022 at 11:13
  • I just noticed I'm getting an error for the citation: LaTeX Warning: Citation 'foo' on page 1 undefined on input line 26. LaTeX Warning: Empty bibliography on input line 30. Does that help? Dec 7, 2022 at 12:18
  • @ReaderGuy42 I compiled without problems your own LaTeX test file added to the question. Are you sure that you follow the compilations steps correctly? (i.e., pdlatex test.tex → biber test → pdlatex test.tex → pdlatex test.tex)
    – Fran
    Dec 7, 2022 at 14:27
  • Thanks! I have now figured it out, it was that my Editor was using BibTeX by default as their backend for bibliographies. I wasn't able to figure it out for Gummi, but for TeXstudio I could select Biber to do it, and now it works :) Thanks for the assistance!! Dec 7, 2022 at 20:46
0

I managed to figure it out! The problem was my Editor. Both Gummi and TexStudio appear to use BibTeX by default as their backend for bibliographies. I wasn't able to figure it out for Gummi, but for TeXstudio I could select Biber to do it, and now it works :)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .