Vertical list customization like enumitem's itemjoin?Enumerate and itemize undefined + captions not workingUsing cleveref with enumitem's newlistsHow can I create a better pseudo-enumerated list unconstrained by any environmentAvoid paragraph new line after enumerate or itemize from package enumitemHow to create list like this?cross-referencing two long lists; general recommendations?Writing enumitem's to a fileForce list-like indentationHow can I fix the spacing in enumitem inline lists?»missing item« despite using enumitem's resume
Is this a crown race?
Do I need a return ticket to Canada if I'm a Japanese National?
Short story about an infectious indestructible metal bar?
Can I frame a new window without adding jack studs?
Short story about cities being connected by a conveyor belt
Finding integer solution to a quadratic equation in two unknowns
Should we avoid writing fiction about historical events without extensive research?
Is "cogitate" used appropriately in "I cogitate that success relies on hard work"?
Why do we call complex numbers “numbers” but we don’t consider 2-vectors numbers?
Generating a list with duplicate entries
Why does this boat have a landing pad? (SpaceX's GO Searcher) Any plans for propulsive capsule landings?
What would be the most expensive material to an intergalactic society?
Having the player face themselves after the mid-game
How do I align tablenotes in a threeparttable
Does an unused member variable take up memory?
Why restrict private health insurance?
School performs periodic password audits. Is my password compromised?
What does *dead* mean in *What do you mean, dead?*?
What is better: yes / no radio, or simple checkbox?
How does learning spells work when leveling a multiclass character?
What is the purpose of a disclaimer like "this is not legal advice"?
How does a sound wave propagate?
Should I apply for my boss's promotion?
Is it a Cyclops number? "Nobody" knows!
Vertical list customization like enumitem's itemjoin?
Enumerate and itemize undefined + captions not workingUsing cleveref with enumitem's newlistsHow can I create a better pseudo-enumerated list unconstrained by any environmentAvoid paragraph new line after enumerate or itemize from package enumitemHow to create list like this?cross-referencing two long lists; general recommendations?Writing enumitem's to a fileForce list-like indentationHow can I fix the spacing in enumitem inline lists?»missing item« despite using enumitem's resume
I like the flexibility in editing afforded by custom inline enumitem lists; for example:
documentclassarticle
usepackageenumitem
newlistinlineitemitemize*1
setlist[inlineitem] % Customize itemize* environ
before=unskip:, % Colon before list
itemjoin=;, % Join with semicolons
itemjoin*=; and, % Last join has "; and "
label=, % No label
after=. % Period at end of last item
begindocument
Here is some text that will have a list of
begininlineitem
item a list item that could go first but also last
item another list item that I'm not sure about
item this one should go last unless I think of another one
endinlineitem
It's convenient because I can add, remove, and rearrange items without worrying about punctuation.
enddocument

I'd like to do the same thing with a non-inline list; however, enumitem's docs state that "itemjoin is ignored in vertical mode", and so it is.
lists enumitem
add a comment |
I like the flexibility in editing afforded by custom inline enumitem lists; for example:
documentclassarticle
usepackageenumitem
newlistinlineitemitemize*1
setlist[inlineitem] % Customize itemize* environ
before=unskip:, % Colon before list
itemjoin=;, % Join with semicolons
itemjoin*=; and, % Last join has "; and "
label=, % No label
after=. % Period at end of last item
begindocument
Here is some text that will have a list of
begininlineitem
item a list item that could go first but also last
item another list item that I'm not sure about
item this one should go last unless I think of another one
endinlineitem
It's convenient because I can add, remove, and rearrange items without worrying about punctuation.
enddocument

I'd like to do the same thing with a non-inline list; however, enumitem's docs state that "itemjoin is ignored in vertical mode", and so it is.
lists enumitem
What does "the same thing" mean? Have you triedlabel=; and?
– Andrew
Sep 13 '18 at 14:39
1
@Andrew "the same thing" means automatically addingbeforebefore the list,itemjointo the end of every item in the list except the penultimate and last ones,itemjoin*to the penultimate item, andafterto the last item. Usinglabel=; andchanges the label of every item to be; and, which is definitely not the effect I'm going for.
– Dan
Sep 14 '18 at 7:39
I'm reminded this bounty needs to be allocated soon, so just a reminder to raise any concerns with either answer before I have to make a decision.
– KJO
Feb 3 at 17:44
add a comment |
I like the flexibility in editing afforded by custom inline enumitem lists; for example:
documentclassarticle
usepackageenumitem
newlistinlineitemitemize*1
setlist[inlineitem] % Customize itemize* environ
before=unskip:, % Colon before list
itemjoin=;, % Join with semicolons
itemjoin*=; and, % Last join has "; and "
label=, % No label
after=. % Period at end of last item
begindocument
Here is some text that will have a list of
begininlineitem
item a list item that could go first but also last
item another list item that I'm not sure about
item this one should go last unless I think of another one
endinlineitem
It's convenient because I can add, remove, and rearrange items without worrying about punctuation.
enddocument

I'd like to do the same thing with a non-inline list; however, enumitem's docs state that "itemjoin is ignored in vertical mode", and so it is.
lists enumitem
I like the flexibility in editing afforded by custom inline enumitem lists; for example:
documentclassarticle
usepackageenumitem
newlistinlineitemitemize*1
setlist[inlineitem] % Customize itemize* environ
before=unskip:, % Colon before list
itemjoin=;, % Join with semicolons
itemjoin*=; and, % Last join has "; and "
label=, % No label
after=. % Period at end of last item
begindocument
Here is some text that will have a list of
begininlineitem
item a list item that could go first but also last
item another list item that I'm not sure about
item this one should go last unless I think of another one
endinlineitem
It's convenient because I can add, remove, and rearrange items without worrying about punctuation.
enddocument

I'd like to do the same thing with a non-inline list; however, enumitem's docs state that "itemjoin is ignored in vertical mode", and so it is.
lists enumitem
lists enumitem
asked Sep 13 '18 at 12:38
DanDan
1625
1625
What does "the same thing" mean? Have you triedlabel=; and?
– Andrew
Sep 13 '18 at 14:39
1
@Andrew "the same thing" means automatically addingbeforebefore the list,itemjointo the end of every item in the list except the penultimate and last ones,itemjoin*to the penultimate item, andafterto the last item. Usinglabel=; andchanges the label of every item to be; and, which is definitely not the effect I'm going for.
– Dan
Sep 14 '18 at 7:39
I'm reminded this bounty needs to be allocated soon, so just a reminder to raise any concerns with either answer before I have to make a decision.
– KJO
Feb 3 at 17:44
add a comment |
What does "the same thing" mean? Have you triedlabel=; and?
– Andrew
Sep 13 '18 at 14:39
1
@Andrew "the same thing" means automatically addingbeforebefore the list,itemjointo the end of every item in the list except the penultimate and last ones,itemjoin*to the penultimate item, andafterto the last item. Usinglabel=; andchanges the label of every item to be; and, which is definitely not the effect I'm going for.
– Dan
Sep 14 '18 at 7:39
I'm reminded this bounty needs to be allocated soon, so just a reminder to raise any concerns with either answer before I have to make a decision.
– KJO
Feb 3 at 17:44
What does "the same thing" mean? Have you tried
label=; and?– Andrew
Sep 13 '18 at 14:39
What does "the same thing" mean? Have you tried
label=; and?– Andrew
Sep 13 '18 at 14:39
1
1
@Andrew "the same thing" means automatically adding
before before the list, itemjoin to the end of every item in the list except the penultimate and last ones, itemjoin* to the penultimate item, and after to the last item. Using label=; and changes the label of every item to be ; and, which is definitely not the effect I'm going for.– Dan
Sep 14 '18 at 7:39
@Andrew "the same thing" means automatically adding
before before the list, itemjoin to the end of every item in the list except the penultimate and last ones, itemjoin* to the penultimate item, and after to the last item. Using label=; and changes the label of every item to be ; and, which is definitely not the effect I'm going for.– Dan
Sep 14 '18 at 7:39
I'm reminded this bounty needs to be allocated soon, so just a reminder to raise any concerns with either answer before I have to make a decision.
– KJO
Feb 3 at 17:44
I'm reminded this bounty needs to be allocated soon, so just a reminder to raise any concerns with either answer before I have to make a decision.
– KJO
Feb 3 at 17:44
add a comment |
2 Answers
2
active
oldest
votes
Here's a possible solution that works by redefining item.
This may seem a little heavy-handed, but it is also how the itemjoin key for inline lists works.
I'm using SetEnumitemKey to define a new key, sentence, that can be supplied to any list environment that enumitem knows about.
It will append a period (.) to the last item and a semicolon (;) to every other item.
documentclassarticle
usepackageenumitem
SetEnumitemKeysentence%
before*=sentencelistprep;,
after*=unskip.,
letsentenceitemjoinempty
edefsentenceitemnoexpandsentenceitemjoinunexpandedexpandafteritem%
newcommand*sentencelistprep[1]%
defsentenceitemjoindefsentenceitemjoinunskip#1%
letitemsentenceitem
begindocument
Here is an textttitemize environment whose items are part of this sentence and therefore come with appropriate punctuation:
beginitemize[sentence]
item a list item that could go first but also last
item another list item that I'm not sure about that is long enough to span two lines
item this one should go last unless I think of another one
enditemize
It's convenient because I can add, remove, and rearrange items without worrying about punctuation.
enddocument

Warning: you can't use any other list environments inside one with the
sentencekey because the redefinition ofitemwill also apply to those and will insert additional semicolons there as well.
(You probably wouldn't want to nest lists inside a running sentence, but if you have to you can addletsentenceitemjoinemptyinside the inner list.)
Remarks
- I didn't include the colon (:) because does not feel like it is a part of the list (and not affected if items are reordered).
If you do want the colon to automatically be inserted you can replace the value ofbefore*above byunskip:sentencelistprep;. If you don't want to have to supply the
sentencekey every time, you can create a custom list environment that includes it with e.g.newlistmyitemizeitemize1
setlist[myitemize]label=textbullet,sentenceThe
beforeandafterkeys overwritesentenceif supplied later, but the converse is not true becausesentenceuses the starred versionsbefore*andafter*.sentencelistprep;, which is called at the start of a list withsentence, does the following: it definessentenceitemjoinasdefsentenceitemjoinunskip;and replacesitemby a version that includessentenceitemjoin.
The firstitemtherefore redefinessentenceitemjointounskip;, and everyitemafter that consequently inserts a;before it.
Addendum
Per your request, here is a way to add “and” to the semicolon in the penultimate item.
I couldn't do this by simply modifying the other solution because an items in a list environment can't really know if it is the final one.
The following works by first scanning the contents of the entire list environment and inserting ;s at the end of every item but the last one, and additionally adding and to the penultimate item. It's a little bit of a hack, but it works. (Unlike with the above version, you can nest another list environment in this one, though it still seems unlikely that you would want to.)
documentclassarticle
usepackageenumitem
usepackageenviron %% <- for Collect@Body
makeatletter %% <- make @ usable in command sequences
SetEnumitemKeysentence% %% <- register key
before*=sentencelist@afterfi,
defsentencelist@afterfi#1fi %% <- insert sentencelist code after fi
#1fiCollect@Bodysentencelist %% <- apply sentencelist to the body of the environment
defsentencelist#1@sentencelist#1item@sentencelist
def@sentencelist#1item#2@sentencelist
#1@@sentencelist#2@@sentencelist %% <- just insert everything up to the first item
def@@sentencelist#1item#2@@sentencelist%
ifrelaxdetokenize#2relax %% <- if last item
if@newlistelse andfi %% <- insert "and" if not also the first item
item #1unskip.% %% <- insert the item and a .
else %% <- otherwise
item #1unskip;% %% <- insert the item and a ;
@@sentencelist#2@@sentencelist %% <- and repeat
fi
makeatother %% <- revert @
begindocument
Here is an textttitemize environment whose items are part of this sentence and therefore come with appropriate punctuation:
beginitemize[sentence]
item a list item that could go first but also last
item another list item that I'm not sure about that is long enough to span two lines
item this one should go last unless I think of another one
enditemize
It's convenient because I can add, remove, and rearrange items without worrying about punctuation.
enddocument
Is there a way to get the "; and" at the end of the penultimate item?
– Dan
yesterday
The answer is of course “yes”, but it won't be a simple modification. I'm usingitemto print the preceding;, but it is impossible to tell if any particularitemis the last one without doing something like countingitems (and storing the result in the aux file) or scanning the contents of the list environment beforehand. I'll get back to you on this (but it may be a while; I'm a little busy atm).
– Circumscribe
yesterday
@Dan: See the addendum to my answer.
– Circumscribe
2 hours ago
add a comment |
Here is a version that sort of reproduces a display itemize allowing for the features of an itemize*. Below is the same content using inlineitem (provided in question), displayitem and a regular itemize for comparison purposes:

Notes:
The color red has been added to make it easier to compare the three versions. You can replace the definition of
Showwithnewcommand*Show[1]#1to eliminate the highlighting or simply remove all references to the
Showmacro.The "sort of" is because I wasn't able to get the vertical spacing of the very first item to match what
itemizeyields.
Code:
documentclassarticle
usepackageenumitem
usepackagexcolor
newcommand*NextLine%
newline
vspace*0.5baselineskip%
hspace*dimexprlabelindent+labelwidth-labelseprelax%
%
newcommand*Show[1]textcolorredbfseries#1% Make it easier to see difference
newlistinlineitemitemize*1
setlist[inlineitem] % Customize itemize* environ
before=unskipShow:, % Colon before list
itemjoin=Show;, % Join with semicolons
itemjoin*=Show; and, % Last join has "; and "
label=, % No label
after=., % Period at end of last item
newlistdisplayitemitemize*1
setlist[displayitem] % Customize itemize* environ
before=unskipShow:NextLine, % Colon before list
itemjoin=Show;NextLine, % Join with semicolons
itemjoin*=Show; andNextLine, % Last join has "; and "
label=$bullet$, % Label
after=unskipShow.endgrafnoindent, % Period at end of last item
pagecolorwhite
begindocument
noindent
Here is some text in a verb|inlineitem|
begininlineitem
item a list item that could go first but also last
item another list item that I'm not sure about
item this one should go last unless I think of another one
endinlineitem
Some text after verb|inlineitem|.
bigskip
noindent
Here is the same text in a verb|displayitem|
begindisplayitem
item a list item that could go first but also last
item another list item that I'm not sure about
item this one should go last unless I think of another one
enddisplayitem
Some text after verb|displayitem|.
bigskip
noindent
Here is the same text in an verb|itemize|
beginitemize
item a list item that could go first but also last
item another list item that I'm not sure about
item this one should go last unless I think of another one
enditemize
Some text after regular verb|itemize|.
enddocument
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "85"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f450715%2fvertical-list-customization-like-enumitems-itemjoin%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Here's a possible solution that works by redefining item.
This may seem a little heavy-handed, but it is also how the itemjoin key for inline lists works.
I'm using SetEnumitemKey to define a new key, sentence, that can be supplied to any list environment that enumitem knows about.
It will append a period (.) to the last item and a semicolon (;) to every other item.
documentclassarticle
usepackageenumitem
SetEnumitemKeysentence%
before*=sentencelistprep;,
after*=unskip.,
letsentenceitemjoinempty
edefsentenceitemnoexpandsentenceitemjoinunexpandedexpandafteritem%
newcommand*sentencelistprep[1]%
defsentenceitemjoindefsentenceitemjoinunskip#1%
letitemsentenceitem
begindocument
Here is an textttitemize environment whose items are part of this sentence and therefore come with appropriate punctuation:
beginitemize[sentence]
item a list item that could go first but also last
item another list item that I'm not sure about that is long enough to span two lines
item this one should go last unless I think of another one
enditemize
It's convenient because I can add, remove, and rearrange items without worrying about punctuation.
enddocument

Warning: you can't use any other list environments inside one with the
sentencekey because the redefinition ofitemwill also apply to those and will insert additional semicolons there as well.
(You probably wouldn't want to nest lists inside a running sentence, but if you have to you can addletsentenceitemjoinemptyinside the inner list.)
Remarks
- I didn't include the colon (:) because does not feel like it is a part of the list (and not affected if items are reordered).
If you do want the colon to automatically be inserted you can replace the value ofbefore*above byunskip:sentencelistprep;. If you don't want to have to supply the
sentencekey every time, you can create a custom list environment that includes it with e.g.newlistmyitemizeitemize1
setlist[myitemize]label=textbullet,sentenceThe
beforeandafterkeys overwritesentenceif supplied later, but the converse is not true becausesentenceuses the starred versionsbefore*andafter*.sentencelistprep;, which is called at the start of a list withsentence, does the following: it definessentenceitemjoinasdefsentenceitemjoinunskip;and replacesitemby a version that includessentenceitemjoin.
The firstitemtherefore redefinessentenceitemjointounskip;, and everyitemafter that consequently inserts a;before it.
Addendum
Per your request, here is a way to add “and” to the semicolon in the penultimate item.
I couldn't do this by simply modifying the other solution because an items in a list environment can't really know if it is the final one.
The following works by first scanning the contents of the entire list environment and inserting ;s at the end of every item but the last one, and additionally adding and to the penultimate item. It's a little bit of a hack, but it works. (Unlike with the above version, you can nest another list environment in this one, though it still seems unlikely that you would want to.)
documentclassarticle
usepackageenumitem
usepackageenviron %% <- for Collect@Body
makeatletter %% <- make @ usable in command sequences
SetEnumitemKeysentence% %% <- register key
before*=sentencelist@afterfi,
defsentencelist@afterfi#1fi %% <- insert sentencelist code after fi
#1fiCollect@Bodysentencelist %% <- apply sentencelist to the body of the environment
defsentencelist#1@sentencelist#1item@sentencelist
def@sentencelist#1item#2@sentencelist
#1@@sentencelist#2@@sentencelist %% <- just insert everything up to the first item
def@@sentencelist#1item#2@@sentencelist%
ifrelaxdetokenize#2relax %% <- if last item
if@newlistelse andfi %% <- insert "and" if not also the first item
item #1unskip.% %% <- insert the item and a .
else %% <- otherwise
item #1unskip;% %% <- insert the item and a ;
@@sentencelist#2@@sentencelist %% <- and repeat
fi
makeatother %% <- revert @
begindocument
Here is an textttitemize environment whose items are part of this sentence and therefore come with appropriate punctuation:
beginitemize[sentence]
item a list item that could go first but also last
item another list item that I'm not sure about that is long enough to span two lines
item this one should go last unless I think of another one
enditemize
It's convenient because I can add, remove, and rearrange items without worrying about punctuation.
enddocument
Is there a way to get the "; and" at the end of the penultimate item?
– Dan
yesterday
The answer is of course “yes”, but it won't be a simple modification. I'm usingitemto print the preceding;, but it is impossible to tell if any particularitemis the last one without doing something like countingitems (and storing the result in the aux file) or scanning the contents of the list environment beforehand. I'll get back to you on this (but it may be a while; I'm a little busy atm).
– Circumscribe
yesterday
@Dan: See the addendum to my answer.
– Circumscribe
2 hours ago
add a comment |
Here's a possible solution that works by redefining item.
This may seem a little heavy-handed, but it is also how the itemjoin key for inline lists works.
I'm using SetEnumitemKey to define a new key, sentence, that can be supplied to any list environment that enumitem knows about.
It will append a period (.) to the last item and a semicolon (;) to every other item.
documentclassarticle
usepackageenumitem
SetEnumitemKeysentence%
before*=sentencelistprep;,
after*=unskip.,
letsentenceitemjoinempty
edefsentenceitemnoexpandsentenceitemjoinunexpandedexpandafteritem%
newcommand*sentencelistprep[1]%
defsentenceitemjoindefsentenceitemjoinunskip#1%
letitemsentenceitem
begindocument
Here is an textttitemize environment whose items are part of this sentence and therefore come with appropriate punctuation:
beginitemize[sentence]
item a list item that could go first but also last
item another list item that I'm not sure about that is long enough to span two lines
item this one should go last unless I think of another one
enditemize
It's convenient because I can add, remove, and rearrange items without worrying about punctuation.
enddocument

Warning: you can't use any other list environments inside one with the
sentencekey because the redefinition ofitemwill also apply to those and will insert additional semicolons there as well.
(You probably wouldn't want to nest lists inside a running sentence, but if you have to you can addletsentenceitemjoinemptyinside the inner list.)
Remarks
- I didn't include the colon (:) because does not feel like it is a part of the list (and not affected if items are reordered).
If you do want the colon to automatically be inserted you can replace the value ofbefore*above byunskip:sentencelistprep;. If you don't want to have to supply the
sentencekey every time, you can create a custom list environment that includes it with e.g.newlistmyitemizeitemize1
setlist[myitemize]label=textbullet,sentenceThe
beforeandafterkeys overwritesentenceif supplied later, but the converse is not true becausesentenceuses the starred versionsbefore*andafter*.sentencelistprep;, which is called at the start of a list withsentence, does the following: it definessentenceitemjoinasdefsentenceitemjoinunskip;and replacesitemby a version that includessentenceitemjoin.
The firstitemtherefore redefinessentenceitemjointounskip;, and everyitemafter that consequently inserts a;before it.
Addendum
Per your request, here is a way to add “and” to the semicolon in the penultimate item.
I couldn't do this by simply modifying the other solution because an items in a list environment can't really know if it is the final one.
The following works by first scanning the contents of the entire list environment and inserting ;s at the end of every item but the last one, and additionally adding and to the penultimate item. It's a little bit of a hack, but it works. (Unlike with the above version, you can nest another list environment in this one, though it still seems unlikely that you would want to.)
documentclassarticle
usepackageenumitem
usepackageenviron %% <- for Collect@Body
makeatletter %% <- make @ usable in command sequences
SetEnumitemKeysentence% %% <- register key
before*=sentencelist@afterfi,
defsentencelist@afterfi#1fi %% <- insert sentencelist code after fi
#1fiCollect@Bodysentencelist %% <- apply sentencelist to the body of the environment
defsentencelist#1@sentencelist#1item@sentencelist
def@sentencelist#1item#2@sentencelist
#1@@sentencelist#2@@sentencelist %% <- just insert everything up to the first item
def@@sentencelist#1item#2@@sentencelist%
ifrelaxdetokenize#2relax %% <- if last item
if@newlistelse andfi %% <- insert "and" if not also the first item
item #1unskip.% %% <- insert the item and a .
else %% <- otherwise
item #1unskip;% %% <- insert the item and a ;
@@sentencelist#2@@sentencelist %% <- and repeat
fi
makeatother %% <- revert @
begindocument
Here is an textttitemize environment whose items are part of this sentence and therefore come with appropriate punctuation:
beginitemize[sentence]
item a list item that could go first but also last
item another list item that I'm not sure about that is long enough to span two lines
item this one should go last unless I think of another one
enditemize
It's convenient because I can add, remove, and rearrange items without worrying about punctuation.
enddocument
Is there a way to get the "; and" at the end of the penultimate item?
– Dan
yesterday
The answer is of course “yes”, but it won't be a simple modification. I'm usingitemto print the preceding;, but it is impossible to tell if any particularitemis the last one without doing something like countingitems (and storing the result in the aux file) or scanning the contents of the list environment beforehand. I'll get back to you on this (but it may be a while; I'm a little busy atm).
– Circumscribe
yesterday
@Dan: See the addendum to my answer.
– Circumscribe
2 hours ago
add a comment |
Here's a possible solution that works by redefining item.
This may seem a little heavy-handed, but it is also how the itemjoin key for inline lists works.
I'm using SetEnumitemKey to define a new key, sentence, that can be supplied to any list environment that enumitem knows about.
It will append a period (.) to the last item and a semicolon (;) to every other item.
documentclassarticle
usepackageenumitem
SetEnumitemKeysentence%
before*=sentencelistprep;,
after*=unskip.,
letsentenceitemjoinempty
edefsentenceitemnoexpandsentenceitemjoinunexpandedexpandafteritem%
newcommand*sentencelistprep[1]%
defsentenceitemjoindefsentenceitemjoinunskip#1%
letitemsentenceitem
begindocument
Here is an textttitemize environment whose items are part of this sentence and therefore come with appropriate punctuation:
beginitemize[sentence]
item a list item that could go first but also last
item another list item that I'm not sure about that is long enough to span two lines
item this one should go last unless I think of another one
enditemize
It's convenient because I can add, remove, and rearrange items without worrying about punctuation.
enddocument

Warning: you can't use any other list environments inside one with the
sentencekey because the redefinition ofitemwill also apply to those and will insert additional semicolons there as well.
(You probably wouldn't want to nest lists inside a running sentence, but if you have to you can addletsentenceitemjoinemptyinside the inner list.)
Remarks
- I didn't include the colon (:) because does not feel like it is a part of the list (and not affected if items are reordered).
If you do want the colon to automatically be inserted you can replace the value ofbefore*above byunskip:sentencelistprep;. If you don't want to have to supply the
sentencekey every time, you can create a custom list environment that includes it with e.g.newlistmyitemizeitemize1
setlist[myitemize]label=textbullet,sentenceThe
beforeandafterkeys overwritesentenceif supplied later, but the converse is not true becausesentenceuses the starred versionsbefore*andafter*.sentencelistprep;, which is called at the start of a list withsentence, does the following: it definessentenceitemjoinasdefsentenceitemjoinunskip;and replacesitemby a version that includessentenceitemjoin.
The firstitemtherefore redefinessentenceitemjointounskip;, and everyitemafter that consequently inserts a;before it.
Addendum
Per your request, here is a way to add “and” to the semicolon in the penultimate item.
I couldn't do this by simply modifying the other solution because an items in a list environment can't really know if it is the final one.
The following works by first scanning the contents of the entire list environment and inserting ;s at the end of every item but the last one, and additionally adding and to the penultimate item. It's a little bit of a hack, but it works. (Unlike with the above version, you can nest another list environment in this one, though it still seems unlikely that you would want to.)
documentclassarticle
usepackageenumitem
usepackageenviron %% <- for Collect@Body
makeatletter %% <- make @ usable in command sequences
SetEnumitemKeysentence% %% <- register key
before*=sentencelist@afterfi,
defsentencelist@afterfi#1fi %% <- insert sentencelist code after fi
#1fiCollect@Bodysentencelist %% <- apply sentencelist to the body of the environment
defsentencelist#1@sentencelist#1item@sentencelist
def@sentencelist#1item#2@sentencelist
#1@@sentencelist#2@@sentencelist %% <- just insert everything up to the first item
def@@sentencelist#1item#2@@sentencelist%
ifrelaxdetokenize#2relax %% <- if last item
if@newlistelse andfi %% <- insert "and" if not also the first item
item #1unskip.% %% <- insert the item and a .
else %% <- otherwise
item #1unskip;% %% <- insert the item and a ;
@@sentencelist#2@@sentencelist %% <- and repeat
fi
makeatother %% <- revert @
begindocument
Here is an textttitemize environment whose items are part of this sentence and therefore come with appropriate punctuation:
beginitemize[sentence]
item a list item that could go first but also last
item another list item that I'm not sure about that is long enough to span two lines
item this one should go last unless I think of another one
enditemize
It's convenient because I can add, remove, and rearrange items without worrying about punctuation.
enddocument
Here's a possible solution that works by redefining item.
This may seem a little heavy-handed, but it is also how the itemjoin key for inline lists works.
I'm using SetEnumitemKey to define a new key, sentence, that can be supplied to any list environment that enumitem knows about.
It will append a period (.) to the last item and a semicolon (;) to every other item.
documentclassarticle
usepackageenumitem
SetEnumitemKeysentence%
before*=sentencelistprep;,
after*=unskip.,
letsentenceitemjoinempty
edefsentenceitemnoexpandsentenceitemjoinunexpandedexpandafteritem%
newcommand*sentencelistprep[1]%
defsentenceitemjoindefsentenceitemjoinunskip#1%
letitemsentenceitem
begindocument
Here is an textttitemize environment whose items are part of this sentence and therefore come with appropriate punctuation:
beginitemize[sentence]
item a list item that could go first but also last
item another list item that I'm not sure about that is long enough to span two lines
item this one should go last unless I think of another one
enditemize
It's convenient because I can add, remove, and rearrange items without worrying about punctuation.
enddocument

Warning: you can't use any other list environments inside one with the
sentencekey because the redefinition ofitemwill also apply to those and will insert additional semicolons there as well.
(You probably wouldn't want to nest lists inside a running sentence, but if you have to you can addletsentenceitemjoinemptyinside the inner list.)
Remarks
- I didn't include the colon (:) because does not feel like it is a part of the list (and not affected if items are reordered).
If you do want the colon to automatically be inserted you can replace the value ofbefore*above byunskip:sentencelistprep;. If you don't want to have to supply the
sentencekey every time, you can create a custom list environment that includes it with e.g.newlistmyitemizeitemize1
setlist[myitemize]label=textbullet,sentenceThe
beforeandafterkeys overwritesentenceif supplied later, but the converse is not true becausesentenceuses the starred versionsbefore*andafter*.sentencelistprep;, which is called at the start of a list withsentence, does the following: it definessentenceitemjoinasdefsentenceitemjoinunskip;and replacesitemby a version that includessentenceitemjoin.
The firstitemtherefore redefinessentenceitemjointounskip;, and everyitemafter that consequently inserts a;before it.
Addendum
Per your request, here is a way to add “and” to the semicolon in the penultimate item.
I couldn't do this by simply modifying the other solution because an items in a list environment can't really know if it is the final one.
The following works by first scanning the contents of the entire list environment and inserting ;s at the end of every item but the last one, and additionally adding and to the penultimate item. It's a little bit of a hack, but it works. (Unlike with the above version, you can nest another list environment in this one, though it still seems unlikely that you would want to.)
documentclassarticle
usepackageenumitem
usepackageenviron %% <- for Collect@Body
makeatletter %% <- make @ usable in command sequences
SetEnumitemKeysentence% %% <- register key
before*=sentencelist@afterfi,
defsentencelist@afterfi#1fi %% <- insert sentencelist code after fi
#1fiCollect@Bodysentencelist %% <- apply sentencelist to the body of the environment
defsentencelist#1@sentencelist#1item@sentencelist
def@sentencelist#1item#2@sentencelist
#1@@sentencelist#2@@sentencelist %% <- just insert everything up to the first item
def@@sentencelist#1item#2@@sentencelist%
ifrelaxdetokenize#2relax %% <- if last item
if@newlistelse andfi %% <- insert "and" if not also the first item
item #1unskip.% %% <- insert the item and a .
else %% <- otherwise
item #1unskip;% %% <- insert the item and a ;
@@sentencelist#2@@sentencelist %% <- and repeat
fi
makeatother %% <- revert @
begindocument
Here is an textttitemize environment whose items are part of this sentence and therefore come with appropriate punctuation:
beginitemize[sentence]
item a list item that could go first but also last
item another list item that I'm not sure about that is long enough to span two lines
item this one should go last unless I think of another one
enditemize
It's convenient because I can add, remove, and rearrange items without worrying about punctuation.
enddocument
edited 2 hours ago
answered Jan 30 at 23:44
CircumscribeCircumscribe
7,25121441
7,25121441
Is there a way to get the "; and" at the end of the penultimate item?
– Dan
yesterday
The answer is of course “yes”, but it won't be a simple modification. I'm usingitemto print the preceding;, but it is impossible to tell if any particularitemis the last one without doing something like countingitems (and storing the result in the aux file) or scanning the contents of the list environment beforehand. I'll get back to you on this (but it may be a while; I'm a little busy atm).
– Circumscribe
yesterday
@Dan: See the addendum to my answer.
– Circumscribe
2 hours ago
add a comment |
Is there a way to get the "; and" at the end of the penultimate item?
– Dan
yesterday
The answer is of course “yes”, but it won't be a simple modification. I'm usingitemto print the preceding;, but it is impossible to tell if any particularitemis the last one without doing something like countingitems (and storing the result in the aux file) or scanning the contents of the list environment beforehand. I'll get back to you on this (but it may be a while; I'm a little busy atm).
– Circumscribe
yesterday
@Dan: See the addendum to my answer.
– Circumscribe
2 hours ago
Is there a way to get the "; and" at the end of the penultimate item?
– Dan
yesterday
Is there a way to get the "; and" at the end of the penultimate item?
– Dan
yesterday
The answer is of course “yes”, but it won't be a simple modification. I'm using
item to print the preceding ;, but it is impossible to tell if any particular item is the last one without doing something like counting items (and storing the result in the aux file) or scanning the contents of the list environment beforehand. I'll get back to you on this (but it may be a while; I'm a little busy atm).– Circumscribe
yesterday
The answer is of course “yes”, but it won't be a simple modification. I'm using
item to print the preceding ;, but it is impossible to tell if any particular item is the last one without doing something like counting items (and storing the result in the aux file) or scanning the contents of the list environment beforehand. I'll get back to you on this (but it may be a while; I'm a little busy atm).– Circumscribe
yesterday
@Dan: See the addendum to my answer.
– Circumscribe
2 hours ago
@Dan: See the addendum to my answer.
– Circumscribe
2 hours ago
add a comment |
Here is a version that sort of reproduces a display itemize allowing for the features of an itemize*. Below is the same content using inlineitem (provided in question), displayitem and a regular itemize for comparison purposes:

Notes:
The color red has been added to make it easier to compare the three versions. You can replace the definition of
Showwithnewcommand*Show[1]#1to eliminate the highlighting or simply remove all references to the
Showmacro.The "sort of" is because I wasn't able to get the vertical spacing of the very first item to match what
itemizeyields.
Code:
documentclassarticle
usepackageenumitem
usepackagexcolor
newcommand*NextLine%
newline
vspace*0.5baselineskip%
hspace*dimexprlabelindent+labelwidth-labelseprelax%
%
newcommand*Show[1]textcolorredbfseries#1% Make it easier to see difference
newlistinlineitemitemize*1
setlist[inlineitem] % Customize itemize* environ
before=unskipShow:, % Colon before list
itemjoin=Show;, % Join with semicolons
itemjoin*=Show; and, % Last join has "; and "
label=, % No label
after=., % Period at end of last item
newlistdisplayitemitemize*1
setlist[displayitem] % Customize itemize* environ
before=unskipShow:NextLine, % Colon before list
itemjoin=Show;NextLine, % Join with semicolons
itemjoin*=Show; andNextLine, % Last join has "; and "
label=$bullet$, % Label
after=unskipShow.endgrafnoindent, % Period at end of last item
pagecolorwhite
begindocument
noindent
Here is some text in a verb|inlineitem|
begininlineitem
item a list item that could go first but also last
item another list item that I'm not sure about
item this one should go last unless I think of another one
endinlineitem
Some text after verb|inlineitem|.
bigskip
noindent
Here is the same text in a verb|displayitem|
begindisplayitem
item a list item that could go first but also last
item another list item that I'm not sure about
item this one should go last unless I think of another one
enddisplayitem
Some text after verb|displayitem|.
bigskip
noindent
Here is the same text in an verb|itemize|
beginitemize
item a list item that could go first but also last
item another list item that I'm not sure about
item this one should go last unless I think of another one
enditemize
Some text after regular verb|itemize|.
enddocument
add a comment |
Here is a version that sort of reproduces a display itemize allowing for the features of an itemize*. Below is the same content using inlineitem (provided in question), displayitem and a regular itemize for comparison purposes:

Notes:
The color red has been added to make it easier to compare the three versions. You can replace the definition of
Showwithnewcommand*Show[1]#1to eliminate the highlighting or simply remove all references to the
Showmacro.The "sort of" is because I wasn't able to get the vertical spacing of the very first item to match what
itemizeyields.
Code:
documentclassarticle
usepackageenumitem
usepackagexcolor
newcommand*NextLine%
newline
vspace*0.5baselineskip%
hspace*dimexprlabelindent+labelwidth-labelseprelax%
%
newcommand*Show[1]textcolorredbfseries#1% Make it easier to see difference
newlistinlineitemitemize*1
setlist[inlineitem] % Customize itemize* environ
before=unskipShow:, % Colon before list
itemjoin=Show;, % Join with semicolons
itemjoin*=Show; and, % Last join has "; and "
label=, % No label
after=., % Period at end of last item
newlistdisplayitemitemize*1
setlist[displayitem] % Customize itemize* environ
before=unskipShow:NextLine, % Colon before list
itemjoin=Show;NextLine, % Join with semicolons
itemjoin*=Show; andNextLine, % Last join has "; and "
label=$bullet$, % Label
after=unskipShow.endgrafnoindent, % Period at end of last item
pagecolorwhite
begindocument
noindent
Here is some text in a verb|inlineitem|
begininlineitem
item a list item that could go first but also last
item another list item that I'm not sure about
item this one should go last unless I think of another one
endinlineitem
Some text after verb|inlineitem|.
bigskip
noindent
Here is the same text in a verb|displayitem|
begindisplayitem
item a list item that could go first but also last
item another list item that I'm not sure about
item this one should go last unless I think of another one
enddisplayitem
Some text after verb|displayitem|.
bigskip
noindent
Here is the same text in an verb|itemize|
beginitemize
item a list item that could go first but also last
item another list item that I'm not sure about
item this one should go last unless I think of another one
enditemize
Some text after regular verb|itemize|.
enddocument
add a comment |
Here is a version that sort of reproduces a display itemize allowing for the features of an itemize*. Below is the same content using inlineitem (provided in question), displayitem and a regular itemize for comparison purposes:

