Table of contents numbering arent correct












3















I am trying to get a table of contents based on the page number (in the footer on the right side) but in some strange way it is counting from the wrong start. It says page 3 instead of 2 and page 4 instead of 3. I have played with the positions of the code but nothing seems to help.



This is my code:



documentclass[11pt, A4]{article}
usepackage[a4paper,top=2cm,hmargin=2cm,bottom=2.9cm,]{geometry}
usepackage{tikz}
usepackage{tikzpagenodes}
usetikzlibrary{calc}
usepackage{fancyhdr}
usepackage{graphicx}
usepackage{xcolor}
usepackage{colortbl}
usepackage[utf8]{inputenc}
usepackage{titletoc}
usepackage[T1]{fontenc}
usepackage{sectsty}
usepackage{float}
usepackage{atbegshi}
makeatletter
renewcommand{@seccntformat}[1]{}
makeatother
renewcommandnumberline[1]{}
setlengthheadheight{48pt}
%lhead{includegraphics[width=5cm]{Afbeeldingen/logo.jpg}}
rhead{}
renewcommand{headrulewidth}{0pt}
renewcommand{contentsname}{Inhoudsopgave}
chapterfont{color[RGB]{227,24,24}}
sectionfont{color[RGB]{227,24,24}}
subsectionfont{color[RGB]{227,24,24}}
definecolor{bcsred}{RGB}{227,24,24}
newcommandFooter{%
begin{tikzpicture}[remember picture, overlay]
node[yshift=1.75cm] at (17, 24.5) {};
draw [line width=0.55mm] (-0.5,-23.5) -- (16.5,-23.5);
node[yshift=1.75cm, text=red] at (1.5, -26) {Test};
node[yshift=1.75cm, text=gray] at (15, -26) {2019-03-21} ;
node[fill=black, text=white, yshift=1.75cm] at (17, -25.5) {thepage};
fill[bcsred]
(current page.south west) -- (current page.south east) --
([yshift=-30pt]current page.south east|-current page text area.south east) --
([yshift=-30pt]current page.south west|-current page text area.south west) -- cycle;
end{tikzpicture}%
}
pagestyle{fancy}
cfoot{}
AtBeginShipout{Footer}
AtBeginShipoutFirst{}
begin{document}
begin{titlepage}
begin{center}
line(1,0){300}\
[0.25in]
hugebfseries Test \
[2mm]
line(1,0){300}\
[1.5cm]
fontfamily{Arial}selectfont
textscLARGE Test\
[1cm]
textscLarge Test \
[12cm]
end{center}
end{titlepage}
setcounter{page}{2}
%newpage
tableofcontents
newpage
section{Test}
newpage
section{Alerts}
end{document}









share|improve this question























  • You should use a4paper as class option instead of A4.

    – JouleV
    Mar 25 at 13:49











  • Welkom bij TeX.SE! There is a setcounter{page}{2} in your code (just before tableofcontents), that might be the problem? Try setting it to 1 or just remove the command.

    – Marijn
    Mar 25 at 14:03











  • @Marijn I have tried that before, i have tried it to set it to 1 and 0 but nothing seems to work. I also placed it on different places in my code, before tableofcontent and after. On the top of my code and after /document but nothing worked so far. I dont understand why it takes the wrong page number it so confusing. If i change it to 1 then the table of contents is correct but then the page numbering in the footer is wrong and says number 1 on two pages before it goes to 2.

    – Stranger543210
    Mar 25 at 14:05


















3















I am trying to get a table of contents based on the page number (in the footer on the right side) but in some strange way it is counting from the wrong start. It says page 3 instead of 2 and page 4 instead of 3. I have played with the positions of the code but nothing seems to help.



This is my code:



documentclass[11pt, A4]{article}
usepackage[a4paper,top=2cm,hmargin=2cm,bottom=2.9cm,]{geometry}
usepackage{tikz}
usepackage{tikzpagenodes}
usetikzlibrary{calc}
usepackage{fancyhdr}
usepackage{graphicx}
usepackage{xcolor}
usepackage{colortbl}
usepackage[utf8]{inputenc}
usepackage{titletoc}
usepackage[T1]{fontenc}
usepackage{sectsty}
usepackage{float}
usepackage{atbegshi}
makeatletter
renewcommand{@seccntformat}[1]{}
makeatother
renewcommandnumberline[1]{}
setlengthheadheight{48pt}
%lhead{includegraphics[width=5cm]{Afbeeldingen/logo.jpg}}
rhead{}
renewcommand{headrulewidth}{0pt}
renewcommand{contentsname}{Inhoudsopgave}
chapterfont{color[RGB]{227,24,24}}
sectionfont{color[RGB]{227,24,24}}
subsectionfont{color[RGB]{227,24,24}}
definecolor{bcsred}{RGB}{227,24,24}
newcommandFooter{%
begin{tikzpicture}[remember picture, overlay]
node[yshift=1.75cm] at (17, 24.5) {};
draw [line width=0.55mm] (-0.5,-23.5) -- (16.5,-23.5);
node[yshift=1.75cm, text=red] at (1.5, -26) {Test};
node[yshift=1.75cm, text=gray] at (15, -26) {2019-03-21} ;
node[fill=black, text=white, yshift=1.75cm] at (17, -25.5) {thepage};
fill[bcsred]
(current page.south west) -- (current page.south east) --
([yshift=-30pt]current page.south east|-current page text area.south east) --
([yshift=-30pt]current page.south west|-current page text area.south west) -- cycle;
end{tikzpicture}%
}
pagestyle{fancy}
cfoot{}
AtBeginShipout{Footer}
AtBeginShipoutFirst{}
begin{document}
begin{titlepage}
begin{center}
line(1,0){300}\
[0.25in]
hugebfseries Test \
[2mm]
line(1,0){300}\
[1.5cm]
fontfamily{Arial}selectfont
textscLARGE Test\
[1cm]
textscLarge Test \
[12cm]
end{center}
end{titlepage}
setcounter{page}{2}
%newpage
tableofcontents
newpage
section{Test}
newpage
section{Alerts}
end{document}









share|improve this question























  • You should use a4paper as class option instead of A4.

    – JouleV
    Mar 25 at 13:49











  • Welkom bij TeX.SE! There is a setcounter{page}{2} in your code (just before tableofcontents), that might be the problem? Try setting it to 1 or just remove the command.

    – Marijn
    Mar 25 at 14:03











  • @Marijn I have tried that before, i have tried it to set it to 1 and 0 but nothing seems to work. I also placed it on different places in my code, before tableofcontent and after. On the top of my code and after /document but nothing worked so far. I dont understand why it takes the wrong page number it so confusing. If i change it to 1 then the table of contents is correct but then the page numbering in the footer is wrong and says number 1 on two pages before it goes to 2.

    – Stranger543210
    Mar 25 at 14:05
















3












3








3








I am trying to get a table of contents based on the page number (in the footer on the right side) but in some strange way it is counting from the wrong start. It says page 3 instead of 2 and page 4 instead of 3. I have played with the positions of the code but nothing seems to help.



This is my code:



