Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BibTeX bibliography for PDF output #19

Open
0x0f0f0f opened this issue May 14, 2021 · 11 comments
Open

BibTeX bibliography for PDF output #19

0x0f0f0f opened this issue May 14, 2021 · 11 comments

Comments

@0x0f0f0f
Copy link

It'd be very cool to support bibtex citations!

@MichaelHatherly
Copy link
Owner

There's some rudimentary support for this already, implemented in

Publish.jl/src/load.jl

Lines 19 to 39 in c03914f

function loadrefs(env)
# Loading of references/bibliography. We can either load a `.bib` file for
# use in LaTeX/PDF output, which turns on `citations = biblatex` for
# control of how citations are printed out to LaTeX.
#
# Our other option is to print out basic citations using a JSON or TOML
# source. TODO: write conversion from JSON/TOML to BIB and back so that we
# can use either source for biblatex bibliographies.
if haskey(env["publish"], "latex") && haskey(env["publish"]["latex"], "bibliography")
env["publish"]["citations"] = "biblatex"
else
refs = env["publish"]["references"]
if isa(refs, String) && isfile(refs)
# TODO: support YAML and XML as well?
env["publish"]["references"] =
endswith(refs, ".toml") ? TOML.parsefile(refs) :
endswith(refs, ".json") ? JSON.Parser.parsefile(refs) : []
end
end
return env
end
but undocumented currently since I'm not yet decided on the final public interface for it. It is something I'd like to finish off, but just requires time to complete mostly.

@0x0f0f0f
Copy link
Author

wooooohhhh cool! will try it out and let you know!

@0x0f0f0f
Copy link
Author

I tried with latest commit. In my Package.toml:

[publish]
author = "test"
title = "DRAFT"

[publish.latex]
bibliography = "bibliography.bib"

My bibliography.bib

@article{grant2002principles,
  title={Principles of Programming Languages Version 1.0. 3},
  author={Grant, Mike and Palmer, Zachary and Smith, Scott},
  year={2002}
}
note: this is a BETA release; ask questions and report bugs at https://tectonic.newton.cx/
Running TeX ...
warning: ./sections/calculator.tex:53: Overfull \hbox (169.03484pt too wide) in paragraph at lines 53--53
warning: warnings were issued by the TeX engine; use --print and/or --keep-logs for details.
Running xdvipdfmx ...
Writing `./WPLJ.toc` (685 B)
Writing `./WPLJ.pdf` (33.36 KiB)
Writing `./WPLJ.bcf` (88.40 KiB)
Writing `./WPLJ.run.xml` (2.29 KiB)
Writing `./WPLJ.aux` (1.90 KiB)
Writing `./WPLJ.out` (344 B)
INFO - This is Biber 2.14
INFO - Logfile is './WPLJ.blg'
INFO - Reading './WPLJ.bcf'
ERROR - Error: Found biblatex control file version 3.4, expected version 3.7.
This means that your biber (2.14) and biblatex (3.11) versions are incompatible.
See compat matrix in biblatex or biber PDF documentation.
INFO - ERRORS: 1
┌ Error: An error happened whilst watching files; shutting down. Error was: CompositeException(Any[TaskFailedException(Task (failed) @0x00007fb8ffe49510)])
└ @ LiveServer ~/.julia/packages/LiveServer/N0zZq/src/file_watching.jl:109
@MichaelHatherly
Copy link
Owner

MichaelHatherly/Tectonic.jl#4 (comment)

It's not documented anywhere in this package, but the biber and biblatex versions need to be compatible with each other. See "Compatibility matrix" in https://anorien.csc.warwick.ac.uk/mirrors/CTAN/biblio/biber/documentation/biber.pdf. 2.14 and 3.14 go together, and since tectonic itself has not updated it's biblatex version, we need to keep this biber version at 2.14.

Not sure why it's picked up biblatex 3.11... is this with a completely fresh tectonic cache?

@0x0f0f0f
Copy link
Author

yes. i downgraded biber to 2.11 and it worked, but it'd be cool to have it work out of the box

@MichaelHatherly
Copy link
Owner

What's your package versions for Publish and Tectonic? Tectonic's binaries for biber and tectonic are meant to be compatible without user intervention, you shouldn't have to change things manually. Off a fresh install of Publish 0.8.0 and Tectonic 0.4.1 it builds alright and uses biber 2.14.

julia> pdf("Project.toml", "output")
note: this is a BETA release; ask questions and report bugs at https://tectonic.newton.cx/
Running TeX ...
Fontconfig warning: "/usr/share/fontconfig/conf.avail/05-reset-dirs-sample.conf", line 6: unknown element "reset-dirs"
Running xdvipdfmx ...
Writing `./pubtest.toc` (202 B)
Writing `./pubtest.aux` (1.21 KiB)
Writing `./pubtest.run.xml` (2.31 KiB)
Writing `./pubtest.out` (42 B)
Writing `./pubtest.bcf` (99.20 KiB)
Writing `./pubtest.pdf` (10.46 KiB)
INFO - This is Biber 2.14
INFO - Logfile is './pubtest.blg'
INFO - Reading './pubtest.bcf'
INFO - Found 0 citekeys in bib section 0
WARN - The file './pubtest.bcf' does not contain any citations!
INFO - Writing './pubtest.bbl' with encoding 'UTF-8'
INFO - Output to ./pubtest.bbl
INFO - WARNINGS: 1
note: this is a BETA release; ask questions and report bugs at https://tectonic.newton.cx/
Running TeX ...
Fontconfig warning: "/usr/share/fontconfig/conf.avail/05-reset-dirs-sample.conf", line 6: unknown element "reset-dirs"
Rerunning TeX because "pubtest.run.xml" changed ...
Running xdvipdfmx ...
Writing `./pubtest.bcf` (99.20 KiB)
Writing `./pubtest.pdf` (10.69 KiB)
Skipped writing 4 intermediate files (use --keep-intermediates to keep them)
"Project.toml"
@0x0f0f0f
Copy link
Author

[[Publish]]
deps = ["Base64", "CommonMark", "DataStructures", "FilePathsBase", "FileTrees", "HTTP", "IOCapture", "IterTools", "JSON", "LiveServer", "Logging", "Mustache", "Pkg", "PrettyTables", "Requires", "TOML", "Tectonic"]
git-tree-sha1 = "b302581743a08b5a542bba0beac0300360b51742"
uuid = "f065f642-d108-4f50-8aa5-6749150a895a"
version = "0.8.0"

[[Tectonic]]
deps = ["Pkg"]
git-tree-sha1 = "753a4ae3be7e03ae9c2654b8c98bca8b2c5a51be"
uuid = "9ac5f52a-99c6-489f-af81-462ef484790f"
version = "0.4.1"
@MichaelHatherly
Copy link
Owner

Are you able to find the tectonic cache files? (On linux they're under $USER/.cache/Tectonic.) It just seems as though the biblatex cache hasn't updated to 3.14. Simplest approach may be to just delete the tectonic cache and let it try and redownload stuff, which might fix it.

(Do you have a system-installed tectonic by any chance? That could possibly also have something to do with it.)

@0x0f0f0f
Copy link
Author

Yes, I do have a system tectonic. I'll try deleting the cache!

$ tectonic -V
Tectonic 0.4.1
@0x0f0f0f
Copy link
Author

works with packages installed from registry now, thanks!! might be worth to add a note to delete tectonic cache if it was installed in the system before, or to specify a different cache directory for Publish.jl, maybe?

@MichaelHatherly
Copy link
Owner

or to specify a different cache directory for Publish.jl, maybe?

That would be ideal, are you aware of whether that's supported in tectonic or not? Last time I check about that I couldn't find an option to change it from the standard one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants