Crates.io | mdbook-latex |
lib.rs | mdbook-latex |
version | 0.1.24 |
source | src |
created_at | 2019-08-06 00:17:01.898303 |
updated_at | 2020-02-24 05:56:40.614222 |
description | An mdbook backend for generating LaTeX and PDF documents. |
homepage | |
repository | https://github.com/lbeckman314/mdbook-latex |
max_upload_size | |
id | 154428 |
size | 455,533 |
mdbook-latex
failed to build my book! Now what? >:(
An mdbook backend for generating LaTeX and PDF documents. Utilizes md2tex
for the markdown to LaTeX transformation, but with the goal of allowing alternative markdown to LaTeX converters. If you have developed your own markdown to LaTeX converter, I'd love to talk with you or share ideas! I'm at liam@liambeckman.com.
Warning: Not yet stable — may eat, shred, and atomize your laundry! See the Are We Stable Yet? section for a roadmap to the production release.
Failure: For what to do if and when
mdbook-latex
fails, seemdbook-latex
failed to build my book! Now what? >:(. I'm also available via e-mail if you have any questions or suggestions!
Compiles? | Generated PDF | Generated LaTeX | Source | Online Version |
---|---|---|---|---|
❌ | Source | HTML | ||
❌ | Source | HTML | ||
❌ | Source | HTML | ||
🍊 | Mdbook User Guide | LaTeX | Source | HTML |
❌ | Source | HTML | ||
❌ | Source | HTML | ||
🍊 | Rust Programming Language | LaTeX | Source | HTML |
❌ | Source | HTML | ||
❌ | Source | HTML | ||
❌ | Source | HTML | ||
❌ | Source | HTML |
First, install the following two programs:
Then, to install mdbook-latex
, enter the following in a shell:
cargo install mdbook-latex
Finally, add the following toml
configuration to book.toml
.
[output.latex]
latex = true # default = true
pdf = true # default = false
markdown = true # default = false
The next mdbook build
command will produce LaTeX and PDF files (and the markdown file of your mdbook) in the book/latex/
directory.
To uninstall mdbook-latex
, enter the following in a shell:
cargo uninstall mdbook-latex
Then delete the [output.latex]
configuration in book.toml
:
- [output.latex]
- latex = true
- pdf = true
- markdown = true
mdbook-latex
is built upon some really wonderful projects, including:
md2tex
and mdbook-latex
are developed in tandem, but are meant to be independent programs. Therefore, if one wishes to use an alternative markdown-to-tex conveter, they should be able to plug it in to mdbook-latex
with ease.Broadly speaking, there are three steps, or "transformations", from mdbook
source to PDF output:
mdbook-latex
): retreives the JSON formatted data from mdbook
. Calls md2tex
and tectonic
for LaTeX and PDF generation, respectively.md2tex
): converts markdown input to LaTeX output.tectonic
): creates PDF document from LaTeX input.Pull requests, forks, and plain old copy-pasting are actively encouraged! Also, I am relatively new to Rust (and programming in general) so recommendations or advice in general is always appreciated.
mdbook-latex
or md2tex
?Either one. mdbook-latex
can be thought of as a frontend for the LaTeX generation done by md2tex
. So if there is a LaTeX error, you may favor creating an issue with md2tex
. Otherwise, creating an issue with mdbook-latex
is a good bet. But any issue is a good issue, so don't worry if it's in the "right" repository or not, I should be able to see it regardless!
Below is a list of features I am currently working on (loosely in a "top-down" direction).
book/latex
directory to keep src
clean.current
event with fold
).The following projects served as guidance for mdbook-latex
(or are simply cool enough that they deserve to be shared!):
mdbook-epub: A backend for mdbook that creates EPUB files.
mdbook-linkcheck: A backend for mdbook
that will verify URL links.
LaTeX-rs: A cool library for programmatic LaTeX generation that I hope to eventually incorporate.
crowbook: A rich program that can generate HTML, PDF, and EPUB files from markdown code. Has a neat online demo page to try it out interactively. Similar in some respects to mdbook
, but with an added focus on "novels and fiction". Though general enough to handle a lot of different projects.
no starch press: The Rust Programming Language made professionally by a proper publishing company. Guranteed to have fewer errors than mdbook-latex
!
lumpy-leandoc: A more elegant approach to markdown-LaTeX conversion via pulldown_cmark
than that currently provided by md2tex
. Also includes parallelism via Rayon and syntax highlighting via syntect!
mdbook-latex
failed to build my book! Now what? >:(Oops! That means I still have more work to do. If you absolutely need your PDF right now, then the quicket option is to select the print
icon in the upper right corner of the online page of your book.
Another method is to run the markdown file through an alternative markdown to LaTeX converter like pandoc
:
pandoc --from markdown --to latex book/latex/MY_BOOK.md -o book/latex/MY_BOOK.pdf
Or run it through a free (as in free parking) online solution:
If, however, you don't mind getting your hands dirty with LaTeX, here is my process for when the build step fails:
book.toml
to only output LaTeX and markdown files:[output.latex]
latex = true
pdf = false
markdown = true
tectonic
is running into errors by manually running it and looking for ! LaTeX Error
:tectonic book/latex/MY_BOOK.tex
note: this is a BETA release; ask questions and report bugs at https://tectonic.newton.cx/
Running TeX ...
error: something bad happened inside TeX; its output follows:
===============================================================================
(MY_BOOK.tex
.
.
.
! LaTeX Error: Missing \begin{document}.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.260 \clearpage
No pages of output.
Transcript written on MY_BOOK.log.
===============================================================================
error: the TeX engine had an unrecoverable error
caused by: halted on potentially-recoverable error as specified
Aha! ! LaTeX Error: Missing \begin{document}.
In this example, mdbook-latex
failed to output the very important \begin{document}
line.
tectonic
(repeat this step until tectonic successfully compiles the PDF):ed book/latex/MY_BOOK.tex
tectonic book/latex/MY_BOOK.tex
Is it an elegant approach? No. Does it work? Sometimes. Is it a pain? Yes.
If you're feeling especially adventurous, create an issue or get in touch with me (liam@liambeckman.com) to help prevent the same errors in the future. I'm more than happy to work with you to get your document compiled!
: ^ )
Binary? | Target |
---|---|
❌ | |
❌ | |
❌ | |
❌ | |
❌ | |
❌ | |
✅ | x86_64-unknown-linux-gnu |