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

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.

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

Is it possible to load a CSV file with Pandoc and producing markdown file for each line?

I have a CSV file similar to below:
0,Bob's Business,50 some address,zip,telephone
1,Jill's Business,25 some address,zip,telephone
...
I would like to take this CSV file and have Pandoc produce a markdown file for each line in the CSV file. Each column accessible from a variable to be used in a markdown template file.
Is it possible to load a CSV file and produce markdown/html files in this way?
I can see three ways.
Use a static site generator
I would probably just use a tool like jekyll with its data files.
Alternative 1: Convert to YAML and use pandoc's template engine
Put something like this in mytemplate.md:
$for(data)$
$data$
$endfor$
Convert the csv to a JSON or YAML file
load that file with the --metadata-file option and use the template to render the output:
echo '' | pandoc --metadata-file data.yaml -t markdown --template mytemplate.md -o output.md
Alternative 2: Write a pandoc filter
There are many pandoc filters (like pandoc-placetable or pantable) that read csv and convert it to a pandoc table. But you want to convert it to a pandoc metadata format (which is usually parsed from the YAML frontmatter of markdown files). I guess you could adjust one of those pandoc filters to your purposes.

Using Pandoc to generate a PDF from multiple files - in order

I'm using the following command to convert 5 files (1 Markdown, 4 HTML) to PDF using Pandoc:
pandoc --toc --latex-engine=xelatex ${SOURCE_DIR}/* -o ${DST_DIR}/${DST}.pdf
It successfully does so, but in whatever order it wants. Is there any way to specify what order these files should be added to the singular PDF file?
It seems to do it alphabetically by file name, so that's a workaround.

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