I am newbie with latex and I try to create a section with movable section number tabs as shown below:
In the following code, I used both tikz and titlesec packages to format the required sections
\documentclass{report}
\usepackage{totcount}
\usepackage{tikz}
\usepackage{blindtext}
\usetikzlibrary{calc,shapes,arrows,positioning,patterns,fit,decorations.pathmorphing}
\usetikzlibrary{decorations.text}
\usepackage[explicit,calcwidth,compact]{titlesec}
\regtotcounter{section}
\newcommand{\secnum}{\arabic{section}}
\titleformat{\section}{\Large\bfseries}{}{0mm}{\tikz[]{
\node [rectangle,,inner sep=0cm,text width=\textwidth] (A) {#1};
\pgfmathsetmacro\ABC{(\secnum-1)/(\totvalue{section}-1)}
\node [yshift=0.4cm] (B) at ($([xshift=1cm]A.north west)!{\ABC}!([xshift=-1cm]A.north east)$) {\thesection};
\draw [rounded corners] ([yshift=0.2cm]A.north west) -| (B.north west) -- (B.north east) |- ([yshift=0.2cm]A.north east);
\draw ([yshift=-0.2cm]A.south west) -- ([yshift=-0.2cm]A.south east);
}}
\begin{document}
\chapter{First Chapter}
\section{First section}
A short paragraph for first section
\section{Second section}
The second paragraph
\section{Third section}
The third paragraph
\section{Last section}
The last paragraph
\chapter{Second Chapter}
\section{First section}
A short paragraph for first section
\section{Last section}
The Last paragraph
\end{document}
The problem is If I use totcount with section counter, then It counts only the sections for the last chapter only (It counts 2 for my code). Is there any macro that counts the sections for each chapter? sorry for my simple English.