SublimeText / LaTeXTools

LaTeX plugin for Sublime Text
https://latextools.readthedocs.io/
2.01k stars 365 forks source link

Bibliography doesn't get printed when using biblatex and \nocite{*} #1581

Closed vinograd0v closed 1 year ago

vinograd0v commented 1 year ago

Biblatex:

There is an issue that occurs when using biblatex and not making any citation in the entire document, basically it does not print the bibliography and the "\nocite{}" command does not work. Once we make at least one citation in the entire document, the "\nocite{ }" command works and the problem is fixed. However, if we do not want to make any citation in the entire document, a quick solution for this is to make a phantom citation, that is, one that does not affect the final document but solves the problem. To do this, we implement the following in our .tex file:

\newcommand{\phantomcite}[1]{
    \phantom{\cite{#1}}
    \nocite{*}
}

So at the end of our document, before using "\printbibliography", we put the command "\phantomcite{"here put any citation from your references"}" and that will solve the problem. This command executes a phantom citation and is followed by the "\nocite{*}" command, so it will no longer be necessary to use it.

\documentclass{article}

\usepackage{biblatex}

\newcommand{\phantomcite}[1]{
    \phantom{\cite{#1}}
    \nocite{*}
}

\addbibresource{sample.bib}

\begin{document}

Test. 

\phantomcite{dirac}

\printbibliography
\end{document}

Another way to fix the problem is before using "\nocite{*}" put "nocite{"some of your reference"}":

\documentclass{article}

\usepackage{biblatex}

\addbibresource{sample.bib}

\begin{document}

Test. 

\nocite{dirac}
\nocite{*}

\printbibliography
\end{document}

As mentioned earlier, the problem is related to "\nocite{*}". In this solution, it is not necessary to add the "\phantomcite" from the previous solution.

vinograd0v commented 1 year ago

That's a quickly solutions

vinograd0v commented 1 year ago

You can check

https://github.com/mmanosalva/SublimeTeX