pandoc not converting latex style citations correctly - latex

I want to use latex-style citations \cite{key} in my markdown so that I can create tex and pdf documents nicely using pandoc. However, when I cite something, it shows the keyword in brackets instead of the citation style, such as author name or citation number. In other words, I want it to show up in the PDF as "This is my citation [1]" but instead it is appearing as "This is my citation [mykey]". Also, my references list isn't showing up after I add my # References header. What is going on here?
Below is my sample command for producing this along with the sample files and my current incorrect output file (test.pdf).
pandoc test.md --biblatex --biblio test.bib --csl chicago-author-date.csl -o test.pdf
test.md
% My test pandoc-ument
I want to reference this: \cite{Gepasi1993}
# References
test.bib
#ARTICLE{Gepasi1993,
Author = {P. Mendes},
Journal = {Comput. Applic. Biosci.},
Pages = {563--571},
Title = {GEPASI: A software package for modelling the dynamics, steady states and control of biochemical and other systems.},
Volume = {9},
Year = {1993}
}
test.pdf
I want to reference this: [Gepasi1993]

The --biblatex option is not for writing biblatex directly in markdown.
What it does is convert native pandoc markdown citations, like
[#Gepasil1993, p. 5]
to biblatex citations in LaTeX output.
If you use pandoc markdown citations instead of the LaTeX ones, you'll
find that the citations work. Use this command:
pandoc test.md --biblio test.bib --csl chicago-author-date.csl -o test.pdf
with this input:
I want to reference this: [#Gepasi1993]
Pandoc's citation format is documented in the Pandoc User's Guide.
If you really want to use raw biblatex citations in your markdown input,
you can, but then you need to take care of the bibliography stuff
yourself. You'd do it this way:
pandoc test.md --parse-raw -t latex -s > test.tex
pdflatex test
biber test
pdflatex test
pdfltatex test

Related

How to remove parentheses around pandoc citations?

Here's how I do my citations in latex
\documentclass[11pt]{article}
\usepackage[
backend=biber, style=apa,
giveninits=true, uniquename=init,
citestyle=authoryear]{biblatex}
\bibliography{references.bib}
\begin{document}
... catastrophic population declines (\cite{McIntyre__2015}).
\end{document}
I'm using pandoc to convert this to docx or odt so I can get track changes from colleagues.
pandoc ./main.tex -f latex -t odt --bibliography=./references.bib --csl ../apa.csl -o output.odt
However... in the resulting document, pandoc automatically surrounds every \cite call with an extra set of parenthesis.
...catastrophic population declines ((McIntyre et al. 2015)).
I really like doing parentheses manually... is there a way for me to get pandoc to stop adding these extra citation parentheses?
I have the impression that this can be done with lua filters in pandoc... I was hoping someone could give me some pointers in the right direction on how to address this.
A Lua filter could be used to change the citation mode such that the parens are omitted:
function Cite(cite)
for _, c in ipairs(cite.citations) do
c.mode = pandoc.AuthorInText
end
return cite
end
Make sure that the filter runs before citeproc, i.e., it must occur first in the call to pandoc:
pandoc --lua-filter=modify-citations.lua --citeproc ...
The alternative would be to change \cite into \citet.
The answer from tarleb didn't solve the question, but it did lead me to the right documentation.
I now understand that pandoc relies on CSL for the actual formatting of citations, while lua filters can modify what kind of citation is used (author in text, vs author in parenthesis).
<citation et-al-min="3" et-al-use-first="1" disambiguate-add-year-suffix="true" disambiguate-add-names="true" disambiguate-add-givenname="true" collapse="year" givenname-disambiguation-rule="primary-name-with-initials">
<layout prefix="" suffix="" delimiter="; ">
</layout>
</citation>
In my CSL doc, I just removed the parentheses from the prefix and suffix attributes of the <citation> <layout> node.
Now only my manually placed parentheses appear in the compiled doc.
...catastrophic population declines (McIntyre et al., 2015).

citations in Pandoc footnotes rendered as numerals

I am getting a weird result when I convert markdown to PDF using Pandoc. This is for academic writing with footnotes generated via citeproc; a bibtex library generated by Zotero; and a Chicago csl file. Most of the footnotes are fine, but sometimes where I should see a book or article I just get a numeral.
When I write the following in Markdown
^[#melvilleMobyDick, 155]
I want a footnote that says
Herman Melville, Moby-Dick, p. 155
but I get
1, p. 155
The problem seems to be in the transition from markdown to LaTeX; the latter output is:
\footnote{1, 155}
My shell command is:
$ pandoc article.md -o article.latex --filter=pandoc-citeproc
And I am using this YAML header:
title: Essay
bibliography: My_Library.bib
csl: chicago_fullnote_ibid.csl
Many thanks for your help.
You're using chicago_fullnote_ibid.csl, which styles citations as footnotes. So just do [#melvilleMobyDick, 155] instead of ^[#melvilleMobyDick, 155] and it will turn into a footnote.

Latex: In Springer class svjour3, want references sorted in alphabetical order, in author-year format

I am writing a paper in LAtex and using Springer macro package (svjour3 class).
Requirement is: citations should be in the form of authoryear and sorted in alphabetical order.
My tex file looks like:
{
\documentclass[smallextended]{svjour3}
\usepackage{natbib}
\begin{document}
\title{abc}
\bibliographystyle{spbasic} % basic style, author-year citations
%\bibliographystyle{spmpsci} % mathematics and physical sciences
%\bibliographystyle{apa}
%bibliographystyle{spphys} % APS-like style for physics
%\bibliographystyle{plainnat}
\bibliography{review} % name your BibTeX data base
\end{document}
}
I have used all the possible options of bibliographystyle.
Also I have used various types of options in \usepackage[options]{natbib}
Tried deleting all the temporary files aux, logs and all others.
All entries in bib file have author and year and are separated by commas.
Still I am getting following errors:
{
Package natbib Error: Bibliography not compatible with author-year citations. ...mmand\NAT#force#numbers{}\NAT#force#numbers
}
You have to add:
\usepackage[numbers,sort&compress]{natbib}
and then add bibliography as:
\bibliographystyle{spbasic}
\bibliography{sample.bib}
You have to add:
\usepackage[numbers,sort&compress]{natbib}
and then add bibliography as:
\bibliographystyle{spbasic}
\bibliography{sample.bib}
That almost did it for me. I changed it to
\usepackage[sort&compress]{natbib}
in the preamble. Cited with
\citep{ReferenceXY}
and added my bib
\bibliographystyle{spbasic}
\bibliography{literature.bib}

Latex: Can I cite a reference after the bibliography

I'm having trouble with citations after the bibliography (in my appendices) using Bibtex/pdflatex. I'm using the 'puthesis' class - Purdue's class for our theses - which is built on top of the 'report' class. I'm using package 'natbib' with the option 'numbers'. An MWE isn't really feasible, but an example is shown below
\documentclass[english, ne, thesis]{puthesis}
\usepackage[numbers]{natbib}
...
\begin{document}
\chapter{Body Chapter}
Citations work fine here \cite{abc123}
\bibliographystyle{unsrt}
\bibliography{dissertation.bib}
\appendices
\chapter{Appendix Chapter}
Citations don't work here, I get an error that the
"Package natbib Warning: Citation `Crane1991' on page 145 undefined
on input line 4940." \cite{abc1234}
\end{document}
Some obvious things:
The citation does exist in the .bib file.
I'm running pdflatex; bibtex; pdflatex; pdflatex
I get the same error with and without the \appendices line.
Is there a way to cite references in latex after the bibliography?
This problem was caused by a non-UTF8/Latin9 encoded character in my .bib file. After ensuring the correct encoding with
recode utf8..l9 dissertation.bib
the file compiled as expected.

Convert LaTeX to MediaWiki syntax

I need to convert LaTeX into MediaWiki syntax. The formulas should stay the same, but I need to transform, for example \chapter{something} into = something =.
Although this can be obtained with a bit of sed, things get a little dirty with the itemize environment, so I was wondering if a better solution can be produced.
Anything that can be useful for this task?
Pandoc should be able to do it:
$ pandoc -f latex -t mediawiki << END
> \documentclass{paper}
> \begin{document}
> \section{Heading}
>
> Hello
>
> \subsection{Sub-heading}
>
> \textbf{World}!
> \end{document}
> END
== Heading ==
Hello
=== Sub-heading ===
'''World'''!
pandoc can get your file converted between several different mark-up languages pretty easily, including mediawiki
I found this: plasTeX. With a bit of hacking probably I can produce a renderer for the mediawiki syntax
Yes Pandoc would be the easiest to do that.
pandoc -f latex -t mediawiki --metadata link-citations --bibliography=bibl.bib --csl=cslstyle.csl test.tex -o test.wiki
--metadata link-citations creates hyperlinks with your in-text citations and the bibliography. You can delete this part if not needed.
bibl.bib is the file of the bibliography you used
cslstyle.csl is the style of citation you want. There are lots of choices that can be downloaded from editor.citationstyles.org
test.tex is the file you want to convert from
test.wiki is the output file you want
all the files should be in the same folder otherwise locations should be specified

Resources