Page LayoutCustom page numbering | index

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
Andreas Knafl
Posts: 11
Joined: Mon Jun 20, 2016 11:28 pm

Custom page numbering | index

Post by Andreas Knafl »

Hey guys!
I've got the following problem:
I've got like five concrete chapters with contractions like trigonometry-> tri
I'd like to code a pagenumbering like "tri-1","tri-2"

So that isn't that hard, there are packages like chappg and I already have a code, but the index isn't displayed

Code: Select all

\documentclass[
paper=a5,
fontsize=10pt,
twoside,
]{scrbook}
\usepackage[
left=2cm,
right=1cm,
top=1cm,
bottom=0.5cm,
includeheadfoot
]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{amsfonts}
\usepackage{blindtext}
\usepackage{tabularx}
\usepackage{xcolor}
\definecolor{BlauDef}{RGB}{11,93,173}

%%%%%%%%%%%%%%%%%%%%%%%%% Inhaltsverzechnis %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[explicit]{titlesec}
\usepackage{titletoc}

\makeatletter
    \newcommand\tableofcontentsA{%
        \chapter*{\contentsname
            \@mkboth{%
               \MakeUppercase\contentsname}{\MakeUppercase\contentsname}}%
        \@starttoc{toca}%
        }
\makeatother

%%%%%%%%%%%%%%%%%%%%%%%% Spalten im Text %%%%%%%%%%%%%%%%%%%%%%%
\usepackage{multicol}
\setlength{\columnsep}{1cm}

%%%%%%%%%%%%%%%%%%%%%%%% Grafik %%%%%%%%%%%%%%%%%%%%%%%
\usepackage{amsthm,amsmath,amssymb}
\usepackage{graphicx}
\graphicspath{{Grafiken/}}
\usepackage{tikz}
\usetikzlibrary{intersections}
\usepackage{pgfplots}
\usepackage{wrapfig} % Bild neben Text

%%%%%%%%%%%%%%%%%%%%%%%%%%% Titel (groß) %%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{xparse}
\titleformat
{\chapter} % command % shape
{} % format
{} % label
{0.5ex}{} % sep

