Okay @Desalegn, don't get too used to this
but I've taken a crack at this macro as well:
§Reference Macros.kmmacros (25.7 KB)
I attempted to improve it by eliminating the reliance on clipboard histories and the need for manual input as to how many times the macro should paste a reference collection. Using the companion macros included in that macro file, I tried to set it up so that you can copy titles, authors, and page numbers in any order you like (though the scrapping references macro does still assume that they're all copied in equal number, i.e. one title, author, and pair of page numbers for each reference collection) by assembling each category in its own variable. Once you invoke the scrapping references macro to copy the reference info, a window now pops up to show you all the references you've copied and verify that everything is in order. Confirm them, and the macro loops through the title, author, and pages variables and adds them to reference collections automatically, then pastes them once the last variable is empty.
Here's the "confirm references" window with my test data:
And here's what the macro produces:
@Incollection{,
title = {Into The Water},
author = {Paula Hawkins},
pages = {12–24},
crossref = {Lorem Ipsum},
year = {1982}
}
@Incollection{,
title = {Dragon Teeth},
author = {Michael Crichton},
pages = {24–36},
crossref = {Lorem Ipsum},
year = {1982}
}
@Incollection{,
title = {The Handmaid’s Tale},
author = {Margaret Atwood},
pages = {36-48},
crossref = {Lorem Ipsum},
year = {1982}
}
The goal with this rewrite is for you to be able to copy as many sets of references as you like, much more than 8 if you want, and to have them all formatted and pasted as collections automatically, without the need for you to keep track of how many times you've copied what and without the uncertainty that comes from relying strictly on clipboard history.
(Incidentally, the reason I used pipes as a delimiter for the title variable is because, as far as I know, very few book titles contain them, so this way you should be able to copy titles with commas, colons, semi-colons, slashes, and anything else and still have them be cross-referenced correctly. Author names and page numbers, on the other hand, never contain commas, so I thought it was safe to use them for delimiters in those categories)
I can't promise I'll be able to spend a significant amount of time on another macro like this, but if you run into any issues with this one, let me know and I'll see if I can fix them. I hope this helps with your work, and to better show you the kind of automation possibilities KM offers!