lierdakil / pandoc-crossref

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

One space too many when prefix is set to empty #428

Open rturquier opened 4 months ago

rturquier commented 4 months ago

Hello, and thank you for maintaining pandoc-crossref, it's super useful!

If figPrefix, secPrefix or eqPrefix is set to empty string, there's one extra space when converting to LaTeX. For example:

Is there a way to avoid this?

(similar to #11 and #12)

rturquier commented 4 months ago

→ A workaround is to use the dash syntax in markdown:

Histogram [-@fig:histogram] is in
the next section ([-@sec:examples]).
lierdakil commented 4 months ago

This works:

---
figPrefixTemplate: $$i$$
---

![Foo](foo.jpg){#fig:foo}

See @fig:foo

See https://lierdakil.github.io/pandoc-crossref/#reference-templates

rturquier commented 4 months ago

Ah yes, this seems better than using a dash everywhere. I didn't know about the templates, thank you!

It doesn't put non-breaking spaces in the right place automatically, though, right?

lierdakil commented 4 months ago

Nope, but neither do dashes. Essentially, putting nbsp outside the exact place where the citation occurs is a very non-trivial problem which I'm not smart enough to solve in general, so I didn't even try. If you want nbsp between the preceeding text and the citation, consider inserting it yourself, e.g. see section\ @sec:foo.

I guess there's an option of playing with citation prefixes, e.g. I could reasonably insert an nbsp if you wrote a citation like this: see [section @sec:foo] (the syntax works, but a regular space is currently inserted, and it doesn't work particularly well with multiple references). I'm not at all convinced it's markedly better than simply section\ @sec:foo though.

rturquier commented 4 months ago

I see – thanks a lot for your answers and your time!