TransWikia.com

Is there a way to optimize citation order to reduce the number of superscript numbers in text?

TeX - LaTeX Asked by Canageek on October 4, 2020

I want to know if there is a way to optimize the order my citations are in, such that they output the minimum number of numbers in the text.

So, if I have citations cite{A,B,C} and later cite{A,C,D} it will realize that if I had instead done cite{B,A,C} and cite{A,C,D} it would give a shorter output. That is, the first case one of these will have (1-3) and the second (1,3,4). But if they are reordered you would instead get (1-3) and (2-4).

Another example: cite{A,B,C}, cite{D,E,F}, cite{A,D,F} could be optimized to cite{B,C,A}, cite{D,F,E}, cite{A,D,F}. Which would go from (1-3), (4-6), (1,4,6) to (1-3), (4-6), (3-5).

Now that way only removes one number from displaying, but I regularly have 9+ citations inside each cite{} command (i.e. cite{Miro2012,Ling2010,Takao2010,Unruh2009,Goff2008,Kubatko2007,DeAquino2001,Rose1994,David1993}) so an optimization like this could change thing from (1,3,5,7,9,11,13,15,17) to (1-9) at an extreme (going from 22 characters to 3).

I don’t have a way to do this outside of LaTeX. If I had to do it by hand I would first make a list of every group of citations with more then 3 citations that also occur earlier in the document. Then I would find if any of those occurred in the same citation block and put them next to one another, provided that doesn’t make other blocks worse. Then I would find if any of the citations that occur in earlier blocks occur in adjacent blocks, and try and move those to the ends, if I could do so without messing up other blocks. This would not generate an optimized solution, but I suspect it would generate a better one. If doing this by computer, I would also do multiple trials of optimizing the blocks in different orders so that you don’t have an early reordering preventing later ones.

Potentially you could do something with a badness score so that you could mess up one citation block if it made two others better, or one a LOT better?

Rewrite inspired by @JosephWright explained well in the comments:

I think the point here is that if one has several multiple citation,
cite{A,B,C}, cite{A,D,E}, cite{B,D,F}, there will be an optimal
approach to the ordering in each argument which places as many as
possible in continuous runs so reduces the output complexity. -Joseph Wright, May 14 ’16 at 5:30

The optimisation might for example spot that if you have a first use
cite{A,B,C} and later cite{B,D,E} then reordering the first case to
cite{A,C,B} will swap two refs and go from output 1—3 (A = 1, B =
2, C = 3) and 2,4,5 (D = 4, E = 5), to 1–3 (A = 1, C = 2, B = 3) and
3–5 (D = 4, E = 5). The point here is that the refs are all still in
use order, but within sets used at one time the order is optimised to
globally-minimise the number of numbers which need to be printed. –
Joseph Wright May 14 ’16 at 13:34

Original text:

Currently, within each citation block, I’m listing citations by date. So I’ll have a command with something like:cite{Miro2012,Ling2010,Takao2010,Unruh2009,Goff2008,Kubatko2007,DeAquino2001,Rose1994,David1993}

This works quite well, LaTeX does the order for me, and gives me an output like 14,19,62,70,71,75–78

That is pretty ugly and takes up a good inch of space. However, most of those are all referenced in the same citation block earlier in the paper. So really, if I’d cited them in order I’d get something more like 14,19,62-68 Given that most of my citation order is arbitrary within each citation (date) I’m wondering if there is a citation optimizer that goes through and tries to compress your later citation references as much as possible by reordering your earlier ones? Has anyone done something like this in LaTeX?

It would be better still if I could specify times not to do this (i.e. this citation must be first within this block, if it hasn’t been cited already) or if it could work with `achemso’ but I’m mostly curious if this is possible at all.

(MWE removed, as they didn’t add anything except making it look like I was trying to do this with a specific citation package, when I am curious if it is possible to do this at all).

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP