# Prevent a paragraph break before a section heading

How can I prevent a paragraph break before a section heading? To prevent it after, I know that I can use runin like

\titleformat{\section}[runin]{\Large\bf}{\thesection\quad}{0pt}{}


However, how can I prevent before? I want something like:

1. First section heading Text... (no line break here) 2. Second Section Heading Text...

EDIT. I am trying in the following way for \subsection. I created a new command like:

\newcommand{\subsectionnlb}[1]{
\stepcounter{subsection}
{\normalfont\bf\thesubsection \hspace{0.3em} #1\hspace{0.3em}}
}


How can I call the formatting of \subsection and apply to the custom command \subsectionnlb?

-
If I understood, you want something like 1. First section heading Text... and then comes a section heading without a line break 2. Second Section Heading Text... If so, titlesec package can't do it, because the very \section command internals (namely, as far as I know, \@startsection) definition starts with a \par... –  henrique Jul 2 '11 at 2:22
@henrique You are correct. I revised my question. What about a \subsection without break? –  FEQ Jul 5 '11 at 20:57

If you don't need to use \section specifically, you can try the following workaround:

\documentclass{scrartcl}
\usepackage{blindtext}
\newcounter{sect}%          Creates a counter to be used in the new section command
\newcommand\Section[1]{%    Defines a new section command:
{\sectfont% This command is intended to use with scrartcl class;
%    if not using it you can use any formatting command you wish
\arabic{sect}.~#1.}}%    Prints "<section number>. <section title>"
\begin{document}
\tableofcontents
\blindtext
\Section{A first section}
\blindtext
\Section{A second section}
\blindtext
\end{document}


EDIT: BTW, this workaround doesn't use (it's actually incompatible with) titlesec package, but I assumed (based on your last comment) that you didn't actually required it.

-
Thanks for the answer. Yes, I don't need titlesec, so I deleted it from the title. I was wondering if there is something similar to \sectfont in the article package. –  FEQ Jul 6 '11 at 16:03