documentclass[11pt, A4]{article}
usepackage[a4paper,top=2cm,hmargin=2cm,bottom=2.9cm,]{geometry}
usepackage{tikz}
usepackage{tikzpagenodes}
usetikzlibrary{calc}
usepackage{fancyhdr}
usepackage{graphicx}
usepackage{xcolor}
usepackage{colortbl}
usepackage[utf8]{inputenc}
usepackage{titletoc}
usepackage[T1]{fontenc}
usepackage{sectsty}
usepackage{float}
usepackage{atbegshi}
makeatletter
renewcommand{@seccntformat}[1]{}
makeatother
renewcommandnumberline[1]{}
setlengthheadheight{48pt}
%lhead{includegraphics[width=5cm]{Afbeeldingen/logo.jpg}}
rhead{}
renewcommand{headrulewidth}{0pt}
renewcommand{contentsname}{Inhoudsopgave}
chapterfont{color[RGB]{227,24,24}}
sectionfont{color[RGB]{227,24,24}}
subsectionfont{color[RGB]{227,24,24}}
definecolor{bcsred}{RGB}{227,24,24}
newcommandFooter{%
begin{tikzpicture}[remember picture, overlay]
node[yshift=1.75cm] at (17, 24.5) {};
draw [line width=0.55mm] (-0.5,-23.5) -- (16.5,-23.5);
node[yshift=1.75cm, text=red] at (1.5, -26) {Test};
node[yshift=1.75cm, text=gray] at (15, -26) {2019-03-21} ;
node[fill=black, text=white, yshift=1.75cm] at (17, -25.5) {thepage};
fill[bcsred]
(current page.south west) -- (current page.south east) --
([yshift=-30pt]current page.south east|-current page text area.south east) --
([yshift=-30pt]current page.south west|-current page text area.south west) -- cycle;
end{tikzpicture}%
}
pagestyle{fancy}
cfoot{}
AtBeginShipout{Footer}
AtBeginShipoutFirst{}
begin{document}
begin{titlepage}
begin{center}
line(1,0){300}\
[0.25in]
hugebfseries Test \
[2mm]
line(1,0){300}\
[1.5cm]
fontfamily{Arial}selectfont
textscLARGE Test\
[1cm]
textscLarge Test \
[12cm]
end{center}
end{titlepage}
setcounter{page}{2}
%newpage
tableofcontents
newpage
section{Test}
newpage
section{Alerts}
end{document}









share|improve this question














I am trying to get a table of contents based on the page number (in the footer on the right side) but in some strange way it is counting from the wrong start. It says page 3 instead of 2 and page 4 instead of 3. I have played with the positions of the code but nothing seems to help.



This is my code:



documentclass[11pt, A4]{article}
usepackage[a4paper,top=2cm,hmargin=2cm,bottom=2.9cm,]{geometry}
usepackage{tikz}
usepackage{tikzpagenodes}
usetikzlibrary{calc}
usepackage{fancyhdr}
usepackage{graphicx}
usepackage{xcolor}
usepackage{colortbl}
usepackage[utf8]{inputenc}
usepackage{titletoc}
usepackage[T1]{fontenc}
usepackage{sectsty}
usepackage{float}
usepackage{atbegshi}
makeatletter
renewcommand{@seccntformat}[1]{}
makeatother
renewcommandnumberline[1]{}
setlengthheadheight{48pt}
%lhead{includegraphics[width=5cm]{Afbeeldingen/logo.jpg}}
rhead{}
renewcommand{headrulewidth}{0pt}
renewcommand{contentsname}{Inhoudsopgave}
chapterfont{color[RGB]{227,24,24}}
sectionfont{color[RGB]{227,24,24}}
subsectionfont{color[RGB]{227,24,24}}
definecolor{bcsred}{RGB}{227,24,24}
newcommandFooter{%
begin{tikzpicture}[remember picture, overlay]
node[yshift=1.75cm] at (17, 24.5) {};
draw [line width=0.55mm] (-0.5,-23.5) -- (16.5,-23.5);
node[yshift=1.75cm, text=red] at (1.5, -26) {Test};
node[yshift=1.75cm, text=gray] at (15, -26) {2019-03-21} ;
node[fill=black, text=white, yshift=1.75cm] at (17, -25.5) {thepage};
fill[bcsred]
(current page.south west) -- (current page.south east) --
([yshift=-30pt]current page.south east|-current page text area.south east) --
([yshift=-30pt]current page.south west|-current page text area.south west) -- cycle;
end{tikzpicture}%
}
pagestyle{fancy}
cfoot{}
AtBeginShipout{Footer}
AtBeginShipoutFirst{}
begin{document}
begin{titlepage}
begin{center}
line(1,0){300}\
[0.25in]
hugebfseries Test \
[2mm]
line(1,0){300}\
[1.5cm]
fontfamily{Arial}selectfont
textscLARGE Test\
[1cm]
textscLarge Test \
[12cm]
end{center}
end{titlepage}
setcounter{page}{2}
%newpage
tableofcontents
newpage
section{Test}
newpage
section{Alerts}
end{document}






table-of-contents






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 25 at 13:48









Stranger543210Stranger543210

183




183













  • You should use a4paper as class option instead of A4.

    – JouleV
    Mar 25 at 13:49











  • Welkom bij TeX.SE! There is a setcounter{page}{2} in your code (just before tableofcontents), that might be the problem? Try setting it to 1 or just remove the command.

    – Marijn
    Mar 25 at 14:03











  • @Marijn I have tried that before, i have tried it to set it to 1 and 0 but nothing seems to work. I also placed it on different places in my code, before tableofcontent and after. On the top of my code and after /document but nothing worked so far. I dont understand why it takes the wrong page number it so confusing. If i change it to 1 then the table of contents is correct but then the page numbering in the footer is wrong and says number 1 on two pages before it goes to 2.

    – Stranger543210
    Mar 25 at 14:05





















  • You should use a4paper as class option instead of A4.

    – JouleV
    Mar 25 at 13:49











  • Welkom bij TeX.SE! There is a setcounter{page}{2} in your code (just before tableofcontents), that might be the problem? Try setting it to 1 or just remove the command.

    – Marijn
    Mar 25 at 14:03











  • @Marijn I have tried that before, i have tried it to set it to 1 and 0 but nothing seems to work. I also placed it on different places in my code, before tableofcontent and after. On the top of my code and after /document but nothing worked so far. I dont understand why it takes the wrong page number it so confusing. If i change it to 1 then the table of contents is correct but then the page numbering in the footer is wrong and says number 1 on two pages before it goes to 2.

    – Stranger543210
    Mar 25 at 14:05



















You should use a4paper as class option instead of A4.

– JouleV
Mar 25 at 13:49





You should use a4paper as class option instead of A4.

– JouleV
Mar 25 at 13:49













Welkom bij TeX.SE! There is a setcounter{page}{2} in your code (just before tableofcontents), that might be the problem? Try setting it to 1 or just remove the command.

– Marijn
Mar 25 at 14:03





Welkom bij TeX.SE! There is a setcounter{page}{2} in your code (just before tableofcontents), that might be the problem? Try setting it to 1 or just remove the command.

– Marijn
Mar 25 at 14:03













@Marijn I have tried that before, i have tried it to set it to 1 and 0 but nothing seems to work. I also placed it on different places in my code, before tableofcontent and after. On the top of my code and after /document but nothing worked so far. I dont understand why it takes the wrong page number it so confusing. If i change it to 1 then the table of contents is correct but then the page numbering in the footer is wrong and says number 1 on two pages before it goes to 2.

– Stranger543210
Mar 25 at 14:05







@Marijn I have tried that before, i have tried it to set it to 1 and 0 but nothing seems to work. I also placed it on different places in my code, before tableofcontent and after. On the top of my code and after /document but nothing worked so far. I dont understand why it takes the wrong page number it so confusing. If i change it to 1 then the table of contents is correct but then the page numbering in the footer is wrong and says number 1 on two pages before it goes to 2.

– Stranger543210
Mar 25 at 14:05












1 Answer
1






active

oldest

votes


















1














The code in the question uses the page number during the AtBeginShipout call. This is tricky because the page counter is modified by different macros and hooks at various times, which makes it difficult to always get the correct value during page shipout.



As an alternative you can use a custom counter that is displayed and increased in the Footer macro, which is responsible for the page number in the box, independent from the actual page counter. The 'real' page counter is still used for the numbers in the Table of Contents.



Partial code:



newcounter{mypagenumber}
setcounter{mypagenumber}{1}
newcommandFooter{%
begin{tikzpicture}[remember picture, overlay]
node[yshift=1.75cm] at (17, 24.5) {};
draw [line width=0.55mm] (-0.5,-23.5) -- (16.5,-23.5);
node[yshift=1.75cm, text=red] at (1.5, -26) {Test};
node[yshift=1.75cm, text=gray] at (15, -26) {2019-03-21} ;
node[fill=black, text=white, yshift=1.75cm] at (17, -25.5) {themypagenumber};
fill[bcsred]
(current page.south west) -- (current page.south east) --
([yshift=-30pt]current page.south east|-current page text area.south east) --
([yshift=-30pt]current page.south west|-current page text area.south west) -- cycle;
end{tikzpicture}%
stepcounter{mypagenumber}
}


