Adding text to the section numbering

I wish to add some text prior to the number given to a subsection, e.g.:

Task 1.1  Blablabla
...
Task 1.2  Blablabla


How?

-
Can you please be a little bit more specific? Do you need this Task text for a special environment, like a theorem or for what? BTW: Welcome to TeX.sx! –  Kurt Nov 10 '12 at 22:23
Thanks. No special environment. Task is just an example text. I would like to have a word like that before the number for a subsection, and that's all. –  Steeven Nov 10 '12 at 22:33

1 Answer

To add text before the section, you can use:

\renewcommand{\thesection}{Text \arabic{section}}


or for subsection you can use:

\renewcommand{\thesubsection}{Text \arabic{section}}


Code: section

\documentclass{article}

\renewcommand{\thesection}{Text \arabic{section}}

\begin{document}
\section{First section}
Some text.

\section{Second section}
Some more text.
\end{document}


Code: subsection:

\documentclass{article}

\renewcommand{\thesubsection}{Text \arabic{subsection}}

\begin{document}
\section{First section}
\subsection{First sub section}
Some text.
\subsection{Second sub section}
Some more text.
\end{document}

-
This is great and works. But some other problem appears when I use the \renewcommand{\thesubsection}{Text \arabic{section}}. The numbering of the subsection suddenly doesn't work. @Peter, if you make two subsections in your example, they both have the number 1. Can that be fixed? –  Steeven Nov 10 '12 at 22:42
Clearly LaTeX is not smart enough to know that when I said \arabic{section}, that I obviously meant \arabic{subsection}. :-) Anyway, sorry about that mistake - have updated answer. –  Peter Grill Nov 10 '12 at 22:47
Precisely ;) Thanks alot. (By the way, you must update it in two places in your answer...) –  Steeven Nov 10 '12 at 23:50
@Steeven: Two places? Only the \renewcommand needed updating. I added two subsections to show that it functioned as desired. –  Peter Grill Nov 10 '12 at 23:56
Oh well, I just meant the single line \renewcommand{\thesubsection}{Text \arabic{section}} above your example. –  Steeven Nov 11 '12 at 13:37