\makeatletter
\NewDocumentCommand{\Chapter}{ o m m }{
\IfNoValueTF{#1}{\chapter{#2}}{\chapter[#1]{#2}}
\noindent\begin{tabularx}{\linewidth}{XcX}

&\centering\normalfont\rmfamily\scshape\fontsize{16}{4}\selectfont #2 & \\
\cline{2-2}
&\fontsize{6}{8}\selectfont #3 &
\end{tabularx}\bigbreak\@afterheading
\addcontentsline{toca}{chapter}{#2}
}
\makeatother
\setcounter{chapter}{-1}%damit das Vorwort zu Teil "0"



%%%%%%%%%%%%%%%%%%%%%%%%%%% Titel (klein) (zb 1.1) %%%%%%%%%%%%%%%%%%%%%%%

%\usepackage{booktabs}% for better rules in the table

\titleformat{\section}{}{}{0pt}{}{} % muss sein damit dei section nicht zweimal auftaucht



\makeatletter
\NewDocumentCommand{\Section}{ o m m }{
\IfNoValueTF{#1}{\section{#2}}{\section[]{#2}}
\noindent\begin{tabularx}{\linewidth}{@{}l>{\raggedleft\arraybackslash}X@{}}
\normalfont\rmfamily\bfseries\fontsize{16}{4}\selectfont Beispiel \thesection&%
\normalfont\rmfamily\bfseries\fontsize{16}{4}\selectfont #2\\\hline
\fontsize{6}{8}\selectfont Version \setcounter{subsection}{1} \thesubsection &\fontsize{6}{8}\selectfont #3 
\end{tabularx}\bigbreak\@afterheading
\addcontentsline{toca}{section}{#2}
\addcontentsline{toca}{subsection}{Version \thesubsection}
}
\makeatother
\renewcommand{\thesection}{\arabic{section}}


%%%%%%%%%%%%%%%%%%%%%%%%%%% Überschrift 1 %%%%%%%%%%%%%%%%%%%%%%%%%%%


\titleformat{\subsection}{}{}{0pt}{}{} % muss sein damit dei section nicht zweimal auftaucht

\makeatletter
\NewDocumentCommand{\Subsection}{ o m m }{


\IfNoValueTF{#1}{\subsection{#2}}{\subsection[Vers. \thesubsection]{#2}}
\noindent\begin{tabularx}{\linewidth}{@{}l>{\raggedleft\arraybackslash}X@{}}
\normalfont\rmfamily\bfseries\fontsize{16}{4}\selectfont Beispiel \thesection &
\normalfont\rmfamily\bfseries\fontsize{16}{4}\selectfont #2\\\hline
\fontsize{6}{8}\selectfont Version \thesubsection &\fontsize{6}{8}\selectfont #3 
\end{tabularx}\bigbreak\@afterheading
\addcontentsline{toca}{subsection}{Version \thesubsection}
}

\makeatother

\renewcommand{\thesubsection}{\Roman{subsection}}


%%%%%%%%%%%%%%%%%%%%%%%%% Kopf-& Fußzeile %%%%%%%%%%%%%%%%%%%%%%%



\usepackage{fancyhdr}
%\usepackage{chappg}
\pagestyle{fancy}

\makeatletter
\@addtoreset{page}{chapter}
\def\@stpelt#1{\global\csname c@#1\endcsname\expandafter\ifx\csname c@#1\endcsname\c@page\@ne\else\z@\fi}% macht dass es bei 1 beginnt
\def\thepage{\thechapter--\@arabic\c@page}
\makeatother

\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\renewcommand{\sectionmark}[1]{\markright{#1}}
%\extramarks{}{23}
\fancyhf{}
\fancyhead[EL]{\rightmark}% Section (Beispiele 1.1)
\fancyhead[OR]{\leftmark}% Chapter (Titel groß - z.b. Algebra und Geometrie)
\fancyfoot[EL,OR]{Seite \thepage}

\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}
%%%%%%%%%%%%%%%%%%%%%%%% Stichwortverzeichnis erstellen %%%%%%%%%%%%%%%%%%%
\usepackage{imakeidx}


\makeindex[columns=3, options=-s mystyle]

\usepackage{filecontents}
\begin{filecontents}{mystyle.ist}
headings_flag 1 % wir benutzen Überschriften
heading_prefix "{\\bfseries " % und setzen sie fett
heading_suffix "\\hfil}\\nopagebreak\n"% und links, nach ihnen kein Seitenumbruch
delim_0 "\\dotfill" % Punktzeile zwischen Einträgen und Seitenzahlen (Ebene 0)
delim_1 "\\dotfill" % Punktzeile zwischen Einträgen und Seitenzahlen (Ebene 1)
delim_2 "\\dotfill" % Punktzeile zwischen Einträgen und Seitenzahlen (Ebene 2)
delim_r "--" % Trenner zwischen Start und Ende eines Seitenbereiches
suffix_2p "\\,f." % Suffix bei einem bereich aus 2 Seiten
suffix_3p "\\,ff." % Suffix bei einem bereich aus 3 Seiten
\end{filecontents}


%%%%%%%%%%%%%%%%%%%%%%%%% Dokument %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}


\tableofcontentsA

\Chapter{chapter zero}{jjgj}




\clearpage
\Chapter{chapterone}{ttt}
\Section{erstes beispiel}{ Nr.:1234}
\thesubsection
\Subsection{erstes beispiel}{1234}
\Subsection{erstes beispiel}{1234}
\Section{zweites beispiel}{1234}
\Subsection{testchen2}{tedrt2}
\Subsection{2subsec}{t}
\Subsection{subsec}{t}
\index{Funktion} \blindtext \clearpage  \index{Teig} \blindtext 

\renewcommand{\indexname}{Stichwortverzeichnis}
\printindex
\end{document}
I've also tried to use an own counter and some ifthenelse conditions , but it didn't work... has anybody an idea ?
Numbering should be used in toc , index, and footer

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
Stefan Kottwitz
Site Admin
Posts: 10290
Joined: Mon Mar 10, 2008 9:44 pm

Custom page numbering | index

Post by Stefan Kottwitz »

Andreas Knall wrote:I'd like to code a pagenumbering like "tri-1","tri-2"
You could redefine the page representation after each \chapter:

\renewcommand*{\thepage}{trig-\arabic{page}}

Stefan
LaTeX.org admin
User avatar
Stefan Kottwitz
Site Admin
Posts: 10290
Joined: Mon Mar 10, 2008 9:44 pm

Custom page numbering | index

Post by Stefan Kottwitz »

Stefan Kottwitz wrote:
Andreas Knall wrote:I'd like to code a pagenumbering like "tri-1","tri-2"
You could redefine the page representation after each \chapter such as for the trig chapter:

\renewcommand*{\thepage}{trig-\arabic{page}}

Stefan
LaTeX.org admin
Andreas Knafl
Posts: 11
Joined: Mon Jun 20, 2016 11:28 pm

Custom page numbering | index

Post by Andreas Knafl »

Stefan Kottwitz wrote:
Andreas Knall wrote:I'd like to code a pagenumbering like "tri-1","tri-2"
You could redefine the page representation after each \chapter:

\renewcommand*{\thepage}{trig-\arabic{page}}

Stefan
Thank you very much, Stefan!!
It's so simple and it works !!
Post Reply