Open mkoohafkan opened 7 years ago
It's not that simple. There are many differences between natbib and biblatex besides which package to use and which citation commands to use. (E.g. what command to use for the bibliography, and where this command goes.) Note also that with biblatex a variety of commands is used, not just two.
Why not just use pandoc-citeproc and an appropriate csl file that fits your journal's standards?
Well, mainly because the journal expects a .tex file for submission that uses their template... so they expect the \cite
commands rather than plain text citations. Some publishers have the same template but a \journal{}
to format the document different according to where it ends up getting published, including bibliography styles. The use case I'm talking about is md --> tex, not md --> pdf.
What about just adding support for base LaTeX \cite
commands? Flexible support for arbitrary citation packages may be unrealistic, but support for basic LaTeX citation commands is probably worthwhile.
Learning more about filters...that's probably the way to go for supporting arbitrary LaTeX citation packages. User could select the citation package closest to the one they actually want to use (e.g. natbib or biblatex) and then use a filter to reformat citations into the actual style of the intended package. I still think it would be valuable to support base LaTeX citations in this case to provide maximum flexibility.
Using pandoc-citeproc you can produce a tex file, but the formatting might not be exactly as the journal expects, if they use bibtex.
As for supporting base LaTeX citations: I can't recall the details of \cite
, but is there a way to distinguish author-in-text and normal citations? Is there a way to add prefixes and suffixes, including locators, to the citations?
Prefixes, suffixes and locators are supported with []
as with natbib. It does not distinguish between parenthetical and in-text citations (just one command: \cite
), but neither does natbib when using numeric citations (\citet
won't be correctly displayed).
Sorry for reviving an old issue, let me know if a separate issue would be best to track this. I just happen to have run into this today while trying to set up a template to use with markdown -> LaTeX. My case is similar to #2392, where the conference template still uses BiBTeX's \cite
(see here). I've resorted to using Ctrl + F and substituting \autocite
with \cite
, but it would be great if this was instead customizable through the command line or YAML front matter.
I'm open to adding a --bibtex
option (parallel to --biblatex
, --natbib
).
But how would it work? We need to support three citation styles, SuppressAuthor, AuthorInText, and NormalCitation, as well as prefixes and suffixes. Can you confirm that standard bibtex \cite
allows optional prefixes and suffixes with square brackets? Would we simply not distinguish between the three citation styles?
I have to say that I don't know enough about the internals of BiBTeX/pandoc to know if there's a way to do that. In my field, that's usually not needed (since my citations are always numeric), but based on this the only thing that is possible is to specify details for the locator using \cite[p.~215]{citation01}
.
After an extremely quick search on the BiBTeX docs there might be two options (keep in mind that I don't know how hard/problematic this is to implement):
--bibtex
could discard prefixes and suffixes, and use only NormalCitation. If you need support for the others, then using --biblatex
or --natbib
makes more sense--bibtex
could only replace \citep
with \cite
when it makes sense, and use the behaviour of --natbib
for the rest, based on this suggestion from the BiBTeX FAQ (this is just a tiny excerpt, but in general there are many places where natbib is recommended) :
Use Patrick Daly’s natbib.sty (or Peter Williams’ harvard.sty, etc.) for author-date references. If you use an author-date style of citations, your choice of style will probably be dictated by the publications you write for. If there is an existing bibstyle that exactly suits your needs, use it in conjunction with the most recent author-date package(s) that support it.
Hi! This requirement fits my use case too - many journals require a tex
file and that too with normal \cite
commands. Has there been any progress on this?
Also, are there any filters available that could serve the purpose?
You could just add this to the top of your file (untested):
\def\citep\cite
You could just add this to the top of your file (untested):
\def\citep\cite
This didn't work for my use case: trying to get Pandoc output to work with an up-to-date Tufte-latex (using BibLaTeX with this update: https://github.com/Tufte-LaTeX/tufte-latex/pull/176). Tufte-latex looks for \cite
to convert to margin placements, and so \autocite
fails. However in this case, a solution is this option in the preamble:
\ExecuteBibliographyOptions{autocite=footnote}
This puts \autocite
citations into the margin for Tufte-latex...
Would love to have a built-in option for the native \cite
command. I've managed to write a Lua filter that works decently, but it's not a very robust solution due to all the issues that have already been mentioned in this thread.
Pandoc currently supports
natbib
andbiblatex
for LaTeX output, but no other citation methods, including the default\cite
command. It would be great to see Pandoc provide flexible support for citation packages, such as the cite package. This functionality would be useful for e.g. generating tex files for journals that restrict use ofnatbib
orbiblatex
.It may be possible to use pandoc variables to support virtually any citation package. My understanding is that Pandoc markdown supports two types of citations: parenthetical
[@citation]
and textual@citation
(difference is the[]
). Perhaps Pandoc could use two variables for LaTeX templates, e.g.$citeparen$
and$citetext$
, which allow users to specify what LaTeX commands to use. So current functionality fornatbib
in the YAML header would look like:and
biblatex
would (I think?) look like:Pandoc would use those variables to populate the .tex file. A third variable
$citepackageoptions$
could also be added to allow users to specify options in[]
, e.g.\usepackage[$citepackageoptions$]{$citation-package$}
.It would of course be up to the user to correctly specify which commands to use. A possible complication arises with citations like
[e.g. @citation; see also @another]
but again, it's up to the user if they want to use a package with more restrictive functionality than what pandoc provides (then again, pandoc seems to do fine with ignoring the extra text when I use a superscript-based bibliography format withnatbib
, so maybe not a difficult issue after all).