Use counters value after it appears in the code

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
4
down vote

favorite












Is there a way to use a counters value at one point in the code, but with the counters state of a line, that comes somewhat after the corresponding use of the counters value?



E.g.
Define the counter in line 10, use it in line 15 with valuecnt and keep increasing the value for three lines one after another.
So in line 18, the counters value holds 3.
I want to use this value (3) in line 15!
So valuecnt in line 15 should return 3.



Below find my MWE:



% MWE

documentclassscrbook
usepackagelmodern
usepackage[T1]fontenc
usepackage[utf8]inputenc
usepackage[ngerman]babel
usepackagetabularx
usepackagemultirow

begindocument
newcounterlinecnt


begintable
begintabular[tbh]p4.2cm p0.68textwidth
textbfField & textbfEntrys \
hline
% This works fine:
multirow4 %------------------------------------------------------
4cmThis Field & Entry 1 \
& Entry 2 \
& Entry 3 \
& Entry 4 \[2ex]



% But it would be great if a didn't have to write the amount of lines everytime.
% Is there a way to use a counters value AFTER it's 'use' in the code. Somethining like:

multirowvaluelinecnt %------------------------------------------------------
4cmAnother Field & Automatic Entry 1 stepcounterlinecnt \
& Automatic Entry 2 stepcounterlinecnt \
& Automatic Entry 3 stepcounterlinecnt \
& Automatic Entry 4 stepcounterlinecnt \

% I would like to use the value of 'linecnt' NOW but in the beginning of the multirow-environment

endtabular
endtable


enddocument


I appreciate your help.



Kind regards.










share|improve this question





















  • you can do this with a label-ref system, e.g. with zref. It then needs two compilations.
    – Ulrike Fischer
    48 mins ago














up vote
4
down vote

favorite












Is there a way to use a counters value at one point in the code, but with the counters state of a line, that comes somewhat after the corresponding use of the counters value?



E.g.
Define the counter in line 10, use it in line 15 with valuecnt and keep increasing the value for three lines one after another.
So in line 18, the counters value holds 3.
I want to use this value (3) in line 15!
So valuecnt in line 15 should return 3.



Below find my MWE:



% MWE

documentclassscrbook
usepackagelmodern
usepackage[T1]fontenc
usepackage[utf8]inputenc
usepackage[ngerman]babel
usepackagetabularx
usepackagemultirow

begindocument
newcounterlinecnt


begintable
begintabular[tbh]p4.2cm p0.68textwidth
textbfField & textbfEntrys \
hline
% This works fine:
multirow4 %------------------------------------------------------
4cmThis Field & Entry 1 \
& Entry 2 \
& Entry 3 \
& Entry 4 \[2ex]



% But it would be great if a didn't have to write the amount of lines everytime.
% Is there a way to use a counters value AFTER it's 'use' in the code. Somethining like:

multirowvaluelinecnt %------------------------------------------------------
4cmAnother Field & Automatic Entry 1 stepcounterlinecnt \
& Automatic Entry 2 stepcounterlinecnt \
& Automatic Entry 3 stepcounterlinecnt \
& Automatic Entry 4 stepcounterlinecnt \

% I would like to use the value of 'linecnt' NOW but in the beginning of the multirow-environment

endtabular
endtable


enddocument


I appreciate your help.



Kind regards.










share|improve this question





















  • you can do this with a label-ref system, e.g. with zref. It then needs two compilations.
    – Ulrike Fischer
    48 mins ago












up vote
4
down vote

favorite









up vote
4
down vote

favorite











Is there a way to use a counters value at one point in the code, but with the counters state of a line, that comes somewhat after the corresponding use of the counters value?



E.g.
Define the counter in line 10, use it in line 15 with valuecnt and keep increasing the value for three lines one after another.
So in line 18, the counters value holds 3.
I want to use this value (3) in line 15!
So valuecnt in line 15 should return 3.



Below find my MWE:



% MWE

documentclassscrbook
usepackagelmodern
usepackage[T1]fontenc
usepackage[utf8]inputenc
usepackage[ngerman]babel
usepackagetabularx
usepackagemultirow

begindocument
newcounterlinecnt


begintable
begintabular[tbh]p4.2cm p0.68textwidth
textbfField & textbfEntrys \
hline
% This works fine:
multirow4 %------------------------------------------------------
4cmThis Field & Entry 1 \
& Entry 2 \
& Entry 3 \
& Entry 4 \[2ex]



% But it would be great if a didn't have to write the amount of lines everytime.
% Is there a way to use a counters value AFTER it's 'use' in the code. Somethining like:

multirowvaluelinecnt %------------------------------------------------------
4cmAnother Field & Automatic Entry 1 stepcounterlinecnt \
& Automatic Entry 2 stepcounterlinecnt \
& Automatic Entry 3 stepcounterlinecnt \
& Automatic Entry 4 stepcounterlinecnt \

% I would like to use the value of 'linecnt' NOW but in the beginning of the multirow-environment

endtabular
endtable


enddocument


I appreciate your help.



Kind regards.










share|improve this question













Is there a way to use a counters value at one point in the code, but with the counters state of a line, that comes somewhat after the corresponding use of the counters value?



E.g.
Define the counter in line 10, use it in line 15 with valuecnt and keep increasing the value for three lines one after another.
So in line 18, the counters value holds 3.
I want to use this value (3) in line 15!
So valuecnt in line 15 should return 3.



Below find my MWE:



% MWE

documentclassscrbook
usepackagelmodern
usepackage[T1]fontenc
usepackage[utf8]inputenc
usepackage[ngerman]babel
usepackagetabularx
usepackagemultirow

begindocument
newcounterlinecnt


begintable
begintabular[tbh]p4.2cm p0.68textwidth
textbfField & textbfEntrys \
hline
% This works fine:
multirow4 %------------------------------------------------------
4cmThis Field & Entry 1 \
& Entry 2 \
& Entry 3 \
& Entry 4 \[2ex]



% But it would be great if a didn't have to write the amount of lines everytime.
% Is there a way to use a counters value AFTER it's 'use' in the code. Somethining like:

multirowvaluelinecnt %------------------------------------------------------
4cmAnother Field & Automatic Entry 1 stepcounterlinecnt \
& Automatic Entry 2 stepcounterlinecnt \
& Automatic Entry 3 stepcounterlinecnt \
& Automatic Entry 4 stepcounterlinecnt \

% I would like to use the value of 'linecnt' NOW but in the beginning of the multirow-environment

endtabular
endtable


enddocument


I appreciate your help.



Kind regards.







counters multicol multirow






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 1 hour ago









Michael Schmid

1637




1637











  • you can do this with a label-ref system, e.g. with zref. It then needs two compilations.
    – Ulrike Fischer
    48 mins ago
















  • you can do this with a label-ref system, e.g. with zref. It then needs two compilations.
    – Ulrike Fischer
    48 mins ago















you can do this with a label-ref system, e.g. with zref. It then needs two compilations.
– Ulrike Fischer
48 mins ago




you can do this with a label-ref system, e.g. with zref. It then needs two compilations.
– Ulrike Fischer
48 mins ago










2 Answers
2






active

oldest

votes

















up vote
5
down vote













By the time you know the final number of the counter, the multirow is already typeset, so you can't do much about it.



The usual approach in these cases is a two-pass compilation, writing the value of the counter to the .aux file.



First, in the preamble, we define an initial value for the counter:



defsavedthelinecnt0


then, when we know the final value of the counter, we write it to the .aux file, so in the next compilation, at the begindocument this counter is updated to the correct value:



immediateprotected@write@auxout
gdefprotectsavedthelinecntthelinecnt


then after two passes the value is correct:




enter image description here




documentclassscrbook
usepackagelmodern
usepackage[T1]fontenc
usepackage[utf8]inputenc
usepackage[ngerman]babel
usepackagetabularx
usepackagemultirow

makeatletter
defsavedthelinecnt0
makeatother

begindocument

newcounterlinecnt

begintable[tbh]
begintabularp4.2cm p0.68textwidth
textbfField & textbfEntries \
hline
multirow44cmThis Field
& Entry 1 \
& Entry 2 \
& Entry 3 \
& Entry 4 \[2ex]
multirowsavedthelinecnt4cmAnother Field savedthelinecnt
& Automatic Entry 1 stepcounterlinecnt \
& Automatic Entry 2 stepcounterlinecnt \
& Automatic Entry 3 stepcounterlinecnt \
& Automatic Entry 4 stepcounterlinecnt \
endtabular
makeatletter
immediateprotected@write@auxout
gdefprotectsavedthelinecntthelinecnt
endtable

enddocument



By the way, the [tbh] optional argument you passed to tabular is (kind of) invalid. If you meant the float positions top, bottom and here, then you need to pass the arguments to begintable. If you meant the vertical position of the baseline of the table, then the valid options are t for top, b for bottom, and c (anything else, actually) for centered. But only one character is passed here.






share|improve this answer






















  • You're completely right about the tbh ;) I just came up with this MWE really quickly and didn't care a lot about anything other than the multirow-environment
    – Michael Schmid
    28 mins ago

















up vote
2
down vote













Use refcount; note refstepcounter instead of stepcounter. Watch out for spaces: Automatic Entry 1 refstepcounterlinecnt would have a trailing space.



Note that [tbh] makes no sense for tabular or tabularx. The table environment takes a positioning argument.



documentclassscrbook

usepackage[T1]fontenc
usepackage[utf8]inputenc
usepackage[ngerman]babel
usepackagelmodern

usepackagemultirow
usepackagerefcount

newcounterlinecnt

begindocument

begintable[htp]

begintabularp4.2cm p0.68textwidth
textbfField & textbfEntries \
hline
% This works fine:
multirow44cmThis Field
& Entry 1 \
& Entry 2 \
& Entry 3 \
& Entry 4 \[2ex]
multirowgetrefnumberstep14cmAnother Field
& Automatic Entry 1refstepcounterlinecnt \
& Automatic Entry 2refstepcounterlinecnt \
& Automatic Entry 3refstepcounterlinecnt \
& Automatic Entry 4refstepcounterlinecntlabelstep1 \
endtabular

endtable


enddocument


enter image description here



On the other hand, the following table is more readable:



documentclassscrbook

usepackage[T1]fontenc
usepackage[utf8]inputenc
usepackage[ngerman]babel
usepackagelmodern

usepackagetabularx
usepackagebooktabs

begindocument

begintable

begintabularxtextwidthlX
toprule
textbfField & textbfEntries \
midrule
This Field
& Entry 1 \
& Entry 2 \
& Entry 3 \
& Entry 4 \
midrule
Another Field
& Automatic Entry 1 \
& Automatic Entry 2 \
& Automatic Entry 3 \
& Automatic Entry 4 \
bottomrule
endtabularx

endtable

enddocument


There is no need to center the field name, which may actually become ambiguous.



enter image description here






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',
    convertImagesToLinks: false,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    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%2f455527%2fuse-counters-value-after-it-appears-in-the-code%23new-answer', 'question_page');

    );

    Post as a guest






























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    5
    down vote













    By the time you know the final number of the counter, the multirow is already typeset, so you can't do much about it.



    The usual approach in these cases is a two-pass compilation, writing the value of the counter to the .aux file.



    First, in the preamble, we define an initial value for the counter:



    defsavedthelinecnt0


    then, when we know the final value of the counter, we write it to the .aux file, so in the next compilation, at the begindocument this counter is updated to the correct value:



    immediateprotected@write@auxout
    gdefprotectsavedthelinecntthelinecnt


    then after two passes the value is correct:




    enter image description here




    documentclassscrbook
    usepackagelmodern
    usepackage[T1]fontenc
    usepackage[utf8]inputenc
    usepackage[ngerman]babel
    usepackagetabularx
    usepackagemultirow

    makeatletter
    defsavedthelinecnt0
    makeatother

    begindocument

    newcounterlinecnt

    begintable[tbh]
    begintabularp4.2cm p0.68textwidth
    textbfField & textbfEntries \
    hline
    multirow44cmThis Field
    & Entry 1 \
    & Entry 2 \
    & Entry 3 \
    & Entry 4 \[2ex]
    multirowsavedthelinecnt4cmAnother Field savedthelinecnt
    & Automatic Entry 1 stepcounterlinecnt \
    & Automatic Entry 2 stepcounterlinecnt \
    & Automatic Entry 3 stepcounterlinecnt \
    & Automatic Entry 4 stepcounterlinecnt \
    endtabular
    makeatletter
    immediateprotected@write@auxout
    gdefprotectsavedthelinecntthelinecnt
    endtable

    enddocument



    By the way, the [tbh] optional argument you passed to tabular is (kind of) invalid. If you meant the float positions top, bottom and here, then you need to pass the arguments to begintable. If you meant the vertical position of the baseline of the table, then the valid options are t for top, b for bottom, and c (anything else, actually) for centered. But only one character is passed here.






    share|improve this answer






















    • You're completely right about the tbh ;) I just came up with this MWE really quickly and didn't care a lot about anything other than the multirow-environment
      – Michael Schmid
      28 mins ago














    up vote
    5
    down vote













    By the time you know the final number of the counter, the multirow is already typeset, so you can't do much about it.



    The usual approach in these cases is a two-pass compilation, writing the value of the counter to the .aux file.



    First, in the preamble, we define an initial value for the counter:



    defsavedthelinecnt0


    then, when we know the final value of the counter, we write it to the .aux file, so in the next compilation, at the begindocument this counter is updated to the correct value:



    immediateprotected@write@auxout
    gdefprotectsavedthelinecntthelinecnt


    then after two passes the value is correct:




    enter image description here




    documentclassscrbook
    usepackagelmodern
    usepackage[T1]fontenc
    usepackage[utf8]inputenc
    usepackage[ngerman]babel
    usepackagetabularx
    usepackagemultirow

    makeatletter
    defsavedthelinecnt0
    makeatother

    begindocument

    newcounterlinecnt

    begintable[tbh]
    begintabularp4.2cm p0.68textwidth
    textbfField & textbfEntries \
    hline
    multirow44cmThis Field
    & Entry 1 \
    & Entry 2 \
    & Entry 3 \
    & Entry 4 \[2ex]
    multirowsavedthelinecnt4cmAnother Field savedthelinecnt
    & Automatic Entry 1 stepcounterlinecnt \
    & Automatic Entry 2 stepcounterlinecnt \
    & Automatic Entry 3 stepcounterlinecnt \
    & Automatic Entry 4 stepcounterlinecnt \
    endtabular
    makeatletter
    immediateprotected@write@auxout
    gdefprotectsavedthelinecntthelinecnt
    endtable

    enddocument



    By the way, the [tbh] optional argument you passed to tabular is (kind of) invalid. If you meant the float positions top, bottom and here, then you need to pass the arguments to begintable. If you meant the vertical position of the baseline of the table, then the valid options are t for top, b for bottom, and c (anything else, actually) for centered. But only one character is passed here.






    share|improve this answer






















    • You're completely right about the tbh ;) I just came up with this MWE really quickly and didn't care a lot about anything other than the multirow-environment
      – Michael Schmid
      28 mins ago












    up vote
    5
    down vote










    up vote
    5
    down vote









    By the time you know the final number of the counter, the multirow is already typeset, so you can't do much about it.



    The usual approach in these cases is a two-pass compilation, writing the value of the counter to the .aux file.



    First, in the preamble, we define an initial value for the counter:



    defsavedthelinecnt0


    then, when we know the final value of the counter, we write it to the .aux file, so in the next compilation, at the begindocument this counter is updated to the correct value:



    immediateprotected@write@auxout
    gdefprotectsavedthelinecntthelinecnt


    then after two passes the value is correct:




    enter image description here




    documentclassscrbook
    usepackagelmodern
    usepackage[T1]fontenc
    usepackage[utf8]inputenc
    usepackage[ngerman]babel
    usepackagetabularx
    usepackagemultirow

    makeatletter
    defsavedthelinecnt0
    makeatother

    begindocument

    newcounterlinecnt

    begintable[tbh]
    begintabularp4.2cm p0.68textwidth
    textbfField & textbfEntries \
    hline
    multirow44cmThis Field
    & Entry 1 \
    & Entry 2 \
    & Entry 3 \
    & Entry 4 \[2ex]
    multirowsavedthelinecnt4cmAnother Field savedthelinecnt
    & Automatic Entry 1 stepcounterlinecnt \
    & Automatic Entry 2 stepcounterlinecnt \
    & Automatic Entry 3 stepcounterlinecnt \
    & Automatic Entry 4 stepcounterlinecnt \
    endtabular
    makeatletter
    immediateprotected@write@auxout
    gdefprotectsavedthelinecntthelinecnt
    endtable

    enddocument



    By the way, the [tbh] optional argument you passed to tabular is (kind of) invalid. If you meant the float positions top, bottom and here, then you need to pass the arguments to begintable. If you meant the vertical position of the baseline of the table, then the valid options are t for top, b for bottom, and c (anything else, actually) for centered. But only one character is passed here.






    share|improve this answer














    By the time you know the final number of the counter, the multirow is already typeset, so you can't do much about it.



    The usual approach in these cases is a two-pass compilation, writing the value of the counter to the .aux file.



    First, in the preamble, we define an initial value for the counter:



    defsavedthelinecnt0


    then, when we know the final value of the counter, we write it to the .aux file, so in the next compilation, at the begindocument this counter is updated to the correct value:



    immediateprotected@write@auxout
    gdefprotectsavedthelinecntthelinecnt


    then after two passes the value is correct:




    enter image description here




    documentclassscrbook
    usepackagelmodern
    usepackage[T1]fontenc
    usepackage[utf8]inputenc
    usepackage[ngerman]babel
    usepackagetabularx
    usepackagemultirow

    makeatletter
    defsavedthelinecnt0
    makeatother

    begindocument

    newcounterlinecnt

    begintable[tbh]
    begintabularp4.2cm p0.68textwidth
    textbfField & textbfEntries \
    hline
    multirow44cmThis Field
    & Entry 1 \
    & Entry 2 \
    & Entry 3 \
    & Entry 4 \[2ex]
    multirowsavedthelinecnt4cmAnother Field savedthelinecnt
    & Automatic Entry 1 stepcounterlinecnt \
    & Automatic Entry 2 stepcounterlinecnt \
    & Automatic Entry 3 stepcounterlinecnt \
    & Automatic Entry 4 stepcounterlinecnt \
    endtabular
    makeatletter
    immediateprotected@write@auxout
    gdefprotectsavedthelinecntthelinecnt
    endtable

    enddocument



    By the way, the [tbh] optional argument you passed to tabular is (kind of) invalid. If you meant the float positions top, bottom and here, then you need to pass the arguments to begintable. If you meant the vertical position of the baseline of the table, then the valid options are t for top, b for bottom, and c (anything else, actually) for centered. But only one character is passed here.







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited 35 mins ago

























    answered 42 mins ago









    Phelype Oleinik

    18.5k54173




    18.5k54173











    • You're completely right about the tbh ;) I just came up with this MWE really quickly and didn't care a lot about anything other than the multirow-environment
      – Michael Schmid
      28 mins ago
















    • You're completely right about the tbh ;) I just came up with this MWE really quickly and didn't care a lot about anything other than the multirow-environment
      – Michael Schmid
      28 mins ago















    You're completely right about the tbh ;) I just came up with this MWE really quickly and didn't care a lot about anything other than the multirow-environment
    – Michael Schmid
    28 mins ago




    You're completely right about the tbh ;) I just came up with this MWE really quickly and didn't care a lot about anything other than the multirow-environment
    – Michael Schmid
    28 mins ago










    up vote
    2
    down vote













    Use refcount; note refstepcounter instead of stepcounter. Watch out for spaces: Automatic Entry 1 refstepcounterlinecnt would have a trailing space.



    Note that [tbh] makes no sense for tabular or tabularx. The table environment takes a positioning argument.



    documentclassscrbook

    usepackage[T1]fontenc
    usepackage[utf8]inputenc
    usepackage[ngerman]babel
    usepackagelmodern

    usepackagemultirow
    usepackagerefcount

    newcounterlinecnt

    begindocument

    begintable[htp]

    begintabularp4.2cm p0.68textwidth
    textbfField & textbfEntries \
    hline
    % This works fine:
    multirow44cmThis Field
    & Entry 1 \
    & Entry 2 \
    & Entry 3 \
    & Entry 4 \[2ex]
    multirowgetrefnumberstep14cmAnother Field
    & Automatic Entry 1refstepcounterlinecnt \
    & Automatic Entry 2refstepcounterlinecnt \
    & Automatic Entry 3refstepcounterlinecnt \
    & Automatic Entry 4refstepcounterlinecntlabelstep1 \
    endtabular

    endtable


    enddocument


    enter image description here



    On the other hand, the following table is more readable:



    documentclassscrbook

    usepackage[T1]fontenc
    usepackage[utf8]inputenc
    usepackage[ngerman]babel
    usepackagelmodern

    usepackagetabularx
    usepackagebooktabs

    begindocument

    begintable

    begintabularxtextwidthlX
    toprule
    textbfField & textbfEntries \
    midrule
    This Field
    & Entry 1 \
    & Entry 2 \
    & Entry 3 \
    & Entry 4 \
    midrule
    Another Field
    & Automatic Entry 1 \
    & Automatic Entry 2 \
    & Automatic Entry 3 \
    & Automatic Entry 4 \
    bottomrule
    endtabularx

    endtable

    enddocument


    There is no need to center the field name, which may actually become ambiguous.



    enter image description here






    share|improve this answer


























      up vote
      2
      down vote













      Use refcount; note refstepcounter instead of stepcounter. Watch out for spaces: Automatic Entry 1 refstepcounterlinecnt would have a trailing space.



      Note that [tbh] makes no sense for tabular or tabularx. The table environment takes a positioning argument.



      documentclassscrbook

      usepackage[T1]fontenc
      usepackage[utf8]inputenc
      usepackage[ngerman]babel
      usepackagelmodern

      usepackagemultirow
      usepackagerefcount

      newcounterlinecnt

      begindocument

      begintable[htp]

      begintabularp4.2cm p0.68textwidth
      textbfField & textbfEntries \
      hline
      % This works fine:
      multirow44cmThis Field
      & Entry 1 \
      & Entry 2 \
      & Entry 3 \
      & Entry 4 \[2ex]
      multirowgetrefnumberstep14cmAnother Field
      & Automatic Entry 1refstepcounterlinecnt \
      & Automatic Entry 2refstepcounterlinecnt \
      & Automatic Entry 3refstepcounterlinecnt \
      & Automatic Entry 4refstepcounterlinecntlabelstep1 \
      endtabular

      endtable


      enddocument


      enter image description here



      On the other hand, the following table is more readable:



      documentclassscrbook

      usepackage[T1]fontenc
      usepackage[utf8]inputenc
      usepackage[ngerman]babel
      usepackagelmodern

      usepackagetabularx
      usepackagebooktabs

      begindocument

      begintable

      begintabularxtextwidthlX
      toprule
      textbfField & textbfEntries \
      midrule
      This Field
      & Entry 1 \
      & Entry 2 \
      & Entry 3 \
      & Entry 4 \
      midrule
      Another Field
      & Automatic Entry 1 \
      & Automatic Entry 2 \
      & Automatic Entry 3 \
      & Automatic Entry 4 \
      bottomrule
      endtabularx

      endtable

      enddocument


      There is no need to center the field name, which may actually become ambiguous.



      enter image description here






      share|improve this answer
























        up vote
        2
        down vote










        up vote
        2
        down vote









        Use refcount; note refstepcounter instead of stepcounter. Watch out for spaces: Automatic Entry 1 refstepcounterlinecnt would have a trailing space.



        Note that [tbh] makes no sense for tabular or tabularx. The table environment takes a positioning argument.



        documentclassscrbook

        usepackage[T1]fontenc
        usepackage[utf8]inputenc
        usepackage[ngerman]babel
        usepackagelmodern

        usepackagemultirow
        usepackagerefcount

        newcounterlinecnt

        begindocument

        begintable[htp]

        begintabularp4.2cm p0.68textwidth
        textbfField & textbfEntries \
        hline
        % This works fine:
        multirow44cmThis Field
        & Entry 1 \
        & Entry 2 \
        & Entry 3 \
        & Entry 4 \[2ex]
        multirowgetrefnumberstep14cmAnother Field
        & Automatic Entry 1refstepcounterlinecnt \
        & Automatic Entry 2refstepcounterlinecnt \
        & Automatic Entry 3refstepcounterlinecnt \
        & Automatic Entry 4refstepcounterlinecntlabelstep1 \
        endtabular

        endtable


        enddocument


        enter image description here



        On the other hand, the following table is more readable:



        documentclassscrbook

        usepackage[T1]fontenc
        usepackage[utf8]inputenc
        usepackage[ngerman]babel
        usepackagelmodern

        usepackagetabularx
        usepackagebooktabs

        begindocument

        begintable

        begintabularxtextwidthlX
        toprule
        textbfField & textbfEntries \
        midrule
        This Field
        & Entry 1 \
        & Entry 2 \
        & Entry 3 \
        & Entry 4 \
        midrule
        Another Field
        & Automatic Entry 1 \
        & Automatic Entry 2 \
        & Automatic Entry 3 \
        & Automatic Entry 4 \
        bottomrule
        endtabularx

        endtable

        enddocument


        There is no need to center the field name, which may actually become ambiguous.



        enter image description here






        share|improve this answer














        Use refcount; note refstepcounter instead of stepcounter. Watch out for spaces: Automatic Entry 1 refstepcounterlinecnt would have a trailing space.



        Note that [tbh] makes no sense for tabular or tabularx. The table environment takes a positioning argument.



        documentclassscrbook

        usepackage[T1]fontenc
        usepackage[utf8]inputenc
        usepackage[ngerman]babel
        usepackagelmodern

        usepackagemultirow
        usepackagerefcount

        newcounterlinecnt

        begindocument

        begintable[htp]

        begintabularp4.2cm p0.68textwidth
        textbfField & textbfEntries \
        hline
        % This works fine:
        multirow44cmThis Field
        & Entry 1 \
        & Entry 2 \
        & Entry 3 \
        & Entry 4 \[2ex]
        multirowgetrefnumberstep14cmAnother Field
        & Automatic Entry 1refstepcounterlinecnt \
        & Automatic Entry 2refstepcounterlinecnt \
        & Automatic Entry 3refstepcounterlinecnt \
        & Automatic Entry 4refstepcounterlinecntlabelstep1 \
        endtabular

        endtable


        enddocument


        enter image description here



        On the other hand, the following table is more readable:



        documentclassscrbook

        usepackage[T1]fontenc
        usepackage[utf8]inputenc
        usepackage[ngerman]babel
        usepackagelmodern

        usepackagetabularx
        usepackagebooktabs

        begindocument

        begintable

        begintabularxtextwidthlX
        toprule
        textbfField & textbfEntries \
        midrule
        This Field
        & Entry 1 \
        & Entry 2 \
        & Entry 3 \
        & Entry 4 \
        midrule
        Another Field
        & Automatic Entry 1 \
        & Automatic Entry 2 \
        & Automatic Entry 3 \
        & Automatic Entry 4 \
        bottomrule
        endtabularx

        endtable

        enddocument


        There is no need to center the field name, which may actually become ambiguous.



        enter image description here







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited 24 mins ago

























        answered 30 mins ago









        egreg

        689k8518373085




        689k8518373085



























             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f455527%2fuse-counters-value-after-it-appears-in-the-code%23new-answer', 'question_page');

            );

            Post as a guest













































































            Comments

            Popular posts from this blog

            What does second last employer means? [closed]

            List of Gilmore Girls characters

            Confectionery