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

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

Open
rturquier opened this issue Feb 13, 2024 · 5 comments
Open

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

rturquier opened this issue Feb 13, 2024 · 5 comments

Comments

@rturquier
Copy link

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:

  • markdown histogram [@fig:histogram]
    becomes: histogram ~\ref{fig:histogram}
    instead of: histogram~\ref{fig:histogram}
  • markdown In the second section ([@sec:examples])
    becomes: In the second section (~\ref{sec:examples})
    instead of: In the second section~(\ref{sec:examples})

Is there a way to avoid this?

(similar to #11 and #12)

@rturquier
Copy link
Author

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

Histogram [-@fig:histogram] is in
the next section ([-@sec:examples]).

@lierdakil
Copy link
Owner

This works:

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

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

See @fig:foo

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

@rturquier
Copy link
Author

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
Copy link
Owner

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
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants