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













7















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


enter image description here



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.










share|improve this question






















  • 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 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















7















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


enter image description here



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.










share|improve this question






















  • 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 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













7












7








7








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


enter image description here



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.










share|improve this question














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


enter image description here



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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Sep 13 '18 at 12:38









DanDan

1625




1625












  • 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 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

















  • 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 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
















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










2 Answers
2






active

oldest

votes


















3





+50









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


output




Warning: you can't use any other list environments inside one with the sentence key because the redefinition of item will 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 add letsentenceitemjoinempty inside 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 of before* above by unskip:sentencelistprep;.


  • If you don't want to have to supply the sentence key every time, you can create a custom list environment that includes it with e.g.



    newlistmyitemizeitemize1
    setlist[myitemize]label=textbullet,sentence


  • The before and after keys overwrite sentence if supplied later, but the converse is not true because sentence uses the starred versions before* and after*.


  • sentencelistprep;, which is called at the start of a list with sentence, does the following: it defines sentenceitemjoin asdefsentenceitemjoinunskip; and replaces item by a version that includes sentenceitemjoin.
    The first item therefore redefines sentenceitemjoin to unskip;, and every item after 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





share|improve this answer

























  • 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












  • @Dan: See the addendum to my answer.

    – Circumscribe
    2 hours ago


















6














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:



enter image description here



Notes:




  • The color red has been added to make it easier to compare the three versions. You can replace the definition of Show with



    newcommand*Show[1]#1


    to eliminate the highlighting or simply remove all references to the Show macro.



  • The "sort of" is because I wasn't able to get the vertical spacing of the very first item to match what itemize yields.


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