Notes:
The color red has been added to make it easier to compare the three versions. You can replace the definition of
Showwithnewcommand*Show[1]#1to eliminate the highlighting or simply remove all references to the
Showmacro.The "sort of" is because I wasn't able to get the vertical spacing of the very first item to match what
itemizeyields.
Code:
documentclassarticle
usepackageenumitem
usepackagexcolor
newcommand*NextLine%
newline
vspace*0.5baselineskip%
hspace*dimexprlabelindent+labelwidth-labelseprelax%
%
newcommand*Show[1]textcolorredbfseries#1% Make it easier to see difference
newlistinlineitemitemize*1
setlist[inlineitem] % Customize itemize* environ
before=unskipShow:, % Colon before list
itemjoin=Show;, % Join with semicolons
itemjoin*=Show; and, % Last join has "; and "
label=, % No label
after=., % Period at end of last item
newlistdisplayitemitemize*1
setlist[displayitem] % Customize itemize* environ
before=unskipShow:NextLine, % Colon before list
itemjoin=Show;NextLine, % Join with semicolons
itemjoin*=Show; andNextLine, % Last join has "; and "
label=$bullet$, % Label
after=unskipShow.endgrafnoindent, % Period at end of last item
pagecolorwhite
begindocument
noindent
Here is some text in a verb|inlineitem|
begininlineitem
item a list item that could go first but also last
item another list item that I'm not sure about
item this one should go last unless I think of another one
endinlineitem
Some text after verb|inlineitem|.
bigskip
noindent
Here is the same text in a verb|displayitem|
begindisplayitem
item a list item that could go first but also last
item another list item that I'm not sure about
item this one should go last unless I think of another one
enddisplayitem
Some text after verb|displayitem|.
bigskip
noindent
Here is the same text in an verb|itemize|
beginitemize
item a list item that could go first but also last
item another list item that I'm not sure about
item this one should go last unless I think of another one
enditemize
Some text after regular verb|itemize|.
enddocument
Here is a version that sort of reproduces a display itemize allowing for the features of an itemize*. Below is the same content using inlineitem (provided in question), displayitem and a regular itemize for comparison purposes:

Notes:
The color red has been added to make it easier to compare the three versions. You can replace the definition of
Showwithnewcommand*Show[1]#1to eliminate the highlighting or simply remove all references to the
Showmacro.The "sort of" is because I wasn't able to get the vertical spacing of the very first item to match what
itemizeyields.
Code:
documentclassarticle
usepackageenumitem
usepackagexcolor
newcommand*NextLine%
newline
vspace*0.5baselineskip%
hspace*dimexprlabelindent+labelwidth-labelseprelax%
%
newcommand*Show[1]textcolorredbfseries#1% Make it easier to see difference
newlistinlineitemitemize*1
setlist[inlineitem] % Customize itemize* environ
before=unskipShow:, % Colon before list
itemjoin=Show;, % Join with semicolons
itemjoin*=Show; and, % Last join has "; and "
label=, % No label
after=., % Period at end of last item
newlistdisplayitemitemize*1
setlist[displayitem] % Customize itemize* environ
before=unskipShow:NextLine, % Colon before list
itemjoin=Show;NextLine, % Join with semicolons
itemjoin*=Show; andNextLine, % Last join has "; and "
label=$bullet$, % Label
after=unskipShow.endgrafnoindent, % Period at end of last item
pagecolorwhite
begindocument
noindent
Here is some text in a verb|inlineitem|
begininlineitem
item a list item that could go first but also last
item another list item that I'm not sure about
item this one should go last unless I think of another one
endinlineitem
Some text after verb|inlineitem|.
bigskip
noindent
Here is the same text in a verb|displayitem|
begindisplayitem
item a list item that could go first but also last
item another list item that I'm not sure about
item this one should go last unless I think of another one
enddisplayitem
Some text after verb|displayitem|.
bigskip
noindent
Here is the same text in an verb|itemize|
beginitemize
item a list item that could go first but also last
item another list item that I'm not sure about
item this one should go last unless I think of another one
enditemize
Some text after regular verb|itemize|.
enddocument
answered Jan 30 at 21:47
Peter GrillPeter Grill
166k25441756
166k25441756
add a comment |
add a comment |
Thanks for contributing an answer to TeX - LaTeX Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f450715%2fvertical-list-customization-like-enumitems-itemjoin%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
What does "the same thing" mean? Have you tried
label=; and?– Andrew
Sep 13 '18 at 14:39
1
@Andrew "the same thing" means automatically adding
beforebefore the list,itemjointo the end of every item in the list except the penultimate and last ones,itemjoin*to the penultimate item, andafterto the last item. Usinglabel=; andchanges the label of every item to be; and, which is definitely not the effect I'm going for.– Dan
Sep 14 '18 at 7:39
I'm reminded this bounty needs to be allocated soon, so just a reminder to raise any concerns with either answer before I have to make a decision.
– KJO
Feb 3 at 17:44