How to show section title before section number
You can use the titlesec
package:
\documentclass{article}
\usepackage[explicit]{titlesec}
\titleformat{\section}{\normalfont\Large\bfseries}{}{0em}{#1\ \thesection}
\begin{document}
\section{A Test Section}
\section{Another Test Section}
\end{document}
Similar redefinitions can be done for the other sectional units, if required.
In ConTeXt you can use
\setuphead[alternative=command, command=\swap]
\unexpanded\def\swap#1#2{#2\space#1}
\starttext
\startTEXpage[offset=5mm]
\chapter{A chapter}
\section{A section}
\subsection{A subsection}
\stopTEXpage
\stoptext
which gives
Here is an example (MWE) for the standard report
-class. The code is copied from Vincent Zoonekynd and modified. The code for the book
-class will be little different:
\documentclass{report}
\makeatletter
\def\@makechapterhead#1{%
\vspace*{50\p@}%
{\parindent \z@ \raggedright
\normalfont
\interlinepenalty\@M
\Huge \bfseries #1 \quad
\ifnum \c@secnumdepth >\m@ne
\Huge\bfseries
\thechapter
\par\nobreak
\fi
\vskip 40\p@
}}
\def\@makeschapterhead#1{%
\vspace*{50\p@}%
{\parindent \z@ \raggedright
\normalfont
\interlinepenalty\@M
\Huge \bfseries #1\par\nobreak
\vskip 40\p@
}}
\makeatother
\begin{document}
\chapter*{Test}
\chapter{Introduction}
\end{document}
And if you use article
-class and only needs \section
, here more code from the same source, slightly modified to suit your needs:
\documentclass{article}
\usepackage{lipsum}
\makeatletter
\def\section{\@ifstar\unnumberedsection\numberedsection}
\def\numberedsection{\@ifnextchar[%]
\numberedsectionwithtwoarguments\numberedsectionwithoneargument}
\def\unnumberedsection{\@ifnextchar[%]
\unnumberedsectionwithtwoarguments\unnumberedsectionwithoneargument}
\def\numberedsectionwithoneargument#1{\numberedsectionwithtwoarguments[#1]{#1}}
\def\unnumberedsectionwithoneargument#1{\unnumberedsectionwithtwoarguments[#1]{#1}}
\def\numberedsectionwithtwoarguments[#1]#2{%
\ifhmode\par\fi
\removelastskip
\vskip 3ex\goodbreak
\refstepcounter{section}%
\hbox to \hsize{%
\vtop{\parindent=0pt \leavevmode\Large\bfseries\raggedright #2\quad\thesection\par}%
}
\vskip 2ex\nobreak\noindent%
\addcontentsline{toc}{section}{%
\protect\numberline{\thesection}%
#1}%
\ignorespaces}
\def\unnumberedsectionwithtwoarguments[#1]#2{%
\ifhmode\par\fi
\removelastskip
\vskip 3ex\goodbreak
\hbox to \hsize{%
\vtop{\parindent=0pt\leavevmode\Large\bfseries\raggedright #2\par}%
}
\vskip 2ex\nobreak\noindent%
\addcontentsline{toc}{section}{%
#1}%
\ignorespaces}
\makeatother
\pagestyle{empty}
\begin{document}
\lipsum[1-2]
\section*{Introduction}
\lipsum[3-4]
\section{Introduction}
\lipsum[5-6]
\end{document}
In any case, it demonstrates clearly how much simpler life is due to titlesec
and secstyle
.