share|improve this answer






















    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
    );



    );













    draft saved

    draft discarded


















    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









    3





    +50









    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


    output




    Warning: you can't use any other list environments inside one with the sentence key because the redefinition of item will 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 add letsentenceitemjoinempty inside 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 of before* above by unskip:sentencelistprep;.


    • If you don't want to have to supply the sentence key every time, you can create a custom list environment that includes it with e.g.



      newlistmyitemizeitemize1
      setlist[myitemize]label=textbullet,sentence


    • The before and after keys overwrite sentence if supplied later, but the converse is not true because sentence uses the starred versions before* and after*.


    • sentencelistprep;, which is called at the start of a list with sentence, does the following: it defines sentenceitemjoin asdefsentenceitemjoinunskip; and replaces item by a version that includes sentenceitemjoin.
      The first item therefore redefines sentenceitemjoin to unskip;, and every item after 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





    share|improve this answer

























    • 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












    • @Dan: See the addendum to my answer.

      – Circumscribe
      2 hours ago















    3





    +50









    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


    output




    Warning: you can't use any other list environments inside one with the sentence key because the redefinition of item will 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 add letsentenceitemjoinempty inside 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 of before* above by unskip:sentencelistprep;.


    • If you don't want to have to supply the sentence key every time, you can create a custom list environment that includes it with e.g.



      newlistmyitemizeitemize1
      setlist[myitemize]label=textbullet,sentence


    • The before and after keys overwrite sentence if supplied later, but the converse is not true because sentence uses the starred versions before* and after*.


    • sentencelistprep;, which is called at the start of a list with sentence, does the following: it defines sentenceitemjoin asdefsentenceitemjoinunskip; and replaces item by a version that includes sentenceitemjoin.
      The first item therefore redefines sentenceitemjoin to unskip;, and every item after 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





    share|improve this answer

























    • 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












    • @Dan: See the addendum to my answer.

      – Circumscribe
      2 hours ago













    3





    +50







    3





    +50



    3




    +50





    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


    output




    Warning: you can't use any other list environments inside one with the sentence key because the redefinition of item will 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 add letsentenceitemjoinempty inside 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 of before* above by unskip:sentencelistprep;.


    • If you don't want to have to supply the sentence key every time, you can create a custom list environment that includes it with e.g.



      newlistmyitemizeitemize1
      setlist[myitemize]label=textbullet,sentence


    • The before and after keys overwrite sentence if supplied later, but the converse is not true because sentence uses the starred versions before* and after*.


    • sentencelistprep;, which is called at the start of a list with sentence, does the following: it defines sentenceitemjoin asdefsentenceitemjoinunskip; and replaces item by a version that includes sentenceitemjoin.
      The first item therefore redefines sentenceitemjoin to unskip;, and every item after 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





    share|improve this answer















    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


    output




    Warning: you can't use any other list environments inside one with the sentence key because the redefinition of item will 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 add letsentenceitemjoinempty inside 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 of before* above by unskip:sentencelistprep;.


    • If you don't want to have to supply the sentence key every time, you can create a custom list environment that includes it with e.g.



      newlistmyitemizeitemize1
      setlist[myitemize]label=textbullet,sentence


    • The before and after keys overwrite sentence if supplied later, but the converse is not true because sentence uses the starred versions before* and after*.


    • sentencelistprep;, which is called at the start of a list with sentence, does the following: it defines sentenceitemjoin asdefsentenceitemjoinunskip; and replaces item by a version that includes sentenceitemjoin.
      The first item therefore redefines sentenceitemjoin to unskip;, and every item after 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






    share|improve this answer














    share|improve this answer



    share|improve this answer








    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 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

















    • 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












    • @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











    6














    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:



    enter image description here



    Notes:




    • The color red has been added to make it easier to compare the three versions. You can replace the definition of Show with



      newcommand*Show[1]#1


      to eliminate the highlighting or simply remove all references to the Show macro.



    • The "sort of" is because I wasn't able to get the vertical spacing of the very first item to match what itemize yields.


    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





    share|improve this answer



























      6














      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:



      enter image description here



      Notes:




      • The color red has been added to make it easier to compare the three versions. You can replace the definition of Show with



        newcommand*Show[1]#1


        to eliminate the highlighting or simply remove all references to the Show macro.



      • The "sort of" is because I wasn't able to get the vertical spacing of the very first item to match what itemize yields.


      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





      share|improve this answer

























        6












        6








        6







        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:



        enter image description here



        Notes:




        • The color red has been added to make it easier to compare the three versions. You can replace the definition of Show with



          newcommand*Show[1]#1


          to eliminate the highlighting or simply remove all references to the Show macro.



        • The "sort of" is because I wasn't able to get the vertical spacing of the very first item to match what itemize yields.


        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





        share|improve this answer













        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:



        enter image description here



        Notes:




        • The color red has been added to make it easier to compare the three versions. You can replace the definition of Show with



          newcommand*Show[1]#1


          to eliminate the highlighting or simply remove all references to the Show macro.



        • The "sort of" is because I wasn't able to get the vertical spacing of the very first item to match what itemize yields.


        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






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jan 30 at 21:47









        Peter GrillPeter Grill

        166k25441756




        166k25441756



























            draft saved

            draft discarded
















































            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.




            draft saved


            draft discarded














            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





















































            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







            Popular posts from this blog

            Isabella Eugénie Boyer Biographie | Références | Menu de navigationmodifiermodifier le codeComparator to Compute the Relative Value of a U.S. Dollar Amount – 1774 to Present.

            Join wedge with single bond in chemfigHow to make only one part of double bond bold with chemfig?Crossing bonds in chemfigjoining atoms in chemfig. Two adjacent molculesHow do I selectively change bond length in chemfig?Ugly bond joints in chemfigchemfig: reaction above arrowUsing the mhchem and chemfig packages in conjunctionBonding to specific element letter using chemfigResonance hybrids in chemfigScale chemfig molecule in beamer with tikzWhy does this chemfig bond with a hook start in the middle of the atom?

            Should we avoid writing fiction about historical events without extensive research?How do we write a story about genocide committed by a fascist government without falling into the “Nazi Germany” cliché?Researching sensitive subjectsShould I avoid “lecturing” my readers?Archetypical/popular historical fictionHow to write a “strong” passage?Will what worked 'back then' work today? (Novels)Historical Fiction: using you and thouHow do you make characters relatable if they exist in a completely different moral context?How do I write a MODERN combat/violence scene without being dry?Fictionizing firsthand accounts from history?Is it possible to narrate a novel in a faux-historical style without alienating the reader?