0

I created new section (i.e., "Workpackage") and subsection (i.e., "Task") headings using titlesec package. The definitions for both headings are as follows.

% Workpackage section
\titleclass{\WP}{straight}[\section]
\titleformat{\WP}{\normalfont\normalsize\bfseries}{}{0em}{Work Package \theWP :\,}
\titlespacing*{\WP}{0pt}{2.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}
\newcounter{WP}
\renewcommand\theWP{\arabic{WP}}

% Task subsection
\newcounter{Taskr}
\renewcommand\theTaskr{\theWP.\arabic{Taskr}}
\titleclass{\Taskr}{straight}[\WP]
\titleformat{\Taskr}[runin]{\normalfont\normalsize\itshape}{}{0em}{Task \theTaskr :\,}
\titlespacing*{\Taskr}{0pt}{2.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}
\numberwithin{Taskr}{WP}

However, when I compiled the document the ordinary subsection headings are without heading numbers, e.g.:

1. Section
Subsection
Subsection
2. Section
Subsection
Workpackage 1
Task 1.1

instead of

1. Section
1.1 Subsection
1.2 Subsection
2. Section
2.2 Subsection
Workpackage 1
Task 1.1

Any how to modify my definitions? The MWE is pasted below.

\documentclass{article}
\usepackage{amsmath}
\usepackage{titlesec}

% Workpackage section
\titleclass{\WP}{straight}[\section]
\titleformat{\WP}{\normalfont\normalsize\bfseries}{}{0em}{Work Package \theWP :\,}
\titlespacing*{\WP}{0pt}{2.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}
\newcounter{WP}
\renewcommand\theWP{\arabic{WP}}

% Task subsection
\newcounter{Taskr}
\renewcommand\theTaskr{\theWP.\arabic{Taskr}}
\titleclass{\Taskr}{straight}[\WP]
\titleformat{\Taskr}[runin]{\normalfont\normalsize\itshape}{}{0em}{Task \theTaskr :\,}
\titlespacing*{\Taskr}{0pt}{2.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}
\numberwithin{Taskr}{WP}

% Don't want to include WP and Tasks into bookmarks and TOC
\makeatletter
  \def\toclevel@WP{6}
  \def\toclevel@Taskr{5}
\makeatother

\begin{document}
\section{Introduction}
\subsection{Problem definition}

\WP{Project management}
\Taskr{Project advisory board}
\end{document}
2

The \titleclass command is defined to insert a new level between the existing levels (with lower levels pushed down), not as an alternative to an existing level. It is however not very difficult to create alternative levels manually (without titlesec and the associated numbering behaviour), you just have to pay attention to spacing issues (note: the example below undoubtedly has remaining issues).

MWE:

\documentclass{article}
\usepackage{amsmath}
%\usepackage{titlesec}

\newcounter{WP}
\newcounter{Taskr}
\newcommand{\WP}[1]{%
\stepcounter{WP}%
\setcounter{Taskr}{0}%
{\normalfont\normalsize\bfseries%
\bigbreak\noindent Work Package \theWP :\,#1}\par\noindent\ignorespaces%
}

\newcommand{\Taskr}[1]{%
\stepcounter{Taskr}%
{\normalfont\normalsize\itshape%
\par\noindent Task \theWP .\theTaskr :\,#1}\par\noindent\ignorespaces%
}

\begin{document}
\section{Introduction}
\subsection{Problem definition}

\WP{Project management}
This WP consists of two tasks.
\Taskr{Project advisory board}
Advise on the project.

\Taskr{Budget allocation}

\WP{Prototype}
\Taskr{Research existing solutions}

\subsection{Further considerations}

\end{document}

Result:

enter image description here

  • Thanks, but still struggling with spacing. Any idea? – Andrej Feb 22 '18 at 14:28
  • Which changes do you want to make to the current spacing? – Marijn Feb 22 '18 at 15:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.