jgm / pandoc

Universal markup converter
https://pandoc.org
Other
34.72k stars 3.39k forks source link

Support `\fullcite`, `\citeauthor`, `\citetitle` biblatex commands #2335

Open alfureu opened 9 years ago

alfureu commented 9 years ago

I would like to report the issue that basic (and critical) biblatex commands are not converted from TeX > docx with pandoc. These commands are:

1. Creating a MWE with the following code in file pandoc.tex:

\documentclass{article}
\usepackage{biblatex}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@article{abc,
author = {John Doe},
year = {1970},
title = {Article Title},
journaltitle = {Journal Name},
volume = {1},
number = {2},
pages = {13--17},
}
\end{filecontents}
\addbibresource{\jobname.bib}

\begin{document}
abcdefgh
ijklmnop
xyvwz

cite: \cite[Cf.][13--17]{abc}
Cite: \Cite[Cf.][13--17]{abc}
parencite: \parencite[Cf.][13--17]{abc}
Parencite: \Parencite[Cf.][13--17]{abc}
footcite: \footcite[Cf.][13--17]{abc}
footcitetext: \footcitetext[Cf.][13--17]{abc}
textcite: \textcite[Cf.][13--17]{abc}
Textcite: \Textcite[Cf.][13--17]{abc}
smartcite: \smartcite[Cf.][13--17]{abc}
Smartcite: \Smartcite[Cf.][13--17]{abc}
fullcite: \fullcite[Cf.][13--17]{abc}
footfullcite: \footfullcite[Cf.][13--17]{abc}
citeauthor: \citeauthor[Cf.][13--17]{abc}
Citeauthor: \Citeauthor[Cf.][13--17]{abc}
citetitle: \citetitle[Cf.][13--17]{abc}
citeyear: \citeyear[Cf.][13--17]{abc} 

\printbibliography
\end{document}

The commands are from the official biblatex manual http://mirrors.ctan.org/macros/latex/contrib/biblatex/doc/biblatex.pdf

2. Typed in command line:

pdflatex pandoc.tex biber pandoc pdflatex pandoc.tex pandoc --bibliography=pandoc.bib -o pandoc.docx pandoc.tex

3. List of non-functional commands

Using pandoc 1.15.0.6 the following commands are not working (highlighted in bold):

Could you, please, provide functionality for the missing biblatex commands? IMHO \citetitle, \footcite and \fullcite are pretty critical.

EDIT: Attached screenshots

4. Result in LaTeX

latex

5. Result from pandoc in DOCX

pandoc

mpickering commented 9 years ago

These are very easy to add in general. You can see an example of how cite is implemented here.

alfureu commented 9 years ago

Thanks @mpickering, though have no idea how to make a patch for this. Anybody can help with this?

alfureu commented 9 years ago

Looked into the link you provided. While few of the citation formats are simply missing (i.e. they are easy to add), I could not figure out how to introduce the \citetitle command. Could somebody here have a look into this please?

jgm commented 9 years ago

If \citetitle prints the title of the citation, then there's no way to do this with current pandoc-citeproc architecture.

+++ DOFfactory [Jul 31 15 05:56 ]:

Looked into the link you provided. While few of the citation formats are simply missing (i.e. they are easy to add), I could not figure out how to introduce the \citetitle command. Could somebody here have a look into this please?

— Reply to this email directly or [1]view it on GitHub.

References

  1. https://github.com/jgm/pandoc/issues/2335#issuecomment-126682366
alfureu commented 9 years ago

Why not to add it? We have a bib(la)tex file, all the data are there ... Just as one calls the author, one should be able to call the title from the same file.

jgm commented 9 years ago

