-
Notifications
You must be signed in to change notification settings - Fork 656
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
Author, year citations #1090
Comments
Thanks for opening your first issue here! Engagement like this is essential for open source projects! 🤗 |
I am not sure exactly how to do this, but it would be great to see it done! If you can figure out how to get sphinxcontrib-bibtex to display more custom outputs, then we can write up some docs as a pattern for users that wish to control this. (perhaps we could also upstream some improvements for certain documentation styles to sphinxcontrib-bibtex?) |
Seconded; it would be nice to have APA style citations in particular for my own work. |
+1, we use author (year) in economics. Thanks @amichuda, would be very happy to have this. |
Y'all should +1 (👍) the top comment in this issue so that it shows up on the issue tracker ;-) |
I was able to integrate the code for this package into pybtex, but there are still two issues I need to resolve: (1) removing the square brackets from the in-line citation, and (2) removing the citation 'name' from the entry in the bibliography. Pictures of odd formatting below. |
That's great! I've been playing around with inheriting from the My main question, though, right now is where to throw in the code... From reading the code, I take it that it has to be integrated somehow into Sorry for the dumb question. Based on the issue above, you're just supposed to include the overriden classes into |
@amichuda There is an associated PyPI package for that repo I linked earlier. You can try installing that, but it didn't work for me when I tried it some months ago. Instead, I took all of the relevant files from that repo and put them into the corresponding folders in the pybtex folder for my conda environment. So formatting/apa.py went into pybtex/formatting/apa.py, and so on. I think that's all I had to do, and then it knows about the |
|
Checking the source of |
I stumbled across the same piece of code as well; I think you are right. Not sure whether there's an alternative to making a separate fork of |
Perhaps we could make some upstream contributions to sphinxcontrib-bibtex? |
Would be happy to help with that; putting my wish-list for publication-ready articles on here for posterity's sake, as I imagine they're all related to
|
Nice - thanks for that wishlist, do you think you could make a new issue out of it? I think it's valuable to track general lists of improvements we want to see to citations support. In general my approach is that we should upstream everything as much as possible. If we hit an impasse with |
In case it helps, author-year citations of various forms are supported in a very hacky way by my https://github.com/jobovy/sphinx-astrorefs It's really way too hacky to incorporate here or in |
Uhhhh that actually seems kind of perfect... How did you get rid of square brackets when dealing with inline citations?
Can you explain what's hacky about it. From a cursory glance at the description, it seems like a custom style using The author of |
It's hacky, because it takes the HTML and LaTeX outputs and processes them to replace the square brackets with parentheses or nothing. It seems to work for now, but such a hack is probably not very long time stable wrt changes to the way Sphinx generates the HTML/LaTeX and it may also not work for all Sphinx themes. I think the proper way would be to create new Sphinx roles for I saw the mcmtroffaes/sphinxcontrib-bibtex#213 PR, but that doesn't allow for the full set of different citation commands that I need. |
Agreed, but that PR would be able to help at least with the issue of processing the files again, correct? I like your idea of defining new roles, I wonder how difficult that would be to implement? Would that require PRs in Sphinx, itself? |
I'm not sure. I think you can define new roles outside of Sphinx, but the |
Some really cool news from |
amazing! |
I would also love to have this option available in |
Hi everyone, I am trying to homogenize the citation/bibliography style for this project(OceanGlidersCommunity/Oxygen_SOP#88). Ideally we would like the Bibliography to show the same format as the citations (example here). Correponding Bibliography entry: I guess what I am most unclear about is how I could implement this custom sphinxcontrib-bibtex code in the If this is not possible, could we export and modify the If someone here has some concrete tips on how to implement this, I would very much appreciate it. I think this is broadly relevant for many folks in e.g. the earth science community. If there is a solution, I'd be happy to work on adding that to the docs if needed. Thanks! |
Hi everyone, while searching for a possibility to get the typical academic citation style (author, year) in a Jupyter book I found this issue. You have done so much great work here and it helped me to come up with a solution ( at least for what I wanted ):
For this Jupyter book this has been achieved with this PR. I want to mention that I'm also very new to this environment and did not know how to bring all the mentioned resources together in the I decided to create an extension folder These extensions can then be loaded within sphinx:
local_extensions:
apastyle: _ext/
bracket_citation_style: _ext/ and referenced: bibtex_reference_style : author_year_round
bibtex_default_style : myapastyle It's important that the files in the extension folder have a As a result I end up with:
For all the details please check out the PR I hope this is useful! |
Thank you so much for outlining these steps @observingClouds! I will try to implement this soon (cc @soerenthomsen ) and report back. |
Hi @observingClouds, I am running into a problem with this, and get Where is the Again, thank you so much for sharing your code, this is less than trivial for me. |
Hi @jbusecke, the |
Thanks @observingClouds also from my side! |
Huh, weird I did install |
That solved it. I think an old pip version might be to blame here. Sorry for the confusion! Works like a charm now! |
Ok so I tried this out locally and it worked fine, but in our actual deployment relevant PR it doesnt. Here is the current preview compared to what I got locally: I have tried switching to a mamba based env setup (which is what I used locally), but somehow this still doesnt work. I wonder if I am still missing a dependency? I am getting some warnings which I didnt see during the local build, but these do not seem related on the problem at hand. Sorry for all the spam, thankful for any ideas how to debug this. |
Hmmm, I wonder if some of these issues would also be resolved by this issue: Feel free to add thoughts there too! |
Thanks for the pointer @choldgraf. I think the most useful action here would to add instructions for this quite common use case to the jupyterbook docs? @observingClouds s PR has all the ingredients (if you actually commit them, not like me yesterday 😭). |
|
This is a first pass at handling jupyter book-style bibliographies. There are a number of compromises made but we'll get to that. As a commit: * This adds tests around both end-of-book bibliographies as well as end-of-chapter and end-of-chapter-part-file bibliographies, as well as code to pass those tests. * There was a small refactor in the `chapter_processing`-type functions to yank out the code that ultimately went into `get_main_section()` to avoid duplication. A chapter-file bibliography gets added as its own section, so we needed a way to capture that and doing it in one function as opposed to in both the chapter and chapter part processing functions made more sense. * HTMLBook bibliographies are appendixes, so that data-type is added when the bib is a single file. * The actual handling of the bibliography happens in the `process_citations` function, which rips out the <dt> pointers and leaves only the <dd> citations. Handling the actual citations to these bibliographical references will come in a later commit. Some notes and caveats: * There is not a good way to reformat the citations in this script. The way to do it would be to modify the Bibtex formatting, but that feels outside the scope of our current work. This means that bibliographies will have to be worked on after intake; this feels like an OK compromise for the time being. Should we go down that path, there is some discussion [here](link), and related [here](other_link). * Since we don't really have a good way to modify the bibliographical entries themselves, we likewise don't have a great way to organize combined bibliographies from multiple chapter sub-files. Right now we're doing a sort of "dumb" combine, appending one to the other (i.e., we're not sorting them in any way). While we could do some list sorting, I'm not confident it would be good enough or that the data will be standard enough to really do that in a reliable way, so for now this compromise feels not _great_ but worthwhile. * As mentioned, handling for the citations themselves will come in a subsequent commit. Sadly, we're starting to get to the brittler points wherein I'm beginning to think that we ought to instead be writing some kind of a backend against Jupyter Book/Sphinx like we do for asciidoc, but we're in this far, so we'll just need to keep on top of Jupyter Book updates and be careful about targeted version(s). This commit tries to honor making the script "just work" while compromising enough that hopefully what work done here is relatively durable (i.e., not making too much assumptions about the formatting of things outside of the document structure itself, which _in theory_ is going to be relatively stable going forward. link: jupyter-book/jupyter-book#1090 other_link: mcmtroffaes/sphinxcontrib-bibtex#203
This is a first pass at handling jupyter book-style bibliographies. There are a number of compromises made but we'll get to that. As a commit: * This adds tests around both end-of-book bibliographies as well as end-of-chapter and end-of-chapter-part-file bibliographies, as well as code to pass those tests. * There was a small refactor in the `chapter_processing`-type functions to yank out the code that ultimately went into `get_main_section()` to avoid duplication. A chapter-file bibliography gets added as its own section, so we needed a way to capture that and doing it in one function as opposed to in both the chapter and chapter part processing functions made more sense. * HTMLBook bibliographies are appendixes, so that data-type is added when the bib is a single file. * The actual handling of the bibliography happens in the `process_citations` function, which rips out the <dt> pointers and leaves only the <dd> citations. Handling the actual citations to these bibliographical references will come in a later commit. Some notes and caveats: * There is not a good way to reformat the citations in this script. The way to do it would be to modify the Bibtex formatting, but that feels outside the scope of our current work. This means that bibliographies will have to be worked on after intake; this feels like an OK compromise for the time being. Should we go down that path, there is some discussion [here](link), and related [here](other_link). * Since we don't really have a good way to modify the bibliographical entries themselves, we likewise don't have a great way to organize combined bibliographies from multiple chapter sub-files. Right now we're doing a sort of "dumb" combine, appending one to the other (i.e., we're not sorting them in any way). While we could do some list sorting, I'm not confident it would be good enough or that the data will be standard enough to really do that in a reliable way, so for now this compromise feels not _great_ but worthwhile. * As mentioned, handling for the citations themselves will come in a subsequent commit. Sadly, we're starting to get to the brittler points wherein I'm beginning to think that we ought to instead be writing some kind of a backend against Jupyter Book/Sphinx like we do for asciidoc, but we're in this far, so we'll just need to keep on top of Jupyter Book updates and be careful about targeted version(s). This commit tries to honor making the script "just work" while compromising enough that hopefully what work done here is relatively durable (i.e., not making too much assumptions about the formatting of things outside of the document structure itself, which _in theory_ is going to be relatively stable going forward. link: jupyter-book/jupyter-book#1090 other_link: mcmtroffaes/sphinxcontrib-bibtex#203 Update: check for existance of lis after processing
This is a first pass at handling jupyter book-style bibliographies. There are a number of compromises made but we'll get to that. As a commit: * This adds tests around both end-of-book bibliographies as well as end-of-chapter and end-of-chapter-part-file bibliographies, as well as code to pass those tests. * There was a small refactor in the `chapter_processing`-type functions to yank out the code that ultimately went into `get_main_section()` to avoid duplication. A chapter-file bibliography gets added as its own section, so we needed a way to capture that and doing it in one function as opposed to in both the chapter and chapter part processing functions made more sense. * HTMLBook bibliographies are appendixes, so that data-type is added when the bib is a single file. * The actual handling of the bibliography happens in the `process_citations` function, which rips out the <dt> pointers and leaves only the <dd> citations. Handling the actual citations to these bibliographical references will come in a later commit. Some notes and caveats: * There is not a good way to reformat the citations in this script. The way to do it would be to modify the Bibtex formatting, but that feels outside the scope of our current work. This means that bibliographies will have to be worked on after intake; this feels like an OK compromise for the time being. Should we go down that path, there is some discussion [here](link), and related [here](other_link). * Since we don't really have a good way to modify the bibliographical entries themselves, we likewise don't have a great way to organize combined bibliographies from multiple chapter sub-files. Right now we're doing a sort of "dumb" combine, appending one to the other (i.e., we're not sorting them in any way). While we could do some list sorting, I'm not confident it would be good enough or that the data will be standard enough to really do that in a reliable way, so for now this compromise feels not _great_ but worthwhile. * As mentioned, handling for the citations themselves will come in a subsequent commit. Sadly, we're starting to get to the brittler points wherein I'm beginning to think that we ought to instead be writing some kind of a backend against Jupyter Book/Sphinx like we do for asciidoc, but we're in this far, so we'll just need to keep on top of Jupyter Book updates and be careful about targeted version(s). This commit tries to honor making the script "just work" while compromising enough that hopefully what work done here is relatively durable (i.e., not making too much assumptions about the formatting of things outside of the document structure itself, which _in theory_ is going to be relatively stable going forward. link: jupyter-book/jupyter-book#1090 other_link: mcmtroffaes/sphinxcontrib-bibtex#203 Update: check for existance of lis after processing
This is a first pass at handling jupyter book-style bibliographies. There are a number of compromises made but we'll get to that. As a commit: * This adds tests around both end-of-book bibliographies as well as end-of-chapter and end-of-chapter-part-file bibliographies, as well as code to pass those tests. * There was a small refactor in the `chapter_processing`-type functions to yank out the code that ultimately went into `get_main_section()` to avoid duplication. A chapter-file bibliography gets added as its own section, so we needed a way to capture that and doing it in one function as opposed to in both the chapter and chapter part processing functions made more sense. * HTMLBook bibliographies are appendixes, so that data-type is added when the bib is a single file. * The actual handling of the bibliography happens in the `process_citations` function, which rips out the <dt> pointers and leaves only the <dd> citations. Handling the actual citations to these bibliographical references will come in a later commit. Some notes and caveats: * There is not a good way to reformat the citations in this script. The way to do it would be to modify the Bibtex formatting, but that feels outside the scope of our current work. This means that bibliographies will have to be worked on after intake; this feels like an OK compromise for the time being. Should we go down that path, there is some discussion [here](link), and related [here](other_link). * Since we don't really have a good way to modify the bibliographical entries themselves, we likewise don't have a great way to organize combined bibliographies from multiple chapter sub-files. Right now we're doing a sort of "dumb" combine, appending one to the other (i.e., we're not sorting them in any way). While we could do some list sorting, I'm not confident it would be good enough or that the data will be standard enough to really do that in a reliable way, so for now this compromise feels not _great_ but worthwhile. * As mentioned, handling for the citations themselves will come in a subsequent commit. Sadly, we're starting to get to the brittler points wherein I'm beginning to think that we ought to instead be writing some kind of a backend against Jupyter Book/Sphinx like we do for asciidoc, but we're in this far, so we'll just need to keep on top of Jupyter Book updates and be careful about targeted version(s). This commit tries to honor making the script "just work" while compromising enough that hopefully what work done here is relatively durable (i.e., not making too much assumptions about the formatting of things outside of the document structure itself, which _in theory_ is going to be relatively stable going forward. link: jupyter-book/jupyter-book#1090 other_link: mcmtroffaes/sphinxcontrib-bibtex#203 Update: check for existance of lis after processing Update: typo fix
Currently,
jupyter-book
usessphinxcontrib-bibtex
for creating citation keys in text using thecite
directive.However, for academic citations (at least for my field) the convention is to use an author, year citation key.
There's an issue open about this on
sphinxcontrib-bibtex
: mcmtroffaes/sphinxcontrib-bibtex#201I think it comes down to just creating a custom citation class using
pybtex
.I think this is something in my wheelhouse to do a PR for if it's something you all think has value.
Would this be a matter of just adding it to some
jupyter-book
conf.py
? And then registering it somehow?The text was updated successfully, but these errors were encountered: