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

Option to remove space between figure prefix and suffix in text (e.g. "Fig. 1A" vs "Fig. 1 A") #352

Closed mhoban closed 2 years ago

mhoban commented 2 years ago

I have a compound figure (i.e. one figure with sections A, B, etc.) and I'm trying to figure out if there's a way to have the in-text citation to the figure appear as e.g. "Fig. 1A" instead of "Fig. 1 A". As far as I can tell, the space is hard-coded into the suffix. I'd prefer to use my own image because it's laid out in a specific way, rather than providing separate images and using subfigures.

In my text, I have [@fig:fig1 A], which renders as "Fig. 1 A".

It would be nice to be able to include some kind of delimiter to specify that I don't want the space, like [@fig:fig1|A] or some such, so that I get "Fig. 1A'.

Is this currently possible and I just haven't figured out how to do it? Or is it not designed to do this?

mhoban commented 2 years ago

Ah, it looks like I can put the "A" outside of the brackets,like [@fig:fig1]A, which works fine for me.

lierdakil commented 2 years ago

The space isn't hard-coded, but the suffix is taken verbatim, including the leading space. You can hack around that by inserting a zero-width space, e.g. [@fig:fig1​A], or inserting an empty bracketed span [@fig:fig1[]{}A]. Neither is very pretty, unfortunately.

Your workaround is fine too, if you don't want to hyperlink the references.

mhoban commented 2 years ago

Great, thanks for the other options!

lierdakil commented 2 years ago

Also, side note, if you don't mind adding a non-alphanumeric non-space character between the reference and the suffix, literal escapes work too, e.g. [@fig:fig1\-A] will be rendered as fig. 1-A; the same goes for any non-alphanumeric non-space characters (most don't need escapes even).