Capturing contents within Curly Brackets

A short description of the post.

Rodney Dyer https://dyerlab.org (Center for Environmental Studies)https://ces.vcu.edu
2017-10-05

OK, just a quickie here. I’m working with a colleague on a manuscript using LaTeX. The citation formatting for the journal we are looking at uses the numerical citations but bibtex will number the citations by the order in which the values they occur in the bibliography section. So, it would be great to get them to be in the order in which they occur in the text.

So, our old friend (and sometimes enemy) grep comes to the rescue. Here is a quick one-liner that allows you to search the text for all the entries and return only the contents within the curly brackets.

cat test.tex | grep -o -e "cite{[^}]*}"

Once all the editing is done and we’ve finished on the main body of the text, we can reorder the bibliography section and the numbers will be incremental.

Sometimes I forget how awesome and powerful the unix underpinnings are.

Citation

For attribution, please cite this work as

Dyer (2017, Oct. 5). The Dyer Laboratory: Capturing contents within Curly Brackets. Retrieved from https://dyerlab.github.io/DLabWebsite/posts/2017-10-05-capturing-contents-within-curly-brackets/

BibTeX citation

@misc{dyer2017capturing,
  author = {Dyer, Rodney},
  title = {The Dyer Laboratory: Capturing contents within Curly Brackets},
  url = {https://dyerlab.github.io/DLabWebsite/posts/2017-10-05-capturing-contents-within-curly-brackets/},
  year = {2017}
}