Result:



enter image description here



The next pages also show the correct number, consistent with the Table of Contents (i.e., 2, 3, etc., not shown in the screenshot).



Note that there is a different problem with the footer macro that adds an empty page with only a header and footer at the end, but that is most likely unrelated to the page counter issue.






share|improve this answer
























  • Thanks for your reply, i will check it now

    – Stranger543210
    Mar 26 at 12:23











  • I get the following error: Runaway argument? {newcounter {mypagenumber} setcounter {mypagenumber}{1} newcommand ETC. ! File ended while scanning use of @argdef. <inserted text> par <*> rapportage2.tex ? ! Emergency stop. <inserted text> par <*> rapportage2.tex

    – Stranger543210
    Mar 26 at 12:29













  • Let's debug in chat, chat.stackexchange.com/rooms/91547/…

    – Marijn
    Mar 26 at 12:33











  • i can not talk to you, my reputation is too low :( need 20

    – Stranger543210
    Mar 26 at 12:35











  • Thank you it works! found the solution

    – Stranger543210
    Mar 26 at 12:39












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%2f481352%2ftable-of-contents-numbering-arent-correct%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














The code in the question uses the page number during the AtBeginShipout call. This is tricky because the page counter is modified by different macros and hooks at various times, which makes it difficult to always get the correct value during page shipout.



As an alternative you can use a custom counter that is displayed and increased in the Footer macro, which is responsible for the page number in the box, independent from the actual page counter. The 'real' page counter is still used for the numbers in the Table of Contents.



Partial code:



newcounter{mypagenumber}
setcounter{mypagenumber}{1}
newcommandFooter{%
begin{tikzpicture}[remember picture, overlay]
node[yshift=1.75cm] at (17, 24.5) {};
draw [line width=0.55mm] (-0.5,-23.5) -- (16.5,-23.5);
node[yshift=1.75cm, text=red] at (1.5, -26) {Test};
node[yshift=1.75cm, text=gray] at (15, -26) {2019-03-21} ;
node[fill=black, text=white, yshift=1.75cm] at (17, -25.5) {themypagenumber};
fill[bcsred]
(current page.south west) -- (current page.south east) --
([yshift=-30pt]current page.south east|-current page text area.south east) --
([yshift=-30pt]current page.south west|-current page text area.south west) -- cycle;
end{tikzpicture}%
stepcounter{mypagenumber}
}


Result:



enter image description here



The next pages also show the correct number, consistent with the Table of Contents (i.e., 2, 3, etc., not shown in the screenshot).



Note that there is a different problem with the footer macro that adds an empty page with only a header and footer at the end, but that is most likely unrelated to the page counter issue.






share|improve this answer
























  • Thanks for your reply, i will check it now

    – Stranger543210
    Mar 26 at 12:23











  • I get the following error: Runaway argument? {newcounter {mypagenumber} setcounter {mypagenumber}{1} newcommand ETC. ! File ended while scanning use of @argdef. <inserted text> par <*> rapportage2.tex ? ! Emergency stop. <inserted text> par <*> rapportage2.tex

    – Stranger543210
    Mar 26 at 12:29













  • Let's debug in chat, chat.stackexchange.com/rooms/91547/…

    – Marijn
    Mar 26 at 12:33











  • i can not talk to you, my reputation is too low :( need 20

    – Stranger543210
    Mar 26 at 12:35











  • Thank you it works! found the solution

    – Stranger543210
    Mar 26 at 12:39
















1














The code in the question uses the page number during the AtBeginShipout call. This is tricky because the page counter is modified by different macros and hooks at various times, which makes it difficult to always get the correct value during page shipout.



As an alternative you can use a custom counter that is displayed and increased in the Footer macro, which is responsible for the page number in the box, independent from the actual page counter. The 'real' page counter is still used for the numbers in the Table of Contents.



Partial code:



newcounter{mypagenumber}
setcounter{mypagenumber}{1}
newcommandFooter{%
begin{tikzpicture}[remember picture, overlay]
node[yshift=1.75cm] at (17, 24.5) {};
draw [line width=0.55mm] (-0.5,-23.5) -- (16.5,-23.5);
node[yshift=1.75cm, text=red] at (1.5, -26) {Test};
node[yshift=1.75cm, text=gray] at (15, -26) {2019-03-21} ;
node[fill=black, text=white, yshift=1.75cm] at (17, -25.5) {themypagenumber};
fill[bcsred]
(current page.south west) -- (current page.south east) --
([yshift=-30pt]current page.south east|-current page text area.south east) --
([yshift=-30pt]current page.south west|-current page text area.south west) -- cycle;
end{tikzpicture}%
stepcounter{mypagenumber}
}


Result:



enter image description here



The next pages also show the correct number, consistent with the Table of Contents (i.e., 2, 3, etc., not shown in the screenshot).



Note that there is a different problem with the footer macro that adds an empty page with only a header and footer at the end, but that is most likely unrelated to the page counter issue.






share|improve this answer
























  • Thanks for your reply, i will check it now

    – Stranger543210
    Mar 26 at 12:23











  • I get the following error: Runaway argument? {newcounter {mypagenumber} setcounter {mypagenumber}{1} newcommand ETC. ! File ended while scanning use of @argdef. <inserted text> par <*> rapportage2.tex ? ! Emergency stop. <inserted text> par <*> rapportage2.tex

    – Stranger543210
    Mar 26 at 12:29













  • Let's debug in chat, chat.stackexchange.com/rooms/91547/…

    – Marijn
    Mar 26 at 12:33











  • i can not talk to you, my reputation is too low :( need 20

    – Stranger543210
    Mar 26 at 12:35











  • Thank you it works! found the solution

    – Stranger543210
    Mar 26 at 12:39














1












1








1







The code in the question uses the page number during the AtBeginShipout call. This is tricky because the page counter is modified by different macros and hooks at various times, which makes it difficult to always get the correct value during page shipout.



As an alternative you can use a custom counter that is displayed and increased in the Footer macro, which is responsible for the page number in the box, independent from the actual page counter. The 'real' page counter is still used for the numbers in the Table of Contents.



Partial code:



newcounter{mypagenumber}
setcounter{mypagenumber}{1}
newcommandFooter{%
begin{tikzpicture}[remember picture, overlay]
node[yshift=1.75cm] at (17, 24.5) {};
draw [line width=0.55mm] (-0.5,-23.5) -- (16.5,-23.5);
node[yshift=1.75cm, text=red] at (1.5, -26) {Test};
node[yshift=1.75cm, text=gray] at (15, -26) {2019-03-21} ;
node[fill=black, text=white, yshift=1.75cm] at (17, -25.5) {themypagenumber};
fill[bcsred]
(current page.south west) -- (current page.south east) --
([yshift=-30pt]current page.south east|-current page text area.south east) --
([yshift=-30pt]current page.south west|-current page text area.south west) -- cycle;
end{tikzpicture}%
stepcounter{mypagenumber}
}


Result:



enter image description here



The next pages also show the correct number, consistent with the Table of Contents (i.e., 2, 3, etc., not shown in the screenshot).



Note that there is a different problem with the footer macro that adds an empty page with only a header and footer at the end, but that is most likely unrelated to the page counter issue.






share|improve this answer













The code in the question uses the page number during the AtBeginShipout call. This is tricky because the page counter is modified by different macros and hooks at various times, which makes it difficult to always get the correct value during page shipout.



As an alternative you can use a custom counter that is displayed and increased in the Footer macro, which is responsible for the page number in the box, independent from the actual page counter. The 'real' page counter is still used for the numbers in the Table of Contents.



Partial code:



newcounter{mypagenumber}
setcounter{mypagenumber}{1}
newcommandFooter{%
begin{tikzpicture}[remember picture, overlay]
node[yshift=1.75cm] at (17, 24.5) {};
draw [line width=0.55mm] (-0.5,-23.5) -- (16.5,-23.5);
node[yshift=1.75cm, text=red] at (1.5, -26) {Test};
node[yshift=1.75cm, text=gray] at (15, -26) {2019-03-21} ;
node[fill=black, text=white, yshift=1.75cm] at (17, -25.5) {themypagenumber};
fill[bcsred]
(current page.south west) -- (current page.south east) --
([yshift=-30pt]current page.south east|-current page text area.south east) --
([yshift=-30pt]current page.south west|-current page text area.south west) -- cycle;
end{tikzpicture}%
stepcounter{mypagenumber}
}


Result:



enter image description here



The next pages also show the correct number, consistent with the Table of Contents (i.e., 2, 3, etc., not shown in the screenshot).



Note that there is a different problem with the footer macro that adds an empty page with only a header and footer at the end, but that is most likely unrelated to the page counter issue.







share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 25 at 15:42









MarijnMarijn

8,439636




8,439636













  • Thanks for your reply, i will check it now

    – Stranger543210
    Mar 26 at 12:23











  • I get the following error: Runaway argument? {newcounter {mypagenumber} setcounter {mypagenumber}{1} newcommand ETC. ! File ended while scanning use of @argdef. <inserted text> par <*> rapportage2.tex ? ! Emergency stop. <inserted text> par <*> rapportage2.tex

    – Stranger543210
    Mar 26 at 12:29













  • Let's debug in chat, chat.stackexchange.com/rooms/91547/…

    – Marijn
    Mar 26 at 12:33











  • i can not talk to you, my reputation is too low :( need 20

    – Stranger543210
    Mar 26 at 12:35











  • Thank you it works! found the solution

    – Stranger543210
    Mar 26 at 12:39



















  • Thanks for your reply, i will check it now

    – Stranger543210
    Mar 26 at 12:23











  • I get the following error: Runaway argument? {newcounter {mypagenumber} setcounter {mypagenumber}{1} newcommand ETC. ! File ended while scanning use of @argdef. <inserted text> par <*> rapportage2.tex ? ! Emergency stop. <inserted text> par <*> rapportage2.tex

    – Stranger543210
    Mar 26 at 12:29













  • Let's debug in chat, chat.stackexchange.com/rooms/91547/…

    – Marijn
    Mar 26 at 12:33











  • i can not talk to you, my reputation is too low :( need 20

    – Stranger543210
    Mar 26 at 12:35











  • Thank you it works! found the solution

    – Stranger543210
    Mar 26 at 12:39

















Thanks for your reply, i will check it now

– Stranger543210
Mar 26 at 12:23





Thanks for your reply, i will check it now

– Stranger543210
Mar 26 at 12:23













I get the following error: Runaway argument? {newcounter {mypagenumber} setcounter {mypagenumber}{1} newcommand ETC. ! File ended while scanning use of @argdef. <inserted text> par <*> rapportage2.tex ? ! Emergency stop. <inserted text> par <*> rapportage2.tex

– Stranger543210
Mar 26 at 12:29







I get the following error: Runaway argument? {newcounter {mypagenumber} setcounter {mypagenumber}{1} newcommand ETC. ! File ended while scanning use of @argdef. <inserted text> par <*> rapportage2.tex ? ! Emergency stop. <inserted text> par <*> rapportage2.tex

– Stranger543210
Mar 26 at 12:29















Let's debug in chat, chat.stackexchange.com/rooms/91547/…

– Marijn
Mar 26 at 12:33





Let's debug in chat, chat.stackexchange.com/rooms/91547/…

– Marijn
Mar 26 at 12:33













i can not talk to you, my reputation is too low :( need 20

– Stranger543210
Mar 26 at 12:35





i can not talk to you, my reputation is too low :( need 20

– Stranger543210
Mar 26 at 12:35













Thank you it works! found the solution

– Stranger543210
Mar 26 at 12:39





Thank you it works! found the solution

– Stranger543210
Mar 26 at 12:39


















draft saved

draft discarded




















































Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f481352%2ftable-of-contents-numbering-arent-correct%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

How to change which sound is reproduced for terminal bell?

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

Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents