TransWikia.com

cleveref list to use "or" instead of "and"

TeX - LaTeX Asked on January 31, 2021

Sometimes I would like cref{item1,,item2,,item3} to write “Item 1, Item 2, or Item 3” instead of “Item 1, Item 2, and Item 3”.

Can this be done on an ad-hoc basis?

One Answer

It can be done, but it's not simple. Take a look at sections 8.1.1 and 8.2.3 of the documentation. This question has a simpler answer than mine below (but take note of the last comment under the question). In my answer you need to specify the counter as well:

usepackage{etoolbox}
usepackage{cleveref}
makeatletter
newcommand{crefor}[2]{%
  crefmultiformat{#1}{csuse{cref@#1@name}~##2##1##3}%
    { or~csuse{cref@#1@name}~##2##1##3}%
    {, csuse{cref@#1@name}~##2##1##3}%
    {, or~csuse{cref@#1@name}~##2##1##3}%
  cref{#2}%
  crefmultiformat{#1}{csuse{cref@#1@name@plural}~##2##1##3}%
    { and~##2##1##3}{, ##2##1##3}{, and~##2##1##3}%
}
makeatother

You use it as crefor{<counter>}{item1,,item2,,item3}. You'd also need to create one for Cref, and maybe add in crefrangemultiformat and Crefrangemultiformat as well. If you want parentheses around equation numbers it will get even more complicated.

I'll let you decide if you want to use the Oxford comma.

Answered by Subhaneil Lahiri on January 31, 2021

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