xuhdev / vim-latex-live-preview

A Vim Plugin for Lively Previewing LaTeX PDF Output
https://www.topbug.net/blog/2013/06/13/live-preview-of-latex-in-vim/
GNU General Public License v3.0
832 stars 73 forks source link

Document with biblatex bibliography "Failed to compile bibliography" #46

Closed ChrisLane closed 4 years ago

ChrisLane commented 7 years ago

Expected behaviour

Expect the plugin to compile successfully and display the PDF.

Actual behaviour

Vim displays "Failed to compile bibliography". From looking at the files in /tmp, everything seems to have compiled fine and the PDF looks correct.

Steps to reproduce

  1. Create these files "test.tex": https://paste2.org/BjB2YcEs and "test.bib": https://paste2.org/Zhhnyngc
  2. Try to run :LLPStartPreview

System configuration

badouralix commented 7 years ago

Hi @ChrisLane! Thank you very much for your clear bug report!

Running the bib compiler by hand, I got it failing with this error message:

This is BibTeX, Version 0.99d (TeX Live 2017/Arch Linux)
The top-level auxiliary file: test.aux
I found no \citation commands---while reading file test.aux
I found no \bibdata command---while reading file test.aux
I found no \bibstyle command---while reading file test.aux
(There were 3 error messages)

According to Google, these are bibtex related errors. Running biber instead compiles correctly. Unfortunately, changing bibtex to biber in vim-llp#L195 leads to a bunch of new errors, that need to be fixed... IMHO, the proper way to handle such an edge case would be to rewrite the plugin to use latexmk, but it is still WIP.

For now, a workaround for you is to change the second line of your test.tex to \usepackage[style=authoryear,backend=bibtex]{biblatex}, in order to make it compliant with the tools this plugin uses.

ChrisLane commented 7 years ago

Thanks for your response. I do typically use latexmk when I want to actually output a PDF and so I look forward to that work that's underway.

What I find strange is that a PDF is generated but the plugin doesn't open it in the viewer. I tried making the line change that you mentioned but am still getting the same "Failed to compile bibliography".

badouralix commented 7 years ago

Okay, actually the backend=bibtex only works if some test-blx.bib exists in the main directory. It roughly looks like:

@Comment{$ biblatex control file $}
@Comment{$ biblatex version 2.8 $}
Do not modify this file!

This is an auxiliary file used by the 'biblatex' package.
This file may safely be deleted. It will be recreated as
required.

@Control{biblatex-control,
  options = {2.8:0:0:1:0:1:1:0:0:1:0:2:3:1:79:+:nyt},
}

It can be created by running pdflatex test in the main directory once (dirty workaround, but still).

I couldn't get the PDF properly generated in the tmp directory. There is one (first pdflatex compilation), but bibliography is missing (bib compilation fails and further pdflatex compilations are aborted).

ChrisLane commented 6 years ago

Hopefully there will be a clean solution to this soon :smile:

badouralix commented 6 years ago

ASAP ( but I didn't have enough time to fix it yet 🙈 )

s2-t2 commented 6 years ago

I have a similar issue. Trying to preview the document using :LLPStartPreview gives the error: failed to compile bibliography. Compiling with \ll works fine and a dvi file is created which looks right that can be opened with okular. I am trying to compile this latex template available here: https://www.overleaf.com/latex/templates/wppm-thesis-template/npxqzncsmsch#.Wqk6tUso9hF

I tried using pdflatex BasicDoc.tex which generates BasicDoc-blx.bib and changed the line in Preamble.tex to have backend=bibtex but get the same error. Is there a workaround for this or some very obvious thing i am missing probably ?

smilesun commented 6 years ago

same problem

renan-eccel commented 6 years ago

same here

kevinalexmathews commented 5 years ago

same here

Iddingsite commented 5 years ago

Same here !

leikoilja commented 5 years ago

Oh, sadly still a problem in 2019

AnonymousSnake commented 4 years ago

Still a problem 11/28/2019

Soar-Sir commented 4 years ago

Still a Problem 2020

changmg commented 4 years ago

Still a problem 3/5/2020. I have an alternative trick to skip this bug in Ubuntu 18.04. First, rename the "bibdata.bib" to "bibdata_bib_bk". Second, manually compile the project. "pdflatex main.tex; bibtex main". Third, open vim and type "LL", a pdf preview file without references will be generated. Finally, rename "bibdata_bib_bk" to "bibdata.lib". The pdf preview file will include the references and then you can use it as usual.

sunwukonga commented 4 years ago

I don't have time for a pull request right this minute, but to get this going with bibtex (what the code is already using), you'd need to change your tex file as mentioned above

\usepackage[style=authoryear,backend=bibtex]{biblatex}

and make the following adjustments to how bibtex is called:

        " Update compile command with bibliography                              
        let b:livepreview_buf_data['run_cmd'] =                                 
                \       'env ' .                                                
                \               'TEXMFOUTPUT=' . l:tmp_root_dir . ' ' .         
                \               'TEXINPUTS=' . l:tmp_root_dir                   
                \                            . ':' . b:livepreview_buf_data['root_dir']
                \                            . ': ' .                           
                \ ' && ' .                                                      
                \       b:livepreview_buf_data['run_cmd'] .                     
                \ ' && ' .                                                      
                \       'cd ' . l:tmp_root_dir . ' && bibtex *.aux' .
                \ ' && ' .                                                      
                \       b:livepreview_buf_data['run_cmd']

This calls pdflatex orxelatex on your tex file, and produces the necessary .aux file for bibtex. It then moves to the appropriate directory to run bibtex on all the produced aux files. Absolute paths will NOT work unless you have loosened a particular security restriction in your texmf.cnf file.

In summary, it wouldn't work before because:

  1. Needed to run pdflatex before and after bibtex
  2. Absolute paths are not allowed for security reasons

This can also be done for biber as well:

  1. Your tex could remain the same, because biblatex uses biber by default
  2. Change *.aux to *.bcf used by biber

Ultimately, which executable to use [biber, bibtex], could be selected either by doing a regex for a combination of conditions on the tex file, default bibtex except when biblatex package used with no backend=bibtex option, OR by creating a new option g:livepreview_biber to use biber explicitly, otherwise default to bibtex.