Sphinx: Bibtex bibliography with EPUB generator - python-sphinx

I'm trying to utilize Sphinx to build three fold output - HTML, Latex, and EPUB. The bibliography is standard bibtex. With HTML and Latex it works perfectly well. However, EPUB generator:
sphinx-build -b epub -D extensions=sphinx.ext.imgmath -D imgmath_embed=True . epub/
produces the following errors:
WARNING: unknown directive or role name: cite:t
3-poplavni.rst:170: ERROR: Unknown interpreted text role "cite:t".
literatura.rst:7: ERROR: Unknown directive type "bibliography".
.. bibliography::
Any advice?
EPUB generator should work well with Bibtex as Latex and HTML generators do.

Perfect! As you suggested:
sphinx-build -b epub -D extensions=sphinx.ext.imgmath,sphinxcontrib.bibtex -D imgmath_embed=True . epub/
works like a charm.

Related

Pandoc .docx to .md with math and images

I am trying to export .docx file to a .md file with math and images. However, only the image is present on the new file, but not the math in mathjax. Any idea how to solve this?
The code I use is: pandoc --extract-media=.-s file.docx -t markdown -o file.md

How to include a latex document into a markdown using yaml metadata `include-after-body`

I want include a latex document into a markdown .md file using the YAML metadata. I have two files in a directory:
markdown.md
---
title: test fuer pdf eingeschlossen
author: AUF
keywords: test
abstract: Versuch
publish: True
include-after-body: testlatex.tex
---
A simple exampe for a test.
and testlatex.tex
some text without sense
\begin{itemize}
\tightlist
\item
firstly, a fundamental human need is;
\item
secondly, a cost-effective technical mean,
\end{itemize}
I can include the testlatex.tex file into the body of the markdown.md on the commandline with
pandoc --pdf-engine=lualatex --toc -o test.pdf markdown.md --include-after-body=testlatex.tex
but the equivalent value put into the YAML metadata seems not to have any effect (author and title are however used). I thought that the value included on the command line or in the YAML metadata would be equivalent. I checked in the pandoc latex template and see there an include for the include-after but I also wonder where the filename is converted to its content.
If I put
include-after: testlatex.tex
in the YAML metadata the name of the file is printed in the output, but the file content is not used!
Thank you for your help!

pandoc command param --epub-cover-image generate fail

I wanna generate docx from markdown files ,and insert into the conver picture, From pandoc metada , I can use --epub-cover-image.
My directory :
then command:
pandoc -s a.md b.md c.md -o example.docx --epub-cover-image cover.png
It generate example.docx file, but the cover.png does not insert into the docx file ?
Quoting the pandoc manual section on --epub-cover-image:
Use the specified image as the EPUB cover.
Since you are not generating a EPUB ebook but a docx word file, the option has simply no effect.

Pandoc: use variables in custom latex preamble

I have the file test.md which contains:
---
footertext: some text for the footer
headertext: this is in the header
---
here is the text body.
And the file format.tex which contains:
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhead[L]{$headertext$}
\fancyfoot[L]{$footertext$}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\setlength{\headsep}{0.25in}
I run the command:
pandoc -H format.tex test.md -o test.pdf
You can see what I want to do. I am trying to get the text "this is in the header" to show up in the header, but it does not, it only shows the string "headertext" (same problem for footer).
What am I doing wrong?
Edit: OK, I think I understand. Apparently variables are only available in templates, not in included begin or end code blocks (like I am using), or in the md itself. So new question: Why is this? It is unintuitive, inconvenient, and poorly documented.
You can easily modify a pandoc template. Access the default template with
pandoc -D latex > new_template.latex
Paste the content of your format.tex in the preamble. You should use $if$ to check if the variable exists before using it if you want to use this template for more than one document :
\usepackage{fancyhdr}
\pagestyle{fancy}
$if(headertext)$\fancyhead[L]{$headertext$}$endif$
$if(footertext)$\fancyfoot[L]{$footertext$}$endif$
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\setlength{\headsep}{0.25in}
Then compile with :
pandoc test.md -o test.pdf --template=new_template.latex

How to split Pandoc template files into sub files

I would like to be able to split Pandoc template files into sub files using the \input{path-to-file} in the template file. When I use the \input command, I get the following error message when running pandoc -o output.pdf --template=default.latex --latex-engine=lualatex:
! LaTeX Error: Missing \begin{document}.
How do I properly split pandoc template files?
I think this is not possible to achieve with Pandoc. I choose to switch to Panzer, a project which combines Pandoc with styles.

Resources