It would be a large change, including changes to the underlying pandoc types. (We'd need to modify CitationMode, which now includes AuthorInText, SuppressAuthor, and NormalCitation to include something like TitleOnly. We'd need to think about whether there was some natural markdownish syntax for this. And we'd need to modify pandoc-citeproc to handle the additional CitationMode.)

+++ DOFfactory [Aug 06 15 13:11 ]:

Why not to add it? We have a bib(la)tex file, all the data are there ... Just as one calls the author, one should be able to call the title from the same file.

— Reply to this email directly or [1]view it on GitHub.

References

  1. https://github.com/jgm/pandoc/issues/2335#issuecomment-128491850
jgm commented 9 years ago

@DOFfactory, it would help if you were more specific about what is "not working" in your list, and how.

\footcite and footcitetext do get parsed as citations in notes.

As I've indicated, \citeauthor and \citetitle can't be done without signficant changes in pandoc and pandoc-citeproc architecture. (Though we could parse them as regular citations, which would be better than doing nothing.) \fullcite is probably in the same boat, though I'm not really sure what it's supposed to do. \Cite should be easy enough to add.

alfureu commented 9 years ago

Hi @jgm, I attached the screenshots. You are right, \footcite and \footcitetext does get parsed, my bad. \Cite should be also easily implemented.

What this ticket initially supposed to point out was that biblatex is getting to be used widely in the LaTeX-using community. It would be great if biblatex commands would be parsed straightforward in pandoc because, I believe, a big group this community (mostly from academia) will then use pandoc and markdown for conversion/writing.

jgm commented 9 years ago

I've implemented \Cite. Getting \fullcite, \citeauthor, and \citetitle would require major architectural changes in pandoc and pandoc-citeproc.

alfureu commented 9 years ago

Many thanks! Since I do not have an expertise to re-write your pandoc-citeproc code either, I will leave this issue open as a reminder and future reference for others. It would be great to have fully implemented biblatex for the reasons mentioned above. Thanks again.

njbart commented 9 years ago

It would be nice to have an equivalent of \fullcite in markdown, though.

In a syllabus, e.g., you might want to use an author-date style in general, but still occasionally give the full details of a recommended textbook, or of the reading for a particular date in the text itself, like:

Blah blah blah. The recommended textbook for this course is:

Knox, Paul L., and Steven Pinch. 2006. Urban Social Geography: An Introduction. 5th ed. Harlow: Pearson/Prentice Hall.

Blah blah blah.

Since this would just have to copy the entry that is being generated anyway for the list of references, this might not be too difficult.

As to syntax, we’d have to invent something; maybe a plus sign (+) before the @ would do, like [+@knox], or just +@knox.

Thoughts?

dbosk commented 5 years ago

Since @ref gives the author's name, [@ref] the actual reference, then maybe "@ref" is a good syntax for the title (i.e. \citetitle)?

sleepymurph commented 4 years ago

For others following this issue, I have found a work-around that might suit your purposes (e.g. writing syllabi like @dbosk). You can trick Pandoc and CSL into rendering full citations in-text (ala \fullcite) throughout the whole document by doing the following:

  1. Choose a CSL file that writes full citations in footnotes.
  2. Change class="note" to class="in-text" in the XML's root <style> element.

CSL makes such a strong distinction between in-text and (foot)note styles that apparently changing that class attribute will change one to the other (see cs:style in the CSL spec). Unfortunately it's all or nothing, though.

The Zotero CSL repository has several full-note styles. I've tried this with Chicago 17th Edition (full note) and Chicago 17th Edition (full note, short title subsequent), and it seems to work just fine.

I generated the following using the Chicago short-title-subsequent CSL.

Input:

> Lorem ipsum let's say I'm in the middle of my text and I want a full citation to an IoT paper:
>
> @Bittencourt2018IotFogAndCloud
>
> Now another one:
>
> @AbdelBaky20178ComputingInTheContinuum
>
> Now back to the first again for a short title:
>
> @Bittencourt2018IotFogAndCloud

Command (the inline sed command makes the class change on the fly as the CSL file is fed into Pandoc):

pandoc --filter pandoc-citeproc \
    --bibliography syllabus.bib \
    --csl <(sed '2s/class="note"/class="in-text"/' \
            chicago-fullnote-bibliography-short-title-subsequent.csl) \
    -M suppress-bibliography=true \
   demo.md --to gfm -o demo-out.md

Output:

Lorem ipsum I'm in the middle of a syllabus table...

Luiz Bittencourt et al. "The Internet of Things, Fog and Cloud Continuum: Integration and Challenges," Internet of Things 3-4 (2018): 134--55, https://doi.org/https://doi.org/10.1016/j.iot.2018.09.005.

M. AbdelBaky et al. "Computing in the Continuum: Combining Pervasive Devices and Services to Support Data-Driven Applications," in 2017 Ieee 37th International Conference on Distributed Computing Systems (Icdcs), 2017, 1815--24, https://doi.org/10.1109/ICDCS.2017.323.

Here is a repeated citation with the short-title form:

Bittencourt et al. "The Internet of Things, Fog and Cloud Continuum."

This isn't a full solution because it's so all-or-nothing and can't be chosen on a per-citation basis, but it's useful for me and I thought I'd share.

dbosk commented 4 years ago

Very useful indeed, thanks for sharing!

rudolf-adamkovic commented 4 years ago

Note: \notecite is critical for the APA Style. For instance, \notecite[5]{something} should produce “p. 5” and \pnotecite[5]{something} should produce “(p. 5)”.

P.S. Further, \textquote/\blockquote and \textcquote/\blockcquote from csquotes would be awesome. (They tie together quoting and citations.)

ndgnuh commented 3 years ago

When this support get added, will it work in markdown/html conversion too?

bcdavasconcelos commented 1 year ago

Perhaps this could be done simply by using a Lua filter to look up the bibliography data and replace \citetitle and \citeauthor occurrences with their appropriate values. I am still a beginner with Lua, but I might give it a try in the holidays.

jgm commented 1 year ago

Perhaps this could be done simply by using a Lua filter to look up the bibliography data and replace \citetitle and \citeauthor occurrences with their appropriate values. I am still a beginner with Lua, but I might give it a try in the holidays.

That sounds feasible to me.

JonathanMair commented 1 year ago

Hi - just to say +1 for \fullcite!

bcdavasconcelos commented 1 year ago

Perhaps this could be done simply by using a Lua filter to look up the bibliography data and replace \citetitle and \citeauthor occurrences with their appropriate values. I am still a beginner with Lua, but I might give it a try in the holidays.

That sounds feasible to me.

@jgm, can you think of any existing script that seems similar or close enough to this that I could use as a blueprint or starting point?

EDIT: I have some experience editing and adapting Lua scripts (that seem close enough to ruby, which I use more often), but not starting them from scratch and, so far, I couldn't find anything close enough that I successfully managed to adapt.

bcdavasconcelos commented 1 year ago

To anyone interested in citeauthor, citetitle, citefield and so on (not fullcite), see: https://github.com/bcdavasconcelos/citefield

sjkiss commented 2 months ago

+1 for \fullcite for me. It's a bit debilitating. I use LaTeX to prepare syllabi and then have to pandoc them over to Word for accessibility issues.