Automatic table row numbers












34














Is there any way to get automatic row numbers in table?



For example, if I define table contents as



begin{tabular} % black magic column definition
rownumber & foo\
rownumber & bar\
rownumber & baz\
end{tabular}


and get something like



1 | foo
2 | bar
3 | baz









share|improve this question
























  • Duplicate question: How to enumerate the rows of a table
    – koppor
    Oct 20 '15 at 13:02
















34














Is there any way to get automatic row numbers in table?



For example, if I define table contents as



begin{tabular} % black magic column definition
rownumber & foo\
rownumber & bar\
rownumber & baz\
end{tabular}


and get something like



1 | foo
2 | bar
3 | baz









share|improve this question
























  • Duplicate question: How to enumerate the rows of a table
    – koppor
    Oct 20 '15 at 13:02














34












34








34


11





Is there any way to get automatic row numbers in table?



For example, if I define table contents as



begin{tabular} % black magic column definition
rownumber & foo\
rownumber & bar\
rownumber & baz\
end{tabular}


and get something like



1 | foo
2 | bar
3 | baz









share|improve this question















Is there any way to get automatic row numbers in table?



For example, if I define table contents as



begin{tabular} % black magic column definition
rownumber & foo\
rownumber & bar\
rownumber & baz\
end{tabular}


and get something like



1 | foo
2 | bar
3 | baz






tables numbering






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jul 15 '17 at 14:56









David Carlisle

482k3811131850




482k3811131850










asked Jun 21 '11 at 11:46









miah

273135




273135












  • Duplicate question: How to enumerate the rows of a table
    – koppor
    Oct 20 '15 at 13:02


















  • Duplicate question: How to enumerate the rows of a table
    – koppor
    Oct 20 '15 at 13:02
















Duplicate question: How to enumerate the rows of a table
– koppor
Oct 20 '15 at 13:02




Duplicate question: How to enumerate the rows of a table
– koppor
Oct 20 '15 at 13:02










3 Answers
3






active

oldest

votes


















23














documentclass{article}
usepackage{array,etoolbox}
pretotabular{setcounter{magicrownumbers}{0}}
newcounter{magicrownumbers}
newcommandrownumber{stepcounter{magicrownumbers}arabic{magicrownumbers}}
begin{document}

begin{tabular}{@{makebox[3em][r]{rownumberspace}} | r}
Something \
Other stuff \
MAGIC!
end{tabular}

end{document}


output



enter image description here

If you want to start with the second row use



documentclass{article}
usepackage{array,etoolbox}
pretotabular{setcounter{magicrownumbers}{0}}
newcounter{magicrownumbers}
defrownumber{}
begin{document}

begin{tabular}{@{makebox[3em][r]{rownumberspace}} | r}
Something
gdefrownumber{stepcounter{magicrownumbers}arabic{magicrownumbers}} \
Other stuff \
MAGIC!
end{tabular}

end{document}


output
enter image description here



If one wants a heading for the columns use:



documentclass{article}
usepackage{array,etoolbox}
pretotabular{setcounter{magicrownumbers}{0}}
newcounter{magicrownumbers}
newcommandrownumber{stepcounter{magicrownumbers}arabic{magicrownumbers}}
begin{document}

begin{tabular}{@{makebox[3em][r]{rownumberspace}} | r}
multicolumn{1}{@{makebox[3em][r]{ID~}} | r}{emph{whatever}}\
Something \
Other stuff \
MAGIC!
end{tabular}

end{document}


enter image description here






share|improve this answer



















  • 1




    Is it possible to start numbering at the second line? i.e. have a header row? TIA.
    – Fabian Tamp
    Oct 10 '12 at 12:00






  • 2




    edit the command rownumber that it test the value: ifnumthemagicrownumber>2relaxarabic{magicrownumbers}fi` then it puts only the number at the third row
    – Herbert
    Jun 30 '13 at 7:08






  • 1




    @Herbert Do you mean replace begin{tabular}{@{makebox[3em][r]{rownumberspace}} | r} with begin{tabular}{@{makebox[3em][r]{ifnumthemagicrownumber>2relaxarabic{magicrownumbers}fispace}} | r} ? When I do that, I get "Undefined control sequence" errors.
    – David Doria
    Jul 7 '14 at 14:21








  • 1




    @littleO: see my edited answer
    – Herbert
    Sep 5 '15 at 7:10






  • 1




    see edited anwer (at the end)
    – Herbert
    Dec 8 at 10:36



















27














You could just make it use a counter...



documentclass{article}
newcounter{magicrownumbers}
newcommandrownumber{stepcounter{magicrownumbers}arabic{magicrownumbers}}
begin{document}
begin{tabular}{l|r}
rownumber & Something \
rownumber & Other stuff \
rownumber & MAGIC!
end{tabular}
end{document}


enter image description here






share|improve this answer























  • Is there any frendly way to reset the counter between tables?
    – miah
    Jun 21 '11 at 11:56






  • 4




    @miah: Load etoolbox and say pretotabular{setcounter{magicrownumbers}{0}}
    – egreg
    Jun 21 '11 at 11:58






  • 4




    @egreg I put that before my second table but the counter did not reset. I had to use simply setcounter{magicrownumbers}{0} instead
    – David Doria
    Jul 7 '14 at 14:27












  • @DavidDoria That code should go in the preamble.
    – egreg
    Jul 7 '14 at 14:29










  • @egreg Hm, even with that in the preamble, the row numbers do not reset for me unless I clear the counter manually as I explained.
    – David Doria
    Jul 7 '14 at 15:05



















0














A quick plain-format version as well for completenes:



newcountrowcount
defmyhalign#1{halign{globaladvancerowcount by 1 therowcountquad##&#1}rowcount=0}
% Yes, yes, next up in *sniping*: "One problem: you can't use repeating preamble"...
myhalign{#hfilcr
blahcr
foocr}
halign{#hfilcr
barcr
bazcr}
myhalign{&#hfilcr
asdf&asdf&asdfcr
sdfg&asdf&dfghcr}
myhalign{#hfil&&hfil#cr
doesn't&workcr
boo&hoocr}
bye





share|improve this answer























  • Two problems. 1. Every subsequent halign will advance the counter even if it doesn't need it. 2. If a row shouldn't be numbered (a header), omitting therowcount would not avoid stepping the counter. The stepping should go in the table preamble.
    – egreg
    Jun 21 '11 at 14:48










  • @egreg I wasn't aiming for a be-all-end-all solution; just an answer to the question.
    – morbusg
    Jun 21 '11 at 14:51












  • @egreg: You don't need the @<username>-notation when you're addressing your comment to the answerer/questioner.
    – morbusg
    Jun 21 '11 at 14:57













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%2f21243%2fautomatic-table-row-numbers%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























3 Answers
3






active

oldest

votes








3 Answers
3






active

oldest

votes









active

oldest

votes






active

oldest

votes









23














documentclass{article}
usepackage{array,etoolbox}
pretotabular{setcounter{magicrownumbers}{0}}
newcounter{magicrownumbers}
newcommandrownumber{stepcounter{magicrownumbers}arabic{magicrownumbers}}
begin{document}

begin{tabular}{@{makebox[3em][r]{rownumberspace}} | r}
Something \
Other stuff \
MAGIC!
end{tabular}

end{document}


output



enter image description here

If you want to start with the second row use



documentclass{article}
usepackage{array,etoolbox}
pretotabular{setcounter{magicrownumbers}{0}}
newcounter{magicrownumbers}
defrownumber{}
begin{document}

begin{tabular}{@{makebox[3em][r]{rownumberspace}} | r}
Something
gdefrownumber{stepcounter{magicrownumbers}arabic{magicrownumbers}} \
Other stuff \
MAGIC!
end{tabular}

end{document}


output
enter image description here



If one wants a heading for the columns use:



documentclass{article}
usepackage{array,etoolbox}
pretotabular{setcounter{magicrownumbers}{0}}
newcounter{magicrownumbers}
newcommandrownumber{stepcounter{magicrownumbers}arabic{magicrownumbers}}
begin{document}

begin{tabular}{@{makebox[3em][r]{rownumberspace}} | r}
multicolumn{1}{@{makebox[3em][r]{ID~}} | r}{emph{whatever}}\
Something \
Other stuff \
MAGIC!
end{tabular}

end{document}


enter image description here






share|improve this answer



















  • 1




    Is it possible to start numbering at the second line? i.e. have a header row? TIA.
    – Fabian Tamp
    Oct 10 '12 at 12:00






  • 2




    edit the command rownumber that it test the value: ifnumthemagicrownumber>2relaxarabic{magicrownumbers}fi` then it puts only the number at the third row
    – Herbert
    Jun 30 '13 at 7:08






  • 1




    @Herbert Do you mean replace begin{tabular}{@{makebox[3em][r]{rownumberspace}} | r} with begin{tabular}{@{makebox[3em][r]{ifnumthemagicrownumber>2relaxarabic{magicrownumbers}fispace}} | r} ? When I do that, I get "Undefined control sequence" errors.
    – David Doria
    Jul 7 '14 at 14:21








  • 1




    @littleO: see my edited answer
    – Herbert
    Sep 5 '15 at 7:10






  • 1




    see edited anwer (at the end)
    – Herbert
    Dec 8 at 10:36
















23














documentclass{article}
usepackage{array,etoolbox}
pretotabular{setcounter{magicrownumbers}{0}}
newcounter{magicrownumbers}
newcommandrownumber{stepcounter{magicrownumbers}arabic{magicrownumbers}}
begin{document}

begin{tabular}{@{makebox[3em][r]{rownumberspace}} | r}
Something \
Other stuff \
MAGIC!
end{tabular}

end{document}


output



enter image description here

If you want to start with the second row use



documentclass{article}
usepackage{array,etoolbox}
pretotabular{setcounter{magicrownumbers}{0}}
newcounter{magicrownumbers}
defrownumber{}
begin{document}

begin{tabular}{@{makebox[3em][r]{rownumberspace}} | r}
Something
gdefrownumber{stepcounter{magicrownumbers}arabic{magicrownumbers}} \
Other stuff \
MAGIC!
end{tabular}

end{document}


output
enter image description here



If one wants a heading for the columns use:



documentclass{article}
usepackage{array,etoolbox}
pretotabular{setcounter{magicrownumbers}{0}}
newcounter{magicrownumbers}
newcommandrownumber{stepcounter{magicrownumbers}arabic{magicrownumbers}}
begin{document}

begin{tabular}{@{makebox[3em][r]{rownumberspace}} | r}
multicolumn{1}{@{makebox[3em][r]{ID~}} | r}{emph{whatever}}\
Something \
Other stuff \
MAGIC!
end{tabular}

end{document}


enter image description here






share|improve this answer



















  • 1




    Is it possible to start numbering at the second line? i.e. have a header row? TIA.
    – Fabian Tamp
    Oct 10 '12 at 12:00






  • 2




    edit the command rownumber that it test the value: ifnumthemagicrownumber>2relaxarabic{magicrownumbers}fi` then it puts only the number at the third row
    – Herbert
    Jun 30 '13 at 7:08






  • 1




    @Herbert Do you mean replace begin{tabular}{@{makebox[3em][r]{rownumberspace}} | r} with begin{tabular}{@{makebox[3em][r]{ifnumthemagicrownumber>2relaxarabic{magicrownumbers}fispace}} | r} ? When I do that, I get "Undefined control sequence" errors.
    – David Doria
    Jul 7 '14 at 14:21








  • 1




    @littleO: see my edited answer
    – Herbert
    Sep 5 '15 at 7:10






  • 1




    see edited anwer (at the end)
    – Herbert
    Dec 8 at 10:36














23












23








23






documentclass{article}
usepackage{array,etoolbox}
pretotabular{setcounter{magicrownumbers}{0}}
newcounter{magicrownumbers}
newcommandrownumber{stepcounter{magicrownumbers}arabic{magicrownumbers}}
begin{document}

begin{tabular}{@{makebox[3em][r]{rownumberspace}} | r}
Something \
Other stuff \
MAGIC!
end{tabular}

end{document}


output



enter image description here

If you want to start with the second row use



documentclass{article}
usepackage{array,etoolbox}
pretotabular{setcounter{magicrownumbers}{0}}
newcounter{magicrownumbers}
defrownumber{}
begin{document}

begin{tabular}{@{makebox[3em][r]{rownumberspace}} | r}
Something
gdefrownumber{stepcounter{magicrownumbers}arabic{magicrownumbers}} \
Other stuff \
MAGIC!
end{tabular}

end{document}


output
enter image description here



If one wants a heading for the columns use:



documentclass{article}
usepackage{array,etoolbox}
pretotabular{setcounter{magicrownumbers}{0}}
newcounter{magicrownumbers}
newcommandrownumber{stepcounter{magicrownumbers}arabic{magicrownumbers}}
begin{document}

begin{tabular}{@{makebox[3em][r]{rownumberspace}} | r}
multicolumn{1}{@{makebox[3em][r]{ID~}} | r}{emph{whatever}}\
Something \
Other stuff \
MAGIC!
end{tabular}

end{document}


enter image description here






share|improve this answer














documentclass{article}
usepackage{array,etoolbox}
pretotabular{setcounter{magicrownumbers}{0}}
newcounter{magicrownumbers}
newcommandrownumber{stepcounter{magicrownumbers}arabic{magicrownumbers}}
begin{document}

begin{tabular}{@{makebox[3em][r]{rownumberspace}} | r}
Something \
Other stuff \
MAGIC!
end{tabular}

end{document}


output



enter image description here

If you want to start with the second row use



documentclass{article}
usepackage{array,etoolbox}
pretotabular{setcounter{magicrownumbers}{0}}
newcounter{magicrownumbers}
defrownumber{}
begin{document}

begin{tabular}{@{makebox[3em][r]{rownumberspace}} | r}
Something
gdefrownumber{stepcounter{magicrownumbers}arabic{magicrownumbers}} \
Other stuff \
MAGIC!
end{tabular}

end{document}


output
enter image description here



If one wants a heading for the columns use:



documentclass{article}
usepackage{array,etoolbox}
pretotabular{setcounter{magicrownumbers}{0}}
newcounter{magicrownumbers}
newcommandrownumber{stepcounter{magicrownumbers}arabic{magicrownumbers}}
begin{document}

begin{tabular}{@{makebox[3em][r]{rownumberspace}} | r}
multicolumn{1}{@{makebox[3em][r]{ID~}} | r}{emph{whatever}}\
Something \
Other stuff \
MAGIC!
end{tabular}

end{document}


enter image description here







share|improve this answer














share|improve this answer



share|improve this answer








edited Dec 8 at 10:36

























answered Jun 21 '11 at 11:59









Herbert

269k24408717




269k24408717








  • 1




    Is it possible to start numbering at the second line? i.e. have a header row? TIA.
    – Fabian Tamp
    Oct 10 '12 at 12:00






  • 2




    edit the command rownumber that it test the value: ifnumthemagicrownumber>2relaxarabic{magicrownumbers}fi` then it puts only the number at the third row
    – Herbert
    Jun 30 '13 at 7:08






  • 1




    @Herbert Do you mean replace begin{tabular}{@{makebox[3em][r]{rownumberspace}} | r} with begin{tabular}{@{makebox[3em][r]{ifnumthemagicrownumber>2relaxarabic{magicrownumbers}fispace}} | r} ? When I do that, I get "Undefined control sequence" errors.
    – David Doria
    Jul 7 '14 at 14:21








  • 1




    @littleO: see my edited answer
    – Herbert
    Sep 5 '15 at 7:10






  • 1




    see edited anwer (at the end)
    – Herbert
    Dec 8 at 10:36














  • 1




    Is it possible to start numbering at the second line? i.e. have a header row? TIA.
    – Fabian Tamp
    Oct 10 '12 at 12:00






  • 2




    edit the command rownumber that it test the value: ifnumthemagicrownumber>2relaxarabic{magicrownumbers}fi` then it puts only the number at the third row
    – Herbert
    Jun 30 '13 at 7:08






  • 1




    @Herbert Do you mean replace begin{tabular}{@{makebox[3em][r]{rownumberspace}} | r} with begin{tabular}{@{makebox[3em][r]{ifnumthemagicrownumber>2relaxarabic{magicrownumbers}fispace}} | r} ? When I do that, I get "Undefined control sequence" errors.
    – David Doria
    Jul 7 '14 at 14:21








  • 1




    @littleO: see my edited answer
    – Herbert
    Sep 5 '15 at 7:10






  • 1




    see edited anwer (at the end)
    – Herbert
    Dec 8 at 10:36








1




1




Is it possible to start numbering at the second line? i.e. have a header row? TIA.
– Fabian Tamp
Oct 10 '12 at 12:00




Is it possible to start numbering at the second line? i.e. have a header row? TIA.
– Fabian Tamp
Oct 10 '12 at 12:00




2




2




edit the command rownumber that it test the value: ifnumthemagicrownumber>2relaxarabic{magicrownumbers}fi` then it puts only the number at the third row
– Herbert
Jun 30 '13 at 7:08




edit the command rownumber that it test the value: ifnumthemagicrownumber>2relaxarabic{magicrownumbers}fi` then it puts only the number at the third row
– Herbert
Jun 30 '13 at 7:08




1




1




@Herbert Do you mean replace begin{tabular}{@{makebox[3em][r]{rownumberspace}} | r} with begin{tabular}{@{makebox[3em][r]{ifnumthemagicrownumber>2relaxarabic{magicrownumbers}fispace}} | r} ? When I do that, I get "Undefined control sequence" errors.
– David Doria
Jul 7 '14 at 14:21






@Herbert Do you mean replace begin{tabular}{@{makebox[3em][r]{rownumberspace}} | r} with begin{tabular}{@{makebox[3em][r]{ifnumthemagicrownumber>2relaxarabic{magicrownumbers}fispace}} | r} ? When I do that, I get "Undefined control sequence" errors.
– David Doria
Jul 7 '14 at 14:21






1




1




@littleO: see my edited answer
– Herbert
Sep 5 '15 at 7:10




@littleO: see my edited answer
– Herbert
Sep 5 '15 at 7:10




1




1




see edited anwer (at the end)
– Herbert
Dec 8 at 10:36




see edited anwer (at the end)
– Herbert
Dec 8 at 10:36











27














You could just make it use a counter...



documentclass{article}
newcounter{magicrownumbers}
newcommandrownumber{stepcounter{magicrownumbers}arabic{magicrownumbers}}
begin{document}
begin{tabular}{l|r}
rownumber & Something \
rownumber & Other stuff \
rownumber & MAGIC!
end{tabular}
end{document}


enter image description here






share|improve this answer























  • Is there any frendly way to reset the counter between tables?
    – miah
    Jun 21 '11 at 11:56






  • 4




    @miah: Load etoolbox and say pretotabular{setcounter{magicrownumbers}{0}}
    – egreg
    Jun 21 '11 at 11:58






  • 4




    @egreg I put that before my second table but the counter did not reset. I had to use simply setcounter{magicrownumbers}{0} instead
    – David Doria
    Jul 7 '14 at 14:27












  • @DavidDoria That code should go in the preamble.
    – egreg
    Jul 7 '14 at 14:29










  • @egreg Hm, even with that in the preamble, the row numbers do not reset for me unless I clear the counter manually as I explained.
    – David Doria
    Jul 7 '14 at 15:05
















27














You could just make it use a counter...



documentclass{article}
newcounter{magicrownumbers}
newcommandrownumber{stepcounter{magicrownumbers}arabic{magicrownumbers}}
begin{document}
begin{tabular}{l|r}
rownumber & Something \
rownumber & Other stuff \
rownumber & MAGIC!
end{tabular}
end{document}


enter image description here






share|improve this answer























  • Is there any frendly way to reset the counter between tables?
    – miah
    Jun 21 '11 at 11:56






  • 4




    @miah: Load etoolbox and say pretotabular{setcounter{magicrownumbers}{0}}
    – egreg
    Jun 21 '11 at 11:58






  • 4




    @egreg I put that before my second table but the counter did not reset. I had to use simply setcounter{magicrownumbers}{0} instead
    – David Doria
    Jul 7 '14 at 14:27












  • @DavidDoria That code should go in the preamble.
    – egreg
    Jul 7 '14 at 14:29










  • @egreg Hm, even with that in the preamble, the row numbers do not reset for me unless I clear the counter manually as I explained.
    – David Doria
    Jul 7 '14 at 15:05














27












27








27






You could just make it use a counter...



documentclass{article}
newcounter{magicrownumbers}
newcommandrownumber{stepcounter{magicrownumbers}arabic{magicrownumbers}}
begin{document}
begin{tabular}{l|r}
rownumber & Something \
rownumber & Other stuff \
rownumber & MAGIC!
end{tabular}
end{document}


enter image description here






share|improve this answer














You could just make it use a counter...



documentclass{article}
newcounter{magicrownumbers}
newcommandrownumber{stepcounter{magicrownumbers}arabic{magicrownumbers}}
begin{document}
begin{tabular}{l|r}
rownumber & Something \
rownumber & Other stuff \
rownumber & MAGIC!
end{tabular}
end{document}


enter image description here







share|improve this answer














share|improve this answer



share|improve this answer








edited Sep 6 at 16:46









alhelal

1,004119




1,004119










answered Jun 21 '11 at 11:51









Seamus

44.9k35215332




44.9k35215332












  • Is there any frendly way to reset the counter between tables?
    – miah
    Jun 21 '11 at 11:56






  • 4




    @miah: Load etoolbox and say pretotabular{setcounter{magicrownumbers}{0}}
    – egreg
    Jun 21 '11 at 11:58






  • 4




    @egreg I put that before my second table but the counter did not reset. I had to use simply setcounter{magicrownumbers}{0} instead
    – David Doria
    Jul 7 '14 at 14:27












  • @DavidDoria That code should go in the preamble.
    – egreg
    Jul 7 '14 at 14:29










  • @egreg Hm, even with that in the preamble, the row numbers do not reset for me unless I clear the counter manually as I explained.
    – David Doria
    Jul 7 '14 at 15:05


















  • Is there any frendly way to reset the counter between tables?
    – miah
    Jun 21 '11 at 11:56






  • 4




    @miah: Load etoolbox and say pretotabular{setcounter{magicrownumbers}{0}}
    – egreg
    Jun 21 '11 at 11:58






  • 4




    @egreg I put that before my second table but the counter did not reset. I had to use simply setcounter{magicrownumbers}{0} instead
    – David Doria
    Jul 7 '14 at 14:27












  • @DavidDoria That code should go in the preamble.
    – egreg
    Jul 7 '14 at 14:29










  • @egreg Hm, even with that in the preamble, the row numbers do not reset for me unless I clear the counter manually as I explained.
    – David Doria
    Jul 7 '14 at 15:05
















Is there any frendly way to reset the counter between tables?
– miah
Jun 21 '11 at 11:56




Is there any frendly way to reset the counter between tables?
– miah
Jun 21 '11 at 11:56




4




4




@miah: Load etoolbox and say pretotabular{setcounter{magicrownumbers}{0}}
– egreg
Jun 21 '11 at 11:58




@miah: Load etoolbox and say pretotabular{setcounter{magicrownumbers}{0}}
– egreg
Jun 21 '11 at 11:58




4




4




@egreg I put that before my second table but the counter did not reset. I had to use simply setcounter{magicrownumbers}{0} instead
– David Doria
Jul 7 '14 at 14:27






@egreg I put that before my second table but the counter did not reset. I had to use simply setcounter{magicrownumbers}{0} instead
– David Doria
Jul 7 '14 at 14:27














@DavidDoria That code should go in the preamble.
– egreg
Jul 7 '14 at 14:29




@DavidDoria That code should go in the preamble.
– egreg
Jul 7 '14 at 14:29












@egreg Hm, even with that in the preamble, the row numbers do not reset for me unless I clear the counter manually as I explained.
– David Doria
Jul 7 '14 at 15:05




@egreg Hm, even with that in the preamble, the row numbers do not reset for me unless I clear the counter manually as I explained.
– David Doria
Jul 7 '14 at 15:05











0














A quick plain-format version as well for completenes:



newcountrowcount
defmyhalign#1{halign{globaladvancerowcount by 1 therowcountquad##&#1}rowcount=0}
% Yes, yes, next up in *sniping*: "One problem: you can't use repeating preamble"...
myhalign{#hfilcr
blahcr
foocr}
halign{#hfilcr
barcr
bazcr}
myhalign{&#hfilcr
asdf&asdf&asdfcr
sdfg&asdf&dfghcr}
myhalign{#hfil&&hfil#cr
doesn't&workcr
boo&hoocr}
bye





share|improve this answer























  • Two problems. 1. Every subsequent halign will advance the counter even if it doesn't need it. 2. If a row shouldn't be numbered (a header), omitting therowcount would not avoid stepping the counter. The stepping should go in the table preamble.
    – egreg
    Jun 21 '11 at 14:48










  • @egreg I wasn't aiming for a be-all-end-all solution; just an answer to the question.
    – morbusg
    Jun 21 '11 at 14:51












  • @egreg: You don't need the @<username>-notation when you're addressing your comment to the answerer/questioner.
    – morbusg
    Jun 21 '11 at 14:57


















0














A quick plain-format version as well for completenes:



newcountrowcount
defmyhalign#1{halign{globaladvancerowcount by 1 therowcountquad##&#1}rowcount=0}
% Yes, yes, next up in *sniping*: "One problem: you can't use repeating preamble"...
myhalign{#hfilcr
blahcr
foocr}
halign{#hfilcr
barcr
bazcr}
myhalign{&#hfilcr
asdf&asdf&asdfcr
sdfg&asdf&dfghcr}
myhalign{#hfil&&hfil#cr
doesn't&workcr
boo&hoocr}
bye





share|improve this answer























  • Two problems. 1. Every subsequent halign will advance the counter even if it doesn't need it. 2. If a row shouldn't be numbered (a header), omitting therowcount would not avoid stepping the counter. The stepping should go in the table preamble.
    – egreg
    Jun 21 '11 at 14:48










  • @egreg I wasn't aiming for a be-all-end-all solution; just an answer to the question.
    – morbusg
    Jun 21 '11 at 14:51












  • @egreg: You don't need the @<username>-notation when you're addressing your comment to the answerer/questioner.
    – morbusg
    Jun 21 '11 at 14:57
















0












0








0






A quick plain-format version as well for completenes:



newcountrowcount
defmyhalign#1{halign{globaladvancerowcount by 1 therowcountquad##&#1}rowcount=0}
% Yes, yes, next up in *sniping*: "One problem: you can't use repeating preamble"...
myhalign{#hfilcr
blahcr
foocr}
halign{#hfilcr
barcr
bazcr}
myhalign{&#hfilcr
asdf&asdf&asdfcr
sdfg&asdf&dfghcr}
myhalign{#hfil&&hfil#cr
doesn't&workcr
boo&hoocr}
bye





share|improve this answer














A quick plain-format version as well for completenes:



newcountrowcount
defmyhalign#1{halign{globaladvancerowcount by 1 therowcountquad##&#1}rowcount=0}
% Yes, yes, next up in *sniping*: "One problem: you can't use repeating preamble"...
myhalign{#hfilcr
blahcr
foocr}
halign{#hfilcr
barcr
bazcr}
myhalign{&#hfilcr
asdf&asdf&asdfcr
sdfg&asdf&dfghcr}
myhalign{#hfil&&hfil#cr
doesn't&workcr
boo&hoocr}
bye






share|improve this answer














share|improve this answer



share|improve this answer








edited Jun 21 '11 at 16:22

























answered Jun 21 '11 at 14:34









morbusg

19.9k362136




19.9k362136












  • Two problems. 1. Every subsequent halign will advance the counter even if it doesn't need it. 2. If a row shouldn't be numbered (a header), omitting therowcount would not avoid stepping the counter. The stepping should go in the table preamble.
    – egreg
    Jun 21 '11 at 14:48










  • @egreg I wasn't aiming for a be-all-end-all solution; just an answer to the question.
    – morbusg
    Jun 21 '11 at 14:51












  • @egreg: You don't need the @<username>-notation when you're addressing your comment to the answerer/questioner.
    – morbusg
    Jun 21 '11 at 14:57




















  • Two problems. 1. Every subsequent halign will advance the counter even if it doesn't need it. 2. If a row shouldn't be numbered (a header), omitting therowcount would not avoid stepping the counter. The stepping should go in the table preamble.
    – egreg
    Jun 21 '11 at 14:48










  • @egreg I wasn't aiming for a be-all-end-all solution; just an answer to the question.
    – morbusg
    Jun 21 '11 at 14:51












  • @egreg: You don't need the @<username>-notation when you're addressing your comment to the answerer/questioner.
    – morbusg
    Jun 21 '11 at 14:57


















Two problems. 1. Every subsequent halign will advance the counter even if it doesn't need it. 2. If a row shouldn't be numbered (a header), omitting therowcount would not avoid stepping the counter. The stepping should go in the table preamble.
– egreg
Jun 21 '11 at 14:48




Two problems. 1. Every subsequent halign will advance the counter even if it doesn't need it. 2. If a row shouldn't be numbered (a header), omitting therowcount would not avoid stepping the counter. The stepping should go in the table preamble.
– egreg
Jun 21 '11 at 14:48












@egreg I wasn't aiming for a be-all-end-all solution; just an answer to the question.
– morbusg
Jun 21 '11 at 14:51






@egreg I wasn't aiming for a be-all-end-all solution; just an answer to the question.
– morbusg
Jun 21 '11 at 14:51














@egreg: You don't need the @<username>-notation when you're addressing your comment to the answerer/questioner.
– morbusg
Jun 21 '11 at 14:57






@egreg: You don't need the @<username>-notation when you're addressing your comment to the answerer/questioner.
– morbusg
Jun 21 '11 at 14:57




















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.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • 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%2f21243%2fautomatic-table-row-numbers%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

mysqli_query(): Empty query in /home/lucindabrummitt/public_html/blog/wp-includes/wp-db.php on line 1924

How to change which sound is reproduced for terminal bell?

Can I use Tabulator js library in my java Spring + Thymeleaf project?