mkdocs-bibtex icon indicating copy to clipboard operation
mkdocs-bibtex copied to clipboard

page numbers in references

Open alexvoss opened this issue 3 years ago • 7 comments

Hi,

I am not sure if it is possible to add page numbers to the references and, if so, what the syntax would be? I tried [@favouriteAuthor2021xx p.123] but no luck. Also not sure how this would be rendered with the default citation style based on footnotes? (The page number could go into the footnote, I guess). In addition to page numbers might also want to reference chapters.

If not possible, please consider this a feature request.

Cheers, Alex

alexvoss avatar Jan 09 '22 15:01 alexvoss

Hi @alexvoss

I'm workin on rebuilding the pandoc integration, so thanks for the feature request. This is definitely more advanced than I expected for this plugin. I'll try to keep this in mind. I don't have any sort of ETA on when it will be included.

shyamd avatar Jan 10 '22 17:01 shyamd

Thanks for looking at this. I guess this is part of a broader question. Sometimes it is necessary to include additional information for a citation. Give than the default reference style is footnotes, would it be possible to have an argument that gets placed into the footnote before the citation itself? Something like:

[Chapter X of @author2021blah] would make a footnote like this: (1)Chapter X of Surname, Firstname. Booktitle. Publisher, Year]

This could serve a whole host of functions including much longer commentary on the referenced part. For example: (1) A counter-example is provided by: ...

alexvoss avatar Jan 10 '22 17:01 alexvoss

The challenge is that I'd then be building a whole referencing standard. My goal is to offload all of this to pandoc, so I'm not supporting everyone's favorite reference style. It's quite possible that the pandoc implementation will forgo footnotes in the future in favor of a "References" section the way wikipedia has evolved.

shyamd avatar Jan 10 '22 18:01 shyamd

That makes perfect sense. Can I ask, though, if there is a way to get the whole formatted reference imported into a place in the document? I could imagine creating footnotes manually and then having the full reference in that footnote. That is a citation style I very much like as the reader does not need to scan to a separate references section. The original use case could be accommodated with that. So, instead of generating a footnote and then putting the formatted reference into \bibliography this would involve putting the formatted reference into the document where the citation occurs.

alexvoss avatar Jan 11 '22 17:01 alexvoss

I have another use case for the feature I suggested. Currently revising my website and I want to manage my own publications using BibTeX. The feature would allow me to compile the list of publications with the bibliographic data interspersed with comments, which would be ideal.

alexvoss avatar Jan 16 '22 10:01 alexvoss

Hi, I was wondering if you had a view on the possibility of emitting the whole reference at the point of the citation as suggested below? I could write [^ref1] at the point of the citation and then [^ref1]: [@farouriteAuthor20xx], page 123 to produce the footnote with the formatted bibliographic data. It would be up to me to manage the creation of footnotes but I could include arbitrary text, even further citations.

alexvoss avatar May 07 '22 11:05 alexvoss

I tested a bit with a different regex syntax in utils.py - this one seems to work pretty well with identifying extra values in the citekey, though I'm not 100% certain it will always work.

cite_regex = re.compile(r"(\[@(?:@\w+[;|,]{0,1}\s*)*[;, -@.\w]+[^\]]\])")

Seems to match everything except prefixes, so [see @author] does not work. Matches via https://regexr.com/

[@author]
[@author, p. 123]
[@author; @author2, p. 123]
[@author; @test_author, chapter 2]
[@author, book a]
[@author, p. 3 suffix]
[@doe99, p. 33-35; also @smith04, chap. 1]

I'm not sure how to approach formatting the keys with data in plugin.py, I'll see if I can modify def format_citations(self, cite_keys): to support it.

Current error message is

File ... \site-packages\mkdocs_bibtex\plugin.py", line 107, in on_page_markdown
File ... \site-packages\mkdocs_bibtex\plugin.py", line 162, in format_citations
File ... \site-packages\pybtex\utils.py", line 163, in __getitem__
return self._dict[key.lower()]
KeyError: 'author, p. 123'

I'll mess around with it and see if I can't get it to work - no clue what the expected input is.

sondregronas avatar May 07 '22 17:05 sondregronas