Automatically end list item with proper punctuation (semicolon, period)List separated by semicolons, ending...
Supervisor wants me to support a diploma-thesis SW tool after I graduated
Bacteria vats to generate edible biomass, require intermediary species?
Do aarakocra have arms as well as wings?
Why can't some airports handle heavy aircraft while others do it easily (same runway length)?
Why does low tire pressure decrease fuel economy?
I won a car in a poker game. How is that taxed in Canada?
Furthest distance half the diameter?
Word for something that used to be popular but not anymore
The meaning of "offing" in "an agreement in the offing"
How to run NPCs with complicated mechanics?
Should I tip on the Amtrak train?
What is the purpose of the rotating plate in front of the lock?
Are professors obligated to accept supervisory role? If not, how does it work?
Complex conjugate and transpose "with respect to a basis"
Contour plot of a sequence of spheres with increasing radius
Why are some hotels asking you to book through Booking.com instead of matching the price at the front desk?
Why is infinite intersection "towards infinity" an empty set?
Poor management handling of recent sickness and how to approach my return?
How can I hint that my character isn't real?
Bit floating sequence
Why is it that I have to play this note on the piano as A sharp?
How strong is aircraft-grade spruce?
Leaving the USA for 10 yrs when you have asylum
I multiply the source, you (probably) multiply the output!
Automatically end list item with proper punctuation (semicolon, period)
List separated by semicolons, ending with a periodEnumerate and itemize undefined + captions not workingaligning a multiline formula with the bullet of itemizeItem displayed twice in beamer itemizeSplit itemize into multiple columnsHow to achieve multicolumn item lists with independent content?possible memoir bug with font sizes and tightlistsFinishing math with a periodIndentation of new list levels with enumitemChecking if current item is last item inside enumerated list
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
If I have a list using itemize
, I want to automatically end each item
with a semicolon (for all but the last item) or a period (for the last item).
For example:
begin{itemize}
item One
item Two
item Three
end{itemize}
Should display as
- One;
- Two;
- Three.
Is there any way to make that happen? I looked around but didn't really find anything. The closest I could find was this, but that seems to be a fancy, custom list rather than a vanilla itemize
.
lists itemize punctuation
New contributor
add a comment |
If I have a list using itemize
, I want to automatically end each item
with a semicolon (for all but the last item) or a period (for the last item).
For example:
begin{itemize}
item One
item Two
item Three
end{itemize}
Should display as
- One;
- Two;
- Three.
Is there any way to make that happen? I looked around but didn't really find anything. The closest I could find was this, but that seems to be a fancy, custom list rather than a vanilla itemize
.
lists itemize punctuation
New contributor
add a comment |
If I have a list using itemize
, I want to automatically end each item
with a semicolon (for all but the last item) or a period (for the last item).
For example:
begin{itemize}
item One
item Two
item Three
end{itemize}
Should display as
- One;
- Two;
- Three.
Is there any way to make that happen? I looked around but didn't really find anything. The closest I could find was this, but that seems to be a fancy, custom list rather than a vanilla itemize
.
lists itemize punctuation
New contributor
If I have a list using itemize
, I want to automatically end each item
with a semicolon (for all but the last item) or a period (for the last item).
For example:
begin{itemize}
item One
item Two
item Three
end{itemize}
Should display as
- One;
- Two;
- Three.
Is there any way to make that happen? I looked around but didn't really find anything. The closest I could find was this, but that seems to be a fancy, custom list rather than a vanilla itemize
.
lists itemize punctuation
lists itemize punctuation
New contributor
New contributor
edited 8 hours ago
Bernard
190k7 gold badges86 silver badges225 bronze badges
190k7 gold badges86 silver badges225 bronze badges
New contributor
asked 8 hours ago
MarcelMarcel
1134 bronze badges
1134 bronze badges
New contributor
New contributor
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
I'm not sure whether it is a good idea to do this, maybe you should use a different environment for that. The following patches item
inside every itemize
environment to add a semicolon after the first, and the enditemize
macro is changed to add a dot. You can no longer nest itemize
environments with this simple approach. All in all I think this creates more problems than it solves...
documentclass[]{article}
usepackage{etoolbox}
AtBeginEnvironment{itemize}
{%
defitemizepunctuation{defitemizepunctuation{ifhmodeunskipfi;}}%
pretocmditem{itemizepunctuation}{}{}%
pretocmdenditemize{ifhmodeunskipfi.}{}{}%
}
newenvironment{punctitemize}
{%
itemize
defitemizepunctuation{defitemizepunctuation{ifhmodeunskipfi;}}%
pretocmditem{itemizepunctuation}{}{}%
pretocmdenditemize{ifhmodeunskipfi.}{}{}%
}
{%
enditemize
}
begin{document}
begin{itemize}
item One
item Two
item Three
end{itemize}
begin{punctitemize}
item One
item Two
item Three
end{punctitemize}
end{document}
EDIT: added the environment approach, nesting is still not supported.
Thanks for the answer. When you say use a different environment, do you mean add a newpunctuateditemize
(for example) rather than overriding the defaultitemize
? If so, could you give an example of what this would look like?
– Marcel
8 hours ago
@Marcel see my edit.
– Skillmon
8 hours ago
Thanks for the edit. I am nitpicking now, but if I have a newline in theitem
, the semicolon / period is on its own line. I don't suppose there is any way to fix that?
– Marcel
7 hours ago
Actually, it looks like that happens if there is a newline in theitemize
.
– Marcel
7 hours ago
1
@Skillmon Probably Marcel is referring to a blank line between items. Try it.
– egreg
5 hours ago
|
show 1 more comment
You can use xparse
, absorbing the whole contents and splitting it at item
; then add a semicolon (and the removed item
) between items.
The processing is complicated by the fact that a blank line between items would introduce a spurious paragraph before the semicolon or the final period, so we need to remove blanks and par
tokens at the end of each item.
Thus the sequence obtained by splitting at item
is mapped to “purify” it.
I added enumitem
for maximum flexibility.
documentclass{article}
usepackage{xparse}
usepackage{enumitem}
ExplSyntaxOn
NewDocumentEnvironment{autoitemize}{O{} +b}
{
begin{itemize}[#1]
marcel_autoitemize:n { #2 }
end{itemize}
}{}
seq_new:N l__marcel_autoitemize_items_seq
seq_new:N l__marcel_autoitemize_items_nopar_seq
tl_new:N l__marcel_autoitemize_item_tl
cs_new_protected:Nn marcel_autoitemize:n
{
% split the contents at item; this also removes blanks at either end
seq_set_split:Nnn l__marcel_autoitemize_items_seq { item } { #1 }
% remove the first (empty) item
seq_pop_left:NN l__marcel_autoitemize_items_seq l_tmpa_tl
% we need to remove trailing par tokens
seq_clear:N l__marcel_autoitemize_items_nopar_seq
seq_map_function:NN l__marcel_autoitemize_items_seq __marcel_autoitemize_purify:n
% start the first item
item
% use the sequence, putting a semicolon and item between items
seq_use:Nn l__marcel_autoitemize_items_nopar_seq { ; item }
% end up with a period
.
}
cs_new_protected:Nn __marcel_autoitemize_purify:n
{
tl_set:Nn l__marcel_autoitemize_item_tl { #1 }
regex_replace_once:nnN { s* c{par}* Z } { } l__marcel_autoitemize_item_tl
seq_put_right:NV l__marcel_autoitemize_items_nopar_seq l__marcel_autoitemize_item_tl
}
ExplSyntaxOff
begin{document}
begin{autoitemize}
item One
item Two
item Three
end{autoitemize}
begin{autoitemize}[label=--]
item One
item Two
item Three
end{autoitemize}
end{document}
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/4.0/"u003ecc by-sa 4.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
});
}
});
Marcel is a new contributor. Be nice, and check out our Code of Conduct.
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%2f507406%2fautomatically-end-list-item-with-proper-punctuation-semicolon-period%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
I'm not sure whether it is a good idea to do this, maybe you should use a different environment for that. The following patches item
inside every itemize
environment to add a semicolon after the first, and the enditemize
macro is changed to add a dot. You can no longer nest itemize
environments with this simple approach. All in all I think this creates more problems than it solves...
documentclass[]{article}
usepackage{etoolbox}
AtBeginEnvironment{itemize}
{%
defitemizepunctuation{defitemizepunctuation{ifhmodeunskipfi;}}%
pretocmditem{itemizepunctuation}{}{}%
pretocmdenditemize{ifhmodeunskipfi.}{}{}%
}
newenvironment{punctitemize}
{%
itemize
defitemizepunctuation{defitemizepunctuation{ifhmodeunskipfi;}}%
pretocmditem{itemizepunctuation}{}{}%
pretocmdenditemize{ifhmodeunskipfi.}{}{}%
}
{%
enditemize
}
begin{document}
begin{itemize}
item One
item Two
item Three
end{itemize}
begin{punctitemize}
item One
item Two
item Three
end{punctitemize}
end{document}
EDIT: added the environment approach, nesting is still not supported.
Thanks for the answer. When you say use a different environment, do you mean add a newpunctuateditemize
(for example) rather than overriding the defaultitemize
? If so, could you give an example of what this would look like?
– Marcel
8 hours ago
@Marcel see my edit.
– Skillmon
8 hours ago
Thanks for the edit. I am nitpicking now, but if I have a newline in theitem
, the semicolon / period is on its own line. I don't suppose there is any way to fix that?
– Marcel
7 hours ago
Actually, it looks like that happens if there is a newline in theitemize
.
– Marcel
7 hours ago
1
@Skillmon Probably Marcel is referring to a blank line between items. Try it.
– egreg
5 hours ago
|
show 1 more comment
I'm not sure whether it is a good idea to do this, maybe you should use a different environment for that. The following patches item
inside every itemize
environment to add a semicolon after the first, and the enditemize
macro is changed to add a dot. You can no longer nest itemize
environments with this simple approach. All in all I think this creates more problems than it solves...
documentclass[]{article}
usepackage{etoolbox}
AtBeginEnvironment{itemize}
{%
defitemizepunctuation{defitemizepunctuation{ifhmodeunskipfi;}}%
pretocmditem{itemizepunctuation}{}{}%
pretocmdenditemize{ifhmodeunskipfi.}{}{}%
}
newenvironment{punctitemize}
{%
itemize
defitemizepunctuation{defitemizepunctuation{ifhmodeunskipfi;}}%
pretocmditem{itemizepunctuation}{}{}%
pretocmdenditemize{ifhmodeunskipfi.}{}{}%
}
{%
enditemize
}
begin{document}
begin{itemize}
item One
item Two
item Three
end{itemize}
begin{punctitemize}
item One
item Two
item Three
end{punctitemize}
end{document}
EDIT: added the environment approach, nesting is still not supported.
Thanks for the answer. When you say use a different environment, do you mean add a newpunctuateditemize
(for example) rather than overriding the defaultitemize
? If so, could you give an example of what this would look like?
– Marcel
8 hours ago
@Marcel see my edit.
– Skillmon
8 hours ago
Thanks for the edit. I am nitpicking now, but if I have a newline in theitem
, the semicolon / period is on its own line. I don't suppose there is any way to fix that?
– Marcel
7 hours ago
Actually, it looks like that happens if there is a newline in theitemize
.
– Marcel
7 hours ago
1
@Skillmon Probably Marcel is referring to a blank line between items. Try it.
– egreg
5 hours ago
|
show 1 more comment
I'm not sure whether it is a good idea to do this, maybe you should use a different environment for that. The following patches item
inside every itemize
environment to add a semicolon after the first, and the enditemize
macro is changed to add a dot. You can no longer nest itemize
environments with this simple approach. All in all I think this creates more problems than it solves...
documentclass[]{article}
usepackage{etoolbox}
AtBeginEnvironment{itemize}
{%
defitemizepunctuation{defitemizepunctuation{ifhmodeunskipfi;}}%
pretocmditem{itemizepunctuation}{}{}%
pretocmdenditemize{ifhmodeunskipfi.}{}{}%
}
newenvironment{punctitemize}
{%
itemize
defitemizepunctuation{defitemizepunctuation{ifhmodeunskipfi;}}%
pretocmditem{itemizepunctuation}{}{}%
pretocmdenditemize{ifhmodeunskipfi.}{}{}%
}
{%
enditemize
}
begin{document}
begin{itemize}
item One
item Two
item Three
end{itemize}
begin{punctitemize}
item One
item Two
item Three
end{punctitemize}
end{document}
EDIT: added the environment approach, nesting is still not supported.
I'm not sure whether it is a good idea to do this, maybe you should use a different environment for that. The following patches item
inside every itemize
environment to add a semicolon after the first, and the enditemize
macro is changed to add a dot. You can no longer nest itemize
environments with this simple approach. All in all I think this creates more problems than it solves...
documentclass[]{article}
usepackage{etoolbox}
AtBeginEnvironment{itemize}
{%
defitemizepunctuation{defitemizepunctuation{ifhmodeunskipfi;}}%
pretocmditem{itemizepunctuation}{}{}%
pretocmdenditemize{ifhmodeunskipfi.}{}{}%
}
newenvironment{punctitemize}
{%
itemize
defitemizepunctuation{defitemizepunctuation{ifhmodeunskipfi;}}%
pretocmditem{itemizepunctuation}{}{}%
pretocmdenditemize{ifhmodeunskipfi.}{}{}%
}
{%
enditemize
}
begin{document}
begin{itemize}
item One
item Two
item Three
end{itemize}
begin{punctitemize}
item One
item Two
item Three
end{punctitemize}
end{document}
EDIT: added the environment approach, nesting is still not supported.
edited 3 hours ago
user7214865
1226 bronze badges
1226 bronze badges
answered 8 hours ago
SkillmonSkillmon
27.9k1 gold badge28 silver badges59 bronze badges
27.9k1 gold badge28 silver badges59 bronze badges
Thanks for the answer. When you say use a different environment, do you mean add a newpunctuateditemize
(for example) rather than overriding the defaultitemize
? If so, could you give an example of what this would look like?
– Marcel
8 hours ago
@Marcel see my edit.
– Skillmon
8 hours ago
Thanks for the edit. I am nitpicking now, but if I have a newline in theitem
, the semicolon / period is on its own line. I don't suppose there is any way to fix that?
– Marcel
7 hours ago
Actually, it looks like that happens if there is a newline in theitemize
.
– Marcel
7 hours ago
1
@Skillmon Probably Marcel is referring to a blank line between items. Try it.
– egreg
5 hours ago
|
show 1 more comment
Thanks for the answer. When you say use a different environment, do you mean add a newpunctuateditemize
(for example) rather than overriding the defaultitemize
? If so, could you give an example of what this would look like?
– Marcel
8 hours ago
@Marcel see my edit.
– Skillmon
8 hours ago
Thanks for the edit. I am nitpicking now, but if I have a newline in theitem
, the semicolon / period is on its own line. I don't suppose there is any way to fix that?
– Marcel
7 hours ago
Actually, it looks like that happens if there is a newline in theitemize
.
– Marcel
7 hours ago
1
@Skillmon Probably Marcel is referring to a blank line between items. Try it.
– egreg
5 hours ago
Thanks for the answer. When you say use a different environment, do you mean add a new
punctuateditemize
(for example) rather than overriding the default itemize
? If so, could you give an example of what this would look like?– Marcel
8 hours ago
Thanks for the answer. When you say use a different environment, do you mean add a new
punctuateditemize
(for example) rather than overriding the default itemize
? If so, could you give an example of what this would look like?– Marcel
8 hours ago
@Marcel see my edit.
– Skillmon
8 hours ago
@Marcel see my edit.
– Skillmon
8 hours ago
Thanks for the edit. I am nitpicking now, but if I have a newline in the
item
, the semicolon / period is on its own line. I don't suppose there is any way to fix that?– Marcel
7 hours ago
Thanks for the edit. I am nitpicking now, but if I have a newline in the
item
, the semicolon / period is on its own line. I don't suppose there is any way to fix that?– Marcel
7 hours ago
Actually, it looks like that happens if there is a newline in the
itemize
.– Marcel
7 hours ago
Actually, it looks like that happens if there is a newline in the
itemize
.– Marcel
7 hours ago
1
1
@Skillmon Probably Marcel is referring to a blank line between items. Try it.
– egreg
5 hours ago
@Skillmon Probably Marcel is referring to a blank line between items. Try it.
– egreg
5 hours ago
|
show 1 more comment
You can use xparse
, absorbing the whole contents and splitting it at item
; then add a semicolon (and the removed item
) between items.
The processing is complicated by the fact that a blank line between items would introduce a spurious paragraph before the semicolon or the final period, so we need to remove blanks and par
tokens at the end of each item.
Thus the sequence obtained by splitting at item
is mapped to “purify” it.
I added enumitem
for maximum flexibility.
documentclass{article}
usepackage{xparse}
usepackage{enumitem}
ExplSyntaxOn
NewDocumentEnvironment{autoitemize}{O{} +b}
{
begin{itemize}[#1]
marcel_autoitemize:n { #2 }
end{itemize}
}{}
seq_new:N l__marcel_autoitemize_items_seq
seq_new:N l__marcel_autoitemize_items_nopar_seq
tl_new:N l__marcel_autoitemize_item_tl
cs_new_protected:Nn marcel_autoitemize:n
{
% split the contents at item; this also removes blanks at either end
seq_set_split:Nnn l__marcel_autoitemize_items_seq { item } { #1 }
% remove the first (empty) item
seq_pop_left:NN l__marcel_autoitemize_items_seq l_tmpa_tl
% we need to remove trailing par tokens
seq_clear:N l__marcel_autoitemize_items_nopar_seq
seq_map_function:NN l__marcel_autoitemize_items_seq __marcel_autoitemize_purify:n
% start the first item
item
% use the sequence, putting a semicolon and item between items
seq_use:Nn l__marcel_autoitemize_items_nopar_seq { ; item }
% end up with a period
.
}
cs_new_protected:Nn __marcel_autoitemize_purify:n
{
tl_set:Nn l__marcel_autoitemize_item_tl { #1 }
regex_replace_once:nnN { s* c{par}* Z } { } l__marcel_autoitemize_item_tl
seq_put_right:NV l__marcel_autoitemize_items_nopar_seq l__marcel_autoitemize_item_tl
}
ExplSyntaxOff
begin{document}
begin{autoitemize}
item One
item Two
item Three
end{autoitemize}
begin{autoitemize}[label=--]
item One
item Two
item Three
end{autoitemize}
end{document}
add a comment |
You can use xparse
, absorbing the whole contents and splitting it at item
; then add a semicolon (and the removed item
) between items.
The processing is complicated by the fact that a blank line between items would introduce a spurious paragraph before the semicolon or the final period, so we need to remove blanks and par
tokens at the end of each item.
Thus the sequence obtained by splitting at item
is mapped to “purify” it.
I added enumitem
for maximum flexibility.
documentclass{article}
usepackage{xparse}
usepackage{enumitem}
ExplSyntaxOn
NewDocumentEnvironment{autoitemize}{O{} +b}
{
begin{itemize}[#1]
marcel_autoitemize:n { #2 }
end{itemize}
}{}
seq_new:N l__marcel_autoitemize_items_seq
seq_new:N l__marcel_autoitemize_items_nopar_seq
tl_new:N l__marcel_autoitemize_item_tl
cs_new_protected:Nn marcel_autoitemize:n
{
% split the contents at item; this also removes blanks at either end
seq_set_split:Nnn l__marcel_autoitemize_items_seq { item } { #1 }
% remove the first (empty) item
seq_pop_left:NN l__marcel_autoitemize_items_seq l_tmpa_tl
% we need to remove trailing par tokens
seq_clear:N l__marcel_autoitemize_items_nopar_seq
seq_map_function:NN l__marcel_autoitemize_items_seq __marcel_autoitemize_purify:n
% start the first item
item
% use the sequence, putting a semicolon and item between items
seq_use:Nn l__marcel_autoitemize_items_nopar_seq { ; item }
% end up with a period
.
}
cs_new_protected:Nn __marcel_autoitemize_purify:n
{
tl_set:Nn l__marcel_autoitemize_item_tl { #1 }
regex_replace_once:nnN { s* c{par}* Z } { } l__marcel_autoitemize_item_tl
seq_put_right:NV l__marcel_autoitemize_items_nopar_seq l__marcel_autoitemize_item_tl
}
ExplSyntaxOff
begin{document}
begin{autoitemize}
item One
item Two
item Three
end{autoitemize}
begin{autoitemize}[label=--]
item One
item Two
item Three
end{autoitemize}
end{document}
add a comment |
You can use xparse
, absorbing the whole contents and splitting it at item
; then add a semicolon (and the removed item
) between items.
The processing is complicated by the fact that a blank line between items would introduce a spurious paragraph before the semicolon or the final period, so we need to remove blanks and par
tokens at the end of each item.
Thus the sequence obtained by splitting at item
is mapped to “purify” it.
I added enumitem
for maximum flexibility.
documentclass{article}
usepackage{xparse}
usepackage{enumitem}
ExplSyntaxOn
NewDocumentEnvironment{autoitemize}{O{} +b}
{
begin{itemize}[#1]
marcel_autoitemize:n { #2 }
end{itemize}
}{}
seq_new:N l__marcel_autoitemize_items_seq
seq_new:N l__marcel_autoitemize_items_nopar_seq
tl_new:N l__marcel_autoitemize_item_tl
cs_new_protected:Nn marcel_autoitemize:n
{
% split the contents at item; this also removes blanks at either end
seq_set_split:Nnn l__marcel_autoitemize_items_seq { item } { #1 }
% remove the first (empty) item
seq_pop_left:NN l__marcel_autoitemize_items_seq l_tmpa_tl
% we need to remove trailing par tokens
seq_clear:N l__marcel_autoitemize_items_nopar_seq
seq_map_function:NN l__marcel_autoitemize_items_seq __marcel_autoitemize_purify:n
% start the first item
item
% use the sequence, putting a semicolon and item between items
seq_use:Nn l__marcel_autoitemize_items_nopar_seq { ; item }
% end up with a period
.
}
cs_new_protected:Nn __marcel_autoitemize_purify:n
{
tl_set:Nn l__marcel_autoitemize_item_tl { #1 }
regex_replace_once:nnN { s* c{par}* Z } { } l__marcel_autoitemize_item_tl
seq_put_right:NV l__marcel_autoitemize_items_nopar_seq l__marcel_autoitemize_item_tl
}
ExplSyntaxOff
begin{document}
begin{autoitemize}
item One
item Two
item Three
end{autoitemize}
begin{autoitemize}[label=--]
item One
item Two
item Three
end{autoitemize}
end{document}
You can use xparse
, absorbing the whole contents and splitting it at item
; then add a semicolon (and the removed item
) between items.
The processing is complicated by the fact that a blank line between items would introduce a spurious paragraph before the semicolon or the final period, so we need to remove blanks and par
tokens at the end of each item.
Thus the sequence obtained by splitting at item
is mapped to “purify” it.
I added enumitem
for maximum flexibility.
documentclass{article}
usepackage{xparse}
usepackage{enumitem}
ExplSyntaxOn
NewDocumentEnvironment{autoitemize}{O{} +b}
{
begin{itemize}[#1]
marcel_autoitemize:n { #2 }
end{itemize}
}{}
seq_new:N l__marcel_autoitemize_items_seq
seq_new:N l__marcel_autoitemize_items_nopar_seq
tl_new:N l__marcel_autoitemize_item_tl
cs_new_protected:Nn marcel_autoitemize:n
{
% split the contents at item; this also removes blanks at either end
seq_set_split:Nnn l__marcel_autoitemize_items_seq { item } { #1 }
% remove the first (empty) item
seq_pop_left:NN l__marcel_autoitemize_items_seq l_tmpa_tl
% we need to remove trailing par tokens
seq_clear:N l__marcel_autoitemize_items_nopar_seq
seq_map_function:NN l__marcel_autoitemize_items_seq __marcel_autoitemize_purify:n
% start the first item
item
% use the sequence, putting a semicolon and item between items
seq_use:Nn l__marcel_autoitemize_items_nopar_seq { ; item }
% end up with a period
.
}
cs_new_protected:Nn __marcel_autoitemize_purify:n
{
tl_set:Nn l__marcel_autoitemize_item_tl { #1 }
regex_replace_once:nnN { s* c{par}* Z } { } l__marcel_autoitemize_item_tl
seq_put_right:NV l__marcel_autoitemize_items_nopar_seq l__marcel_autoitemize_item_tl
}
ExplSyntaxOff
begin{document}
begin{autoitemize}
item One
item Two
item Three
end{autoitemize}
begin{autoitemize}[label=--]
item One
item Two
item Three
end{autoitemize}
end{document}
answered 6 hours ago
egregegreg
767k91 gold badges2002 silver badges3355 bronze badges
767k91 gold badges2002 silver badges3355 bronze badges
add a comment |
add a comment |
Marcel is a new contributor. Be nice, and check out our Code of Conduct.
Marcel is a new contributor. Be nice, and check out our Code of Conduct.
Marcel is a new contributor. Be nice, and check out our Code of Conduct.
Marcel is a new contributor. Be nice, and check out our Code of Conduct.
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%2f507406%2fautomatically-end-list-item-with-proper-punctuation-semicolon-period%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