0

in the report class I structured my document in chapters, sections and subsections. All my sections are called "Task [number]".

At the moment all my sections headings are like "Task 2" and I want them to be that way. But I use \section*{} so they are not automatically numbered. Otherwise it looks strange to have the heading "1.2 Task 2". Also the sections are not in the table of content.

Do you have any idea how to not show the chapter counter in the heading and put the section counter behind the section title? And also how to show that in the table of contents?

I suppose it works with \renewenvironment{section} somehow but this also changes the default font and text size.

2
  • Or leave its that way and rephrase the title to something like "1.2 Solution to Task 2" or "1.2 Result Regarding Task 2" (German "1.2 Lösung zu Aufgabe 2"). Commented May 26, 2019 at 15:29
  • 1
    Most probably, titlesec can do what guntherkastenfrosch wants (using \thesection inside arguments of \titleformat), but since the description of the desired result isn't very precise...
    – frougon
    Commented May 26, 2019 at 21:36

1 Answer 1

2

I'm not completely sure what you want but I hope that the following (less any typos) will give you what you are after, basically defining \tasksec as a version of \section.

\documentclass{report}
\newcounter{tasksec}
\newcommand{\tasksec}{
  \section*{Task \refstepcounter{tasksec}\thetasksec}
  \addcontentsline{toc}{section}{Task \thetasksec}
}

\begin{document}
\tableofcontents
\chapter{Chap One}
Some text
\tasksec  % should output as Task 1
A task
\tasksec  % should output as Task 2
Another task
\chapter{Chap Two}
\tasksec  % should output as Task 3
Yet another task
\end{document}

Each \tasksec will produce a \section* style division of the form Task # where the number # is incremented each time (has no relation to the \chapter number). The \addcontentsline puts Task # into the ToC together with the page number in the style of a \section entry but without a section number.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .