Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "Figure" label when referencing #13

Closed
dbobak opened this issue Apr 25, 2016 · 5 comments
Closed

Add "Figure" label when referencing #13

dbobak opened this issue Apr 25, 2016 · 5 comments

Comments

@dbobak
Copy link

dbobak commented Apr 25, 2016

When referencing a figure in the text, fignos produces only the figure number, without "fig" or "figure" label. Would it be possible to make its behaviour similar to pandoc-citeproc?

For example:
Figure insertion:
![My great chart with data.](fig/chart.png){#fig:chart}
Figure reference:
Lorem ipsum ({@fig:chart}) dolor sit amet
Result:
Lorem ipsum (1.1) dolor sit amet

And I mean this behaviour:
Figure reference:
Lorem ipsum ({@fig:chart}) dolor sit amet
Result:
Lorem ipsum (Figure 1.1) dolor sit amet

Figure reference:
Lorem ipsum ({-@fig:chart}) dolor sit amet
Result:
Lorem ipsum (1.1) dolor sit amet

It would also be nice to have the same behaviour in tablenos and eqnos :)

@tomduck
Copy link
Owner

tomduck commented Apr 27, 2016

Hi, @dbobak. Thanks for this excellent suggestion. I have been thinking on it for a few days. LaTeX supports "clever referencing" through the cleveref package. To implement it for other output formats I just need to work out what cleveref is doing.

The question is how to best enable this behaviour.

It seems reasonable to add a metadata field to signal clever referencing; e.g., -M cref in the call to pandoc. It is probably also necessary to have control on a per-reference class basis; e.g., -M eqnos-cref. Each of these could be optionally set to on or off.

As you have pointed out, there needs to be some way to turn off clever referencing. The use case is markdown text like @fig:one and @fig:two that would be transformed to "Figure 1 and Figure 2". We need to turn off clever referencing in order to manually generate the text "Figures 1 and 2". (Note: I know the cleveref package support grouping references, but I don't presently have a markdown spec that describes such behaviour. Let's take it one step at a time.)

Using markdown like -@fig:one to disable clever referencing is well outside of the syntax developed in Pandoc Issue #813. It doesn't seem likely to me that pandoc would adopt it. Perhaps we can come up with something better.

Pandoc is increasingly using attributes. Can we use them instead? e.g., something like @fig:one{cref=off}. It isn't quite as economical, but it is more consistent with pandoc's direction and the meaning is clear.

Thoughts?

@tomduck
Copy link
Owner

tomduck commented Apr 28, 2016

I created a new cleveref branch that has this feature working for tex/pdf output. There is still some tuning to do, more coding for the other formats, and documentation to write. But it won't be long.

Feedback on the proposed syntax is definitely welcome.

@tomduck
Copy link
Owner

tomduck commented May 3, 2016

I was wrong about the -@fig:one syntax. Pandoc does use something similar for citation processing. We can use it too.

This enhancement is still in progress. I'm doing a pretty major refactoring to allow for the same behaviour in pandoc-eqnos and pandoc-tablenos.

@dbobak
Copy link
Author

dbobak commented May 10, 2016

@tomduck, thanks for taking my idea under consideration :) The "clever referencing" feature looks very promising!

Thank you! :)

@tomduck
Copy link
Owner

tomduck commented May 15, 2016

I just posted new releases of pandoc-fignos/eqnos/tablenos that have clever referencing. The syntax is close to what you suggested. Unfortunately, I couldn't use the minus sign to disable clever referencing because pandoc silently drops minus signs in front of references. There is nothing that I can do to work around this flaw. An exclamation point is used to disable clever referencing instead.

As part of this release, I pulled common code out of the three projects and created the pandoc-xnos library. This should make maintenance and further development easier.

In any case, enjoy!

@tomduck tomduck closed this as completed May 15, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants