Wandmalfarbe / pandoc-latex-template

A pandoc LaTeX template to convert markdown files to PDF or LaTeX.
BSD 3-Clause "New" or "Revised" License
6.12k stars 959 forks source link

CSL Citations Rendering but not in expected CSL format #313

Open williamcroberts opened 1 year ago

williamcroberts commented 1 year ago

Hello,

I am using pandoc version 2.19.2 I have enabled option --citeproc and filter citations, see the command example below.

My issue is that references always render as [@foo] no matter what CSL is used. I am expecting that the reference be numerical in nature, something like [1]. However, The generated references section is in the expected format. I am using CSL transactions-on-computer-systems.csl as found here:

Does anyone know why it's not working or things to try and trouble shoot it?

My YAML meta data block is as follows:

---
title: "My Spec"
type: SPECIFICATION
status: DRAFT
bibliography: citations.yaml
csl: transactions-on-computer-systems.csl
...

foo bar example: [@fenner].

# References

With the following citations.yaml file:

references:
  - id: fenner
    title: One-click science marketing
    author:
      - family: Fenner
        given: Martin
    container-title: Nature Materials
    volume: 11
    URL: "https://dx.doi.org/10.1038/nmat3283"
    DOI: 10.1038/nmat3283
    issue: 4
    publisher: Nature Publishing Group
    page: 261-263
    type: article-journal
    issued:
      year: 2012
      month: 3

Command Example:

    pandoc \
        --citeproc \
        --embed-resources \
        --standalone \
        --template=eisvogel.latex \
        --filter=mermaid-filter \
        --filter=pandoc-crossref \
        --resource-path=.:/resources \
        --data-dir=/resources \
        --top-level-division=section \
        --variable=block-headings \
        --variable=numbersections \
        --variable=table-use-row-colors \
        --metadata=date-english:"${DATE_ENGLISH}" \
        --metadata=year:"${YEAR}" \
        --metadata=titlepage:true \
        --metadata=titlepage-background:/resources/img/cover.png \
        --metadata=logo:/resources/img/my.png \
        --metadata=titlepage-rule-height:0 \
        --metadata=colorlinks:true \
        --metadata=contact:admin@trustedcomputinggroup.org \
        --from=markdown+implicit_figures+table_captions+citations \
        ${extra_pandoc_options} \
        --to=pdf \
        "${build_dir}/${input_file}.3" \
        --output="${pdf_output}"

Pandoc Version Info

pandoc --version
pandoc 2.19.2
Compiled with pandoc-types 1.22.2.1, texmath 0.12.5.2, skylighting 0.13,
citeproc 0.8.0.1, ipynb 0.2, hslua 2.1.0
Scripting engine: Lua 5.3
User data directory: /home/user/.local/share/pando
cagix commented 1 year ago

what happens if you append --biblatex to your pandoc options?

williamcroberts commented 1 year ago

what happens if you append --biblatex to your pandoc options?

Now I get [foo] for the reference, but no References section appended to the output.

nicolaipre commented 7 months ago

I found a solution from this post: https://github.com/Wandmalfarbe/pandoc-latex-template/issues/151#issuecomment-687640102

In my case I wanted IEEE-style citations so I downloaded this file: https://github.com/jgm/pandoc-citeproc/blob/master/tests/ieee.csl

I then added link-citations: true to my YAML. My full make command looks like this:

$ REPORT_DIR="./report/" docker run --rm --volume "`pwd`:/data" --user `id -u`:`id -g` pandoc/extra `find ${REPORT_DIR} -name "*.md" | sort` -o ${REPORT_OUTPUT} \
        --template ./templates/eisvogel.tex \
        --table-of-contents \
        --number-sections \
        --listings \
        --highlight-style tango \
        --from markdown+yaml_metadata_block+raw_html+implicit_figures+table_captions+citations \
        --toc-depth 3 \
        --bibliography=references.bib \
        --citeproc \
        --csl ieee.csl
        # --biblatex #removes References page...

With this combination you get linked references with the [1] tags you are looking for:

Test [@knuthwebsite]
@misc{knuthwebsite,
    author    = "Donald Knuth",
    title     = "Knuth: Computers and Typesetting",
    url       = "http://www-cs-faculty.stanford.edu/\~{}uno/abcde.html"
}

image

image

Although the URLs are not visible in the References-list the URL is embedded in the reference title which makes it clickable and hoverable.

Edit: If you use this CSL instead you get URLs in the References output as expected: https://raw.githubusercontent.com/citation-style-language/styles/master/ieee-with-url.csl

rpoisel commented 4 months ago

I found a solution from this post: #151 (comment)

Thanks, that worked for me too. In case you get an ! LaTeX Error: Something's wrong--perhaps a missing \item. error, I had to use an older version of the CSLReferences environment. Here is a diff that works for me now: https://github.com/Wandmalfarbe/pandoc-latex-template/commit/b8fa1c966bc58e3c38157e3b26aeb7a669aac390.

Maybe it is of help to someone else too. I guess there is some version mismatch (pandoc, eisvogel template, etc.).

EDIT: Better make sure your pandoc version matches the version required by this template instead of hacking the template. At the time of writing this comment, I had to manually update to pandoc 3.2 which was not included in Debian's official package sources yet.

cryptax commented 2 months ago

@rpoisel I encountered the ! LaTeX Error: Something's wrong--perhaps a missing \item. error. Thanks for the diff fix, it worked for me :)

asaurabh-iitk commented 1 month ago

Wow! Extremely helpful thread. I'm lucky that I came across this. Perhaps these steps could be part of the installation/usage guidelines.

--biblatex suggested earlier in the thread does not help when creating pdf output from md.