chrisgrieser / alfred-bibtex-citation-picker

Citation picker & lightweight reference manager for BibTeX files, via Alfred.
MIT License
137 stars 8 forks source link

Feature Request: Support customizing citation syntax #1

Closed wenlzhang closed 2 years ago

wenlzhang commented 2 years ago

Feature Requested

Currently, the default citation syntax is [@citekey], for use with pandoc. In my workflow, there are also two other use cases.

Therefore, it would be great if one can customize the citation syntax to use. For instance, one can set a default format and a few other formats. When inserting the citation key, the default format would be used, unless specified otherwise.

Relevant Screenshot

No response

Checklist

noirchen commented 2 years ago

I agree. This can be implemented as an option choosing between @, # or bare key.

owlasea commented 2 years ago

Seconded. This would be super useful! Thanks!

stravers56 commented 2 years ago

I would like this feature for latex as well.

chrisgrieser commented 2 years ago

Can anyone refer me to some documentation for Latex citations? Specifically, I need information on how citations look like for various cases?

owlasea commented 2 years ago

These are the ones that work for bibtex. Not sure if it works for other settings/packages (e.g., Natbib, apacite).

I also found these on Overleaf for your reference: https://www.overleaf.com/learn/latex/Biblatex_citation_styles

https://www.overleaf.com/learn/latex/Natbib_citation_styles

chrisgrieser commented 2 years ago

so instead of hardcoding a citation syntax format, I have simply turned all of them into variables, so it should cover everything form tags in Obsidian to other citation formats. However I am not totally certain, that I "get" this weird Latex citation syntax โ€“ I am writing in markdown since I wanted to avoid all the hassle of Latex, after all ๐Ÿ˜…

Would this suffice? (the screenshot contains the values for Pandoc citations) You can try it out in release 9.0.0.

Pasted image 2022-05-19 19 56 20
owlasea commented 2 years ago

Thanks for the great work Chris! Everything works except the _format_citekey_prefix though. When I set it to empty instead of @, the "@" still appears anyway. If I change it to other values, @ remains and the newly set value is not reflected. Wonder if there is anything I am doing wrong? Should I be tweaking something else? Thank you again!

noirchen commented 2 years ago

Thanks for the new version! Everything works like a charm. I did not meet the persisting @ issue.

owlasea commented 2 years ago

Ah I reloaded the buffer and now everything works!

chrisgrieser commented 2 years ago

Could you show me what values you have all set for _format... ?

That way, I can add some presets, which not only make it easier to switch, but also automatically reload the buffer

chrisgrieser commented 2 years ago

also, I noticed that with certain citation styles, you put the page number before the citekey. So I have added the following two options to version 9.1.0 to account for that possibility.

Could you give it a try and see whether you can cover all cases (multiple citations, with/without page numbers) by having these variables? If those are enough, and you can give me the values for the _format... variables, then I can set presets so the user doesn't have to fiddle too much with the formatting.

image

owlasea commented 2 years ago

Hi @chrisgrieser , here is the values I set for _format...:

Screen Shot 2022-05-20 at 15 09 13

I also noticed that the reason that reloading the buffer solves the issue with persistent @ is that I have set the prefix to empty in the first place, but this creates another problem that, if I want to insert something like [[@citekey]] and the prefix is set to empty, it will give me [[citekey]] without the @. In other words, it seems if I set the prefix and reload the buffer, it will always come up with prefix+citekey as the {query} variable. Is there a way for me to set the {query} as only the citekeys without the prefixes? Thanks!

chrisgrieser commented 2 years ago

if I want to insert something like [[@citekey]] and the prefix is set to empty, it will give me [[citekey]] without the @

@owlasea I am not entirely sure that I understand what you mean. Like, how is set prefix โ†’ get prefix not the intended behavior? ๐Ÿคจ

If this is about the need for reloading, I just pushed an update (9.1.2) which removes the prefix from the query, so that you can change the formatting without reloading the buffer.

chrisgrieser commented 2 years ago

with 9.2.0, one can now more conveniently change the citation format via scp. You can add citations formats, e.g. for all the Latex variants, via PR to this file.

Pasted image 2022-05-20 12 02 32 Pasted image 2022-05-20 12 02 54
owlasea commented 2 years ago

This is awesome! Thanks Chris!

By the way is the multiple citation working properly? I am getting something like this:

Screen Shot 2022-05-20 at 21 17 33

The only citation that gets the prefix is the one that I select last? Was not a problem in some earlier versions.

chrisgrieser commented 2 years ago

thanks, is fixed

chrisgrieser commented 2 years ago

well, I guess this issue can be regarded as closed then?

chrisgrieser commented 2 years ago

just for reference: I also added a bare citekey option.

With the irregularity of Latex citations, I'd probably need some advice on how to properly format that. In case someone is interested in that, please open a new issue for the Latex citation format