lierdakil / pandoc-crossref

Pandoc filter for cross-references
https://lierdakil.github.io/pandoc-crossref/
GNU General Public License v2.0
911 stars 72 forks source link

Figure labels #19

Closed HJAllen closed 9 years ago

HJAllen commented 9 years ago

I have updated to the latest version but still get figure labels as

fig 1.

I have added to the yaml header

figureTitle: 'Figure'
tableTitle: 'Table'

using RStudio-knitr-pandoc writing output to word .docx

Thanks,

Joel

lierdakil commented 9 years ago

Title is for captions. Try figurePrefix.

lierdakil commented 9 years ago

Or maybe I misunderstood your problem.

lierdakil commented 9 years ago

Not sure on RStudio-knitr, and how it handles things, but in order for pandoc-crossref to number your figures, you have to attach identifier to them, i.e. this ![Figure](image.png) would be "just a figure", without number, while this ![Figure](image.png){#fig:fig1} would be a numbered figure.

You can omit label, i.e. just have ![Figure](image.png){#fig:}, but that would mess with \listoffigures, since it's build based on figure labels (which I should probably fix somewhere down the line)

HJAllen commented 9 years ago

Thanks for the quick response. To be clear, I want the reference in the text for the figure to be 'Figure x.' The figure is an image inserted as

![Organization Chart](HABOrgChart.jpg) {#fig:orgStruct}

and the reference in the text is [@fig:orgStruct]

the figures are numbered properly.

HJAllen commented 9 years ago

The YAML header is:

---
title: "Title"
output: 
  word_document:
    pandoc_args:
    - --filter
    - pandoc-crossref
    - --filter
    - pandoc-word-newpage
    fig_width: 5
    fig_height: 5
    reference_docx: style_v1.docx
  pdf_document:
    includes:
      in_header: header.tex
    pandoc_args:
    - --filter
    - pandoc-crossref
  html_document:
    keep_md: yes
    pandoc_args:
    - --filter
    - pandoc-crossref
    - --filter
    - pandoc-word-newpage
csl: /workspace/cyanoHAB/environmental-toxicology-and-chemistry.csl
bibliography: HAB.bib
figurePrefix: 'Figure'
tablePrefix: 'Table'
---
lierdakil commented 9 years ago

I'm not entirely sure if knitr passes metadata to pandoc unmangled, but that should work from where I stand. Could you check with just pandoc, e.g. pandoc -s -t markdown -F pandoc-crossref input.md?

HJAllen commented 9 years ago

I generated a markdown file from RStudio with

render(input="./doc_v3.Rmd",
       output_format="md_document",
       output_file="./doc_v3.md")

then ran

pandoc -s -t markdown -F pandoc-crossref doc_v3.md

and where i expected a figure reference

organizational structure is presented in [<span class="citeproc-no-output">**???**</span>].
HJAllen commented 9 years ago

the header of output shows figPrefix as 'fig.'

---
chapDelim: '.'
crossrefYaml: 'pandoc-crossref.yaml'
eqnPrefix:
- 'eq.'
- 'eqns.'
figPrefix:
- 'fig.'
- 'figs.'
figureTemplate: $$figureTitle$$ $$i$$$$titleDelim$$ $$t$$
figureTitle: Figure
listingTemplate: $$listingTitle$$ $$i$$$$titleDelim$$ $$t$$
listingTitle: Listing
lofTitle: |
    List of Figures
    ===============
lolTitle: |
    List of Listings
    ================
lotTitle: |
    List of Tables
    ==============
lstPrefix:
- 'lst.'
- 'lsts.'
rangeDelim: '-'
tableTemplate: $$tableTitle$$ $$i$$$$titleDelim$$ $$t$$
tableTitle: Table
tblPrefix:
- 'tbl.'
- 'tbls.'
titleDelim: ':'
...
lierdakil commented 9 years ago

Oohhh. Right. Sorry. It's not figurePrefix, but figPrefix.

I've got confused with my own spftware. Embarassing.

HJAllen commented 9 years ago

that did it. Thanks. If it makes you feel better, I could have read a bit closer...

lierdakil commented 9 years ago

Anyway, glad to have it resolved. Thank you for using pandoc-crossref!

HJAllen commented 9 years ago

Thank you for your efforts! It has made my workflow so much easier and allows me to keep docx users happy.