Pandoc citeproc bibliography entries sorting follows the order of entries in bib file - pandoc

When I convert the markdown file to pdf the order of references in the bibliography is the same as in the .bib file. As a result, the references in the text appear in the wrong order. As a result, I can have in the text sentences like ... reported in [2] after [1] ... while I would like the references to be sorted in the bibliography as they appear in the text, as it would be using unsrt.bib.
The question is: how do I achieve sorting of entries in the bibliography section in order of their appearance in the text?
MWE, compiled using pandoc -C -f markdown testing.md -o testing.pdf
testing.md:
---
bibliography: test.bib
csl: aps.csl
---
The first reference [#second_title_2015]
The second reference [#author_title_2014]
test.bib
#article{author_title_2014,
title = {The title},
author = {Author, A. B. and Other, C. D.},
year = {2014},
}
#article{second_title_2015,
title = {The other title},
author = {Second, T. A. and First, F. G.},
year = {2015},
}
The output
Changing the order of #article's in test.bib results in the desired output: The first reference [1] the second reference [2].
I am using the aps.csl taken from zotero style repository:
https://www.zotero.org/styles/american-physics-society?source=1
cause of the problem:
I had an outdated pandoc installed by conda (pandoc is a prerequisite for some important packages I needed), and this version took precedence over the default arch installation because of conda's executables dir being in $PATH before /bin/.

Did you use outdated pandoc? I tested your code with pandoc 2.13, which produced the correct output. You can get the latest release here.
pandoc --version
pandoc 2.13
Compiled with pandoc-types 1.22, texmath 0.12.2, skylighting 0.10.5,
citeproc 0.3.0.9, ipynb 0.1.0.1
pandoc -C -f markdown testing.md -o testing.pdf

Related

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 does not produce bibliography when biblio file is in YAML-metadata only

I assume that inserting a reference to a BibTex bibliography in a YAML-metadata is sufficient for the references to be produced. This is like pandoc does not print references when .bib file is in YAML, which was perhaps misunderstood and which has no accepted answer yet.
I have the example input file:
---
title: Ontologies of what?
author: auf
date: 2010-07-29
keywords: homepage
abstract: |
What are the objects ontologists talk about.
Inconsistencies become visible if one models real objects (cats) and children playthings.
bibliography: "BibTexExample.bib"
---
An example post. With a reference to [#Frank2010a] and more.
## References
I invoke the conversion to latex with :
pandoc -f markdown -t pdf postWithReference.markdown -s --verbose -o postWR.pdf -w latex
The pdf is produced, but it contains no references and the text is rendered as With a reference to [#Frank2010a] and more. demonstrating that the reference file was not used. The title and author is inserted in the pdf, thus the YAML-metadata is read. If I add the reference file on the command line, the output is correctly produce with the reference list.
What am I doing wrong? I want to avoid specifying the bibliography file (as duplication, DRY) on the command line. Is there a general switch to demand bibliography processing and leaving the selection of the bibliography file to the document YAML-metada?
In the more recent version requires --citeproc instead of --filter=pandoc-citeproc
Theo bibliography is inserted by the pandoc-citeproc filter. It will be run automatically when biblioraphy is set via the command lines, but has to be run manually in cases such as yours. Addind --filter=pandoc-citeproc will make it work as expected.

How can I specify pandoc's markdown extensions using a YAML block?

Background
Pandoc's markdown lets you specify extensions for how you would like your markdown to be handled:
Markdown syntax extensions can be individually enabled or disabled by appending +EXTENSION or -EXTENSION to the format name. So, for example, markdown_strict+footnotes+definition_lists is strict markdown with footnotes and definition lists enabled, and markdown-pipe_tables+hard_line_breaks is pandoc’s markdown without pipe tables and with hard line breaks.
My specific question
For a given pandoc conversion where, say, I use grid tables in my source:
pandoc myReport.md --from markdown+pipe_tables --to latex -o myReport.pdf
How can I write a pandoc YAML block to accomplish the same thing (specifying that my source contains grid tables?)
A generalized form of my question
How can I turn extensions on and off using pandoc YAML?
Stack Overflow Questions that I don't think completely answer my question
Can I set command line arguments using the YAML metadata - This one deals with how to specify output options, but I'm trying to tell pandoc about the structure of my input
What can I control with YAML header options in pandoc? - Answerers mention pandoc's templates, but neither the latex output template nor the markdown template indicate any sort of option for grid_tables. So, it's not clear to me from these answers how knowing about the templates will help me figure out how to structure my YAML.
There may also not be a way to do this
It's always possible that pandoc isn't designed to let you specify those extensions in the YAML. Although, I'm hoping it is.
You can use Markdown Variants to do this in an Rmarkdown document. Essentially, you enter your extensions into a variant option in the YAML header block at the start of the your .Rmd file.
For example, to use grid tables, you have something like this in your YAML header block:
---
title: "Habits"
author: John Doe
date: March 22, 2005
output: md_document
variant: markdown+grid_tables
---
Then you can compile to a PDF directly in pandoc by typing in your command line something like:
pandoc yourfile.md -o yourfile.pdf
For more information on markdown variants in RStudio: http://rmarkdown.rstudio.com/markdown_document_format.html#markdown_variants
For more information on Pandoc extensions in markdown/Rmarkdown in RStudio:
http://rmarkdown.rstudio.com/authoring_pandoc_markdown.html#pandoc_markdown
You can specify pandoc markdown extension in the yaml header using md_extension argument included in each output format.
---
title: "Your title"
output:
pdf_document:
md_extensions: +grid_tables
---
This will activate the extension. See Rmarkdown Definitive Guide for details.
Outside Rmarkdown scope, you can use Pandocomatic to it, or Paru for Ruby.
---
title: My first pandocomatic-converted document
pandocomatic_:
pandoc:
from: markdown+footnotes
to: html
...
As Merchako noted, the accepted answer is specific to rmarkdown. In, for instance, Atom md_extensions: does not work.
A more general approach would be to put the extensions in the command line options. This example works fine:
----
title: "Word document with emojis"
author: me
date: June 9, 2021
output:
word_document:
pandoc_args: ["--standalone", "--from=markdown+emoji"]
----
For people stumbling across this in or after 2021, this can be done without Rmarkdown. You can specify a YAML "defaults" file, which basically includes anything you could want to configure.
In order to do what OP wanted, all you'd need to do is
from: markdown+pipe_tables
in the defaults file, then pass it when you compile.
You can also specify the input and output files, so you can end up with the very minimal command
pandoc --defaults=defaults.yaml
and have it handle the rest for you. See https://pandoc.org/MANUAL.html#extensions for more.

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

Doxygen latex fine-tuning?

I've got 2 questions concerning the latex output of doxygen:
How can one organize the related pages (those created by \page) ? (They seem to be organized according to the title of the page)
How to specify which latex stylesheet to use ? (i've found nothing in the Doxyfile)
I would like to get rid of the paragraph numbers for the class members.
thanks
For LaTeX output, you can generate the first part of refman.tex (see LATEX_HEADER) and the style sheet included by that header (normally doxygen.sty), using:
doxygen -w latex header.tex doxygen.sty
In current doxygen (I use 1.8.11), you can modify the footer as well, the command by #synthesizerpatel won't work anymore. Now you have to say
doxygen -w latex header.tex footer.tex doxygen.sty
You can use the modified files by setting these variables in your Doxyfile
LATEX_HEADER = header.tex
LATEX_FOOTER = footer.tex

Resources