Discussion:
How to stop \frontmatter from resetting the counter When using it more than once
(too old to reply)
d***@googlemail.com
2017-06-26 14:48:06 UTC
Permalink
Raw Message
For example say you have something like:

\documentclass[12pt,oneside]{book}
...
...
\frontmatter %labels page numbers for chapters via roman numbers starting at i
\chapter*{Preambles}
\chapter*{Introduction}

\mainmatter %lables page numbers for Arabic numerical starting at 1
\chapter{Chapter 1}
\chapter*{Chapter 2}

\frontmatter %labels page number to continue previous roman numerals, start iii
\chapter*{Bibliography}
\chapter*{Appendix}
...

What code do you put in the preambles to stop it resting the counter when you put it in the second time?
Axel Berger
2017-06-26 15:33:29 UTC
Permalink
Raw Message
Post by d***@googlemail.com
What code do you put in the preambles to stop it resting the counter
when you put it in the second time?
None. Backmatter ist backmatter and should be called such.

The numbering can be set with
\pagenumbering{roman}\setcounter{page}{}

You save the current page in a \newcounter or \newcommand at the end of
your frontmatter, add one and insert it above.

Axel
--
/¯\ No | Dipl.-Ing. F. Axel Berger Tel: +49/ 221/ 7771 8067
\ / HTML | Roald-Amundsen-Straße 2a Fax: +49/ 221/ 7771 8069
 X in | D-50829 Köln-Ossendorf http://berger-odenthal.de
/ \ Mail | -- No unannounced, large, binary attachments, please! --
d***@googlemail.com
2017-06-26 16:58:42 UTC
Permalink
Raw Message
Post by Axel Berger
None. Backmatter ist backmatter and should be called such.
The numbering can be set with
\pagenumbering{roman}\setcounter{page}{}
You save the current page in a \newcounter or \newcommand at the end of
your frontmatter, add one and insert it above.
So I tried back matter and it wasn't continuing. So I tried \newcommand i'm still trying to look at wikibooks though. This is as far as I've gotten I think i'm close

\documentclass[12pt, oneside]{book}

\usepackage{sectsty,fancyhdr}
\sectionfont{\LARGE\bfseries}
\usepackage{geometry}

\usepackage{lipsum}%remove

% *******************************Margin Settings*******************************

\geometry{% margin settings, has to go first before \pagestyle{}
paper=a4paper,
inner=2.5cm, % Inner margin
outer=2.5cm, % Outer margin
bindingoffset=0.0cm, % Binding offset
top=2.5cm, % Top margin
bottom=2.5cm, % Bottom margin
headsep=4.5mm,% controles header
footskip=7.4mm,% controles footer
%showframe,% show how the type block is set on the page
}

% ***************************Header/Footer Settings****************************

\sectionfont{\LARGE\bfseries}%this will keep the formattings of sections
\pagestyle{fancy}
\fancyhf{} % sets all head and foot elements empty.
\rhead{} % right side of upper footer
\lhead{Project title} %left side
\renewcommand{\headrulewidth}{2.0pt} % Width of the top line
\renewcommand{\footrulewidth}{1.0pt} % Bottom line
\setlength{\headheight}{14.5pt}%used to remove the \fancyhf{} \headheight error
\rfoot{Page \thepage} % vice versa with the page number
\lfoot{\leftmark} % Should show the name of section

% or page # of page # would be
%\thepage\ of \pageref{LastPage}}
%\usepackage{lastpage}
%https://tex.stackexchange.com/questions/227/how-can-i-add-page-of-on-my-document


