Skip to content
Snippets Groups Projects
Commit 156b88b6 authored by Veli Mäkinen's avatar Veli Mäkinen
Browse files

Merge branch 'new-counter-2020' into 'master'

New counter code

See merge request cs/thesis-template!3
parents f27e59dd 98f357a2
No related branches found
No related tags found
No related merge requests found
...@@ -225,7 +225,7 @@ additional insight. ...@@ -225,7 +225,7 @@ additional insight.
% Place ToC % Place ToC
\newpage \newpage
\mytableofcontents \mytableofcontents
\frontmatter \mainmatter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% STEP 4: Write the thesis. %% STEP 4: Write the thesis.
......
...@@ -368,7 +368,7 @@ ...@@ -368,7 +368,7 @@
{\translate{department2018}} {\translate{department2018}}
\renewcommand{\oppiaine}{{Koulutusohjelma --- Utbildningsprogram --- Study programme}} \renewcommand{\oppiaine}{{Koulutusohjelma --- Utbildningsprogram --- Study programme}}
\renewcommand{\getSubject}{\programme} \renewcommand{\getSubject}{\programme}
\providecommand{\track}{} \providecommand{\track}{}
\fi \fi
\if@tktl \if@tktl
\newcommand{\level}% \newcommand{\level}%
...@@ -383,7 +383,7 @@ ...@@ -383,7 +383,7 @@
% VM: poistin "oppiaineeseen laitos" lisäämällä allaolevan % VM: poistin "oppiaineeseen laitos" lisäämällä allaolevan
\renewcommand{\department}{\programme} \renewcommand{\department}{\programme}
\renewcommand{\getSubject}{\programme} \renewcommand{\getSubject}{\programme}
\providecommand{\track}{} \providecommand{\track}{}
\fi \fi
\if@cs \if@cs
\renewcommand\subject{\translate{\track}} \renewcommand\subject{\translate{\track}}
...@@ -436,6 +436,12 @@ ...@@ -436,6 +436,12 @@
\usepackage{amsmath, amssymb} % For better math \usepackage{amsmath, amssymb} % For better math
\usepackage[footnotesize,bf]{caption} % For more control over figure captions \usepackage[footnotesize,bf]{caption} % For more control over figure captions
\usepackage{blindtext} \usepackage{blindtext}
\usepackage{everyshi}
\newtoggle{mainmatter}
\newtoggle{backmatter}
\togglefalse{mainmatter}
\togglefalse{backmatter}
\newcommand{\frontmatter}{ \newcommand{\frontmatter}{
\setcounter{page}{1} \setcounter{page}{1}
...@@ -444,24 +450,30 @@ ...@@ -444,24 +450,30 @@
\newcommand{\mainmatter}{ \newcommand{\mainmatter}{
\cleardoublepage \toggletrue{mainmatter}
\thispagestyle{empty} \thispagestyle{empty}
\pagenumbering{arabic} \pagenumbering{arabic}
\setcounter{page}{1} \setcounter{page}{1}
} }
\newcommand{\backmatter}{% \newcommand{\backmatter}{%
\addtocounter{numberofappendixes}{1} \clearpage % needed so that mainmatter is fully flushed before turning off the counter
\setcounter{numberofpages}{\value{page}} \togglefalse{mainmatter}
\addtocontents{toc}{\cftpagenumbersoff{chapter}} \addtocontents{toc}{\cftpagenumbersoff{chapter}}
\cleardoublepage \cleardoublepage
\toggletrue{backmatter}
\titleformat{\chapter}{\large\bfseries}{\chaptertitlename\space\thechapter\newline}{0.5em}{\setcounter{page}{1}\pagenumbering{roman}\markboth{\chaptertitlename\space\thechapter}{\chaptertitlename \space\thechapter}\label{Appendix.\thechapter}\thispagestyle{empty}} \titleformat{\chapter}{\large\bfseries}{\chaptertitlename\space\thechapter\newline}{0.5em}{\setcounter{page}{1}\pagenumbering{roman}\markboth{\chaptertitlename\space\thechapter}{\chaptertitlename \space\thechapter}\label{Appendix.\thechapter}\thispagestyle{empty}}
% \titleformat{\chapter}{\Huge\bfseries}{\chaptertitlename\space\thechapter\newline}{0.5em}{\setcounter{page}{1}\pagenumbering{arabic}\markboth{}{}\label{Appendix.\thechapter}} % \titleformat{\chapter}{\Huge\bfseries}{\chaptertitlename\space\thechapter\newline}{0.5em}{\setcounter{page}{1}\pagenumbering{arabic}\markboth{}{}\label{Appendix.\thechapter}}
\thispagestyle{empty} \thispagestyle{empty}
} }
\EveryShipout{%
\iftoggle{mainmatter}{\stepcounter{numberofpages}}{}%
\iftoggle{backmatter}{\stepcounter{numberofappendixpages}{}}
}
% Additions and changes for document key terms. % Additions and changes for document key terms.
...@@ -519,48 +531,22 @@ ...@@ -519,48 +531,22 @@
\renewcommand*{\thefootnote}{\fnsymbol{footnote}} %footnote symbols for one page only \renewcommand*{\thefootnote}{\fnsymbol{footnote}} %footnote symbols for one page only
\MakePerPage{footnote} \MakePerPage{footnote}
%----------------------------
\AtEndPreamble{%
% user command to ask for the value
\providecommand{\recallcounter}[1]{\@ifundefined{stored@#1}{Rerun or fix for number of pages info in abstract}{\csname stored@#1\endcsname}}
% used at the aux
\providecommand{\restorecounter}[2]{\expandafter\gdef\csname stored@#1\endcsname{#2}}
\providecommand\recalltext[1]{\if{mytext@#1}\@nameuse{mytext@#1}\fi}
}% end of end preamble
\newcommand{\numberofpagesinformation}[1]{
\gdef\@numberofpagesinformation{#1}
}
\numberofpagesinformation{}
\newcommand{\pagesInformation}[1]{
\gdef\@pagesInformation{#1}
}
\pagesInformation{}
%%%%%% Appendices %%%%%%% %%%%%% Appendices %%%%%%%
\newcounter{appendixPagesCounter} \newcounter{appendixPagesCounter}
\setcounter{appendixPagesCounter}{0}% \setcounter{appendixPagesCounter}{0}%
\let\oldappendix\appendix
\renewcommand{\appendix}[1]{
\addtocounter{appendixPagesCounter}{\value{page}}%
\typeout{***appendixPagesCounter \theappendixPagesCounter}
\let\oldappendix\appendix
\renewcommand{\appendix}[1]{
%TM: This one set the last page of each appendix to 1, which kinda is not what one wants %TM: This one set the last page of each appendix to 1, which kinda is not what one wants
%TM:- \setcounter{page}{1}% %TM:- \setcounter{page}{1}%
\chapter{#1} \chapter{#1}
} }
\renewcommand{\appendices}{% \renewcommand{\appendices}{%
\setcounter{page}{-1}% %\setcounter{page}{-1}%
% \setcounter{appendix}{1}% % \setcounter{appendix}{1}%
% \newpage % \newpage
% %\pagestyle{empty} % %\pagestyle{empty}
...@@ -584,86 +570,27 @@ ...@@ -584,86 +570,27 @@
\DefineBibliographyStrings{swedish}{% \DefineBibliographyStrings{swedish}{%
editor = {red.}, editor = {red.},
editors = {red.}, editors = {red.},
bibliography = {Referenser} bibliography = {Referenser}
} }
} }
\newcounter{selfdefined}
\newcounter{numberofpages} \newcounter{numberofpages}
\newcounter{numberofappendixes}
\newcounter{numberofappendixpages} \newcounter{numberofappendixpages}
\newcommand{\numberofpagesinfo}[1]{\gdef\@numberofpagesinfo{#1}} \setcounter{numberofpages}{0}
\newcommand{\numberofappendixesinfo}[1]{\gdef\@numberofappendixesinfo{#1}} \setcounter{numberofappendixpages}{0}
\newcommand{\iffirstrun}{\@ifundefined{notfirstrun}}
\iffirstrun{%
\setcounter{selfdefined}{0}
\setcounter{numberofpages}{0}
\setcounter{numberofappendixes}{0}
\setcounter{numberofappendixpages}{0}
\numberofpagesinfo{}
\numberofappendixesinfo{}
}{%
\ifnumcomp{\value{selfdefined}}{=}{0}{%
% hidden setcounter cmds from aux for all counters above here
\ifnumcomp{\value{numberofappendixes}}{=}{0}%
% view together with same split in \atenddocument
{%
}{% appendixes exist, backmatter takes care of mainmatter pages
\appendixinfo{,\space\arabic{numberofappendixes}\space\@app\space(\arabic{numberofappendixpages}\space\@appno)}
}
}{ % author defined cases handled by separate user command below
% write to aux all texts (note: lang spesific)
% to become available as author command elements
% on the second pdflatex run
% only used as author command
\providecommand{\setnumberofpagesinformation}[1]{
\addtocounter{selfdefined}{1}
\numberofpagesinformation{#1}
}
}
} }
}
\newcounter{appendixpage}
\AtEndDocument{% \AtEndDocument{%
\typeout{***AED Number of Appendices \thenumberofappendixpages}
\immediate\write\@auxout{\string\gdef\string\appendixCount{\thenumberofappendixpages}}
\iffirstrun{ \typeout{***AED Number of pages \thenumberofpages \pp}
\immediate\write\@auxout{\string\gdef\string\pagesCount{\thenumberofpages}}
}{
\addtocounter{appendixPagesCounter}{\value{page}}%
\typeout{***AED Number of Appendices \theappendixPagesCounter}
\immediate\write\@auxout{\string\gdef\string\appendixCount{\theappendixPagesCounter}}
\typeout{***AED Number of pages \thenumberofpages \pp}
\immediate\write\@auxout{\string\gdef\string\pagesCount{\thenumberofpages}}
}
\immediate\write\@auxout{\string\gdef\string\notfirstrun{}}
\ifnumcomp{\value{numberofappendixes}}{=}{0}{%
\setcounter{numberofpages}{\value{page}}
\numberofpagesinfo{\arabic{numberofpages}\space\@pp}
}{%
\setcounter{numberofappendixes}{\value{chapter}}
\addtocounter{numberofappendixpages}{\value{page}}
}
} }
......
...@@ -44,6 +44,6 @@ ...@@ -44,6 +44,6 @@
\providetranslation{supervisors}{Supervisor(s)} \providetranslation{supervisors}{Supervisor(s)}
\providetranslation{examiner}{Examiner(s)} \providetranslation{examiner}{Examiner(s)}
\providetranslation{appendices}{appendices} \providetranslation{appendices}{appendices}
\providetranslation{appendice pages}{appendice pages} \providetranslation{appendice pages}{appendix pages}
\providetranslation{pp}{pages} \providetranslation{pp}{pages}
\providetranslation{seminar}{Seminar} \providetranslation{seminar}{Seminar}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment