Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
1  
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 1

up vote 7 down vote accepted

To add text before the section, you can use:

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

enter image description here

or for subsection you can use:

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

enter image description here

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}
share|improve this answer
    
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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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