\makeatletter
\renewcommand{\sectionmark}[1]{%this avoids the \makecaptical of footers
\markboth{\ifnum \***@secnumdepth>\z@ %this allowes symbols in foorters
\thesection\hskip 1em\relax
\fi #1}{}}
\makeatother

% ***************************title Settings****************************

\newcommand{\mytitle}{

\begin{center}
{\Huge{\textbf{Project of...}}}
\end{center}

\begin{center}
\textsc{\Large My name}\\[0.5cm]
\end{center}

\begin{center}
{\large My ID number}\\[0.5cm]
\end{center}

}

% ********************************NEW CHAPTER PAGE SETTING*********************
\fancypagestyle{chapterstart}{% 1st page of the chapters, i.e. no new page for chapter
}
\makeatletter

\def\chapter{
\pagestyle{chapterstart}
\secdef\@chapter\@schapter}

\renewcommand\thesection{\@arabic\***@section}

\makeatother
% ********************************CHAPTER STYLE SETTING***********************
\usepackage{geometry}
\usepackage[T1]{fontenc}
\usepackage{graphicx}%**change
% replace color by xcolor (both are for color support, but xcolor is used in code 2 preamble)
\usepackage{titlesec,xcolor} %remove blindtext after
\definecolor{gray75}{gray}{0.65} %1=white, 0=black
\newcommand{\hsp}{\hspace{20pt}} %spacing between line and text
\titleformat{\chapter}[hang]{\vspace*{-2em}\Huge\bfseries}{\scalebox{1} {\thechapter}\hsp\textcolor{gray75}{|}\hsp}{0pt}{} %spacing across entire page %CHANGES** \scalebox{2}{}**3pt, **\vspace{+ down - up}
\titlespacing{\chapter}{0pt}{50pt}{30pt} %change{right}{shift down}{tile and text}

%------------------------TABLE OF CONTENTS SESSTINGS-------------------------------------

\renewcommand\contentsname{CONTENTS}
\renewcommand\listtablename{LIST OF TABLES}
\renewcommand\listfigurename{LIST OF FIGURES}
% added \protect\noindent to remove \parindent from table header
\addtocontents{toc}{{\protect\noindent\bfseries Contents\hfill Page No.\bigskip\par}}
\addtocontents{lot}{{\protect\noindent\bfseries No.\hfill Title\hfill\hfill Page No.\bigskip\par}}
\addtocontents{lof}{{\protect\noindent\bfseries No.\hfill Title\hfill\hfill Page No.\bigskip\par}}

\usepackage[titles]{tocloft}
% xcolor removed, because it's loaded above
\usepackage{xpatch}
\renewcommand\cftbeforechapskip{0ex}
\renewcommand\cftchapfont{\mdseries}
\renewcommand\cftchappagefont{\mdseries}
\renewcommand\cftchappresnum{Chapter~}
\renewcommand\cftchapaftersnum{: }
\newlength\tocindent
\settowidth\tocindent{\cftchapfont\cftchappresnum9\cftchapaftersnum}
\edef\cftchapnumwidth{\the\tocindent}
\edef\cftsecindent{\the\tocindent}
\advance\tocindent2.3em
\edef\cftsubsecindent{\the\tocindent}
\advance\tocindent3.2em
\edef\cftsubsubsecindent{\the\tocindent}
\renewcommand\cftsecdotsep{\cftnodots}
\renewcommand\cftsubsecdotsep{\cftnodots}
\renewcommand\cftsubsubsecdotsep{\cftnodots}
\newcommand\tocmainmatter
{\renewcommand\cftchappagefont{\color{white}}%
}
\xapptocmd\mainmatter{\addtocontents{toc}{\protect\tocmainmatter}}{}{}

% centers \chapter* headers
% if unwanted comment out ...
\newif\ifschaptertoc
\makeatletter
\renewcommand\@makeschapterhead[1]%
{{\parindent \z@ \centering
\normalfont
\interlinepenalty\@M
\Large \bfseries #1\par\nobreak
\vskip 20\p@
}%
\@mkboth{\MakeUppercase{#1}}{\MakeUppercase{#1}}%
\ifschaptertoc
\addcontentsline{toc}{chapter}{#1}%
\fi
}
\makeatother
% ... to here

%\usepackage{blindtext} thrown out, one dummy text package is enough

%dots
\renewcommand{\cftpartleader}{\cftdotfill{\cftdotsep}} % for parts
\renewcommand{\cftchapleader}{\cftdotfill{\cftdotsep}} % for chapters
\renewcommand{\cftsecleader}{\cftdotfill{\cftdotsep}} % for sections
\renewcommand{\cftsubsecleader}{\cftdotfill{\cftdotsep}} % for subsection


%------------------------------------------------------------------

% Begin Project

%------------------------------------------------------------------

\begin{document}



\frontmatter %sets lower case roman page numbering. Usually it's followed by abstract, TOC, LOF, LOT, and other stuff, which isn't the main contents of your document.


%\backmatter
\schaptertoctrue %setafter \tableofcontents ( or set before would also add a line for the TOC to the TOC). You can disable this with \schaptertocfalse before the \chpter* you don`t want in the TOC.

\tableofcontents


\newpage
\listoftables

\newpage
\listoffigures
\newcounter{roman}
%-------------------------------Title-------------------------------
\mainmatter %Latter, which sets the page numbering to arabic and resets the page number.

\newpage
\mytitle

%------------------------------Begin--------------------------------

\chapter{Minor introduction}
\section{Introduction}
\subsection{Super introduction}
\lipsum

\newpage
\chapter{Something more}
\section{ssection 1}
\subsection{subection 1}
\lipsum

\pagenumbering{roman}\setcounter{page}{4}
\frontmatter

\newpage
\chapter*{Appendix}
\section*{section}
\lipsum

\newpage
\chapter*{Bibliography}
\lipsum




%------------------------------------------------------------------

% end Project

%------------------------------------------------------------------


\end{document}
Axel Berger
2017-06-26 20:21:24 UTC
Permalink
Raw Message
Post by d***@googlemail.com
So I tried back matter and it wasn't continuing.
\pagenumbering{roman}\setcounter{page}{4}
\frontmatter
\backmatter and \frontmatter reset the page counter and change the style
of the page numbering. So of course you have to apply your own settings
after and not before those commands.
--
/¯\ No | Dipl.-Ing. F. Axel Berger Tel: +49/ 221/ 7771 8067
\ / HTML | Roald-Amundsen-Straße 2a Fax: +49/ 221/ 7771 8069
 X in | D-50829 Köln-Ossendorf http://berger-odenthal.de
/ \ Mail | -- No unannounced, large, binary attachments, please! --
Peter Flynn
2017-06-26 18:36:09 UTC
Permalink
Raw Message
On 06/26/2017 03:48 PM, ***@googlemail.com wrote:

In your Subject: *what* counter are you referring to? LaTeX has many.
Post by d***@googlemail.com
\documentclass[12pt,oneside]{book}
...
...
\frontmatter %labels page numbers for chapters via roman numbers starting at i
Front matter is usually formatted as unnumbered sections, not chapters,
eg \clearpage\section*{Preamble}
Post by d***@googlemail.com
\chapter*{Preambles}
\chapter*{Introduction}
\mainmatter %lables page numbers for Arabic numerical starting at 1
\chapter{Chapter 1}
\chapter*{Chapter 2}
That looks wrong, should be \chapter

For Appendixes, use

\appendix
\chapter{Appendix}

then they will be lettered correctly.
Post by d***@googlemail.com
\frontmatter %labels page number to continue previous roman numerals, start iii
Don't use \frontmatter for back matter, use \backmatter.

Again, back matter sections are usually done as \section*
Post by d***@googlemail.com
\chapter*{Bibliography}
What code do you put in the preambles to stop it resting the counter
when you put it in the second time?
I don't under stand the question, but I *think* what you mean is you
want the roman numbering from the front matter continued in thr back
matter, right?
Post by d***@googlemail.com
So I tried back matter and it wasn't continuing. So I tried
\newcommand i'm still trying to look at wikibooks though.
You're looking in the wrong place. Modify the meaning of \mainmatter and
\backmatter from book.cls (I don't think there is a package to do what
you want, as it's rather unusual, although perhaps the Memoir or the
KomaScript classes might do it).

=====================================================================
\documentclass[12pt,oneside]{book}
\newcounter{fmpage}
\makeatletter
\renewcommand\mainmatter{%
\clearpage
\setcounter{fmpage}{\value{page}}%
\message{page is \thefmpage}
\@mainmattertrue
\pagenumbering{arabic}}
\renewcommand\backmatter{%
\clearpage
\@mainmatterfalse
\markright{}%
\pagenumbering{roman}%
\setcounter{page}{\value{fmpage}}}
\makeatother
\begin{document}
\title{Title}
\author{Author}
\maketitle
\frontmatter
\section*{Preamble}
Stuff
\clearpage
\section*{Introduction}
Stuff
\mainmatter
\chapter{First}
Stuff
\chapter{Second}
Stuff
\appendix
\chapter{First}
\backmatter
\section*{Bibliography}
Stuff
\end{document}
======================================================================

///Peter
--
Using LaTeX? See http://latex.silmaril.ie/formattinginformation/
Loading...