TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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


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:

   {\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?

share|improve this question
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? – Chang Jul 5 '11 at 20:57
up vote 1 down vote accepted

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

\newcounter{sect}%          Creates a counter to be used in the new section command
\newcommand\Section[1]{%    Defines a new section command:
 \addtocounter{sect}{1}%    Increases counter
 \addcontentsline{toc}{section}{\arabic{sect}.~#1}% Add to table of contents
  {\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>"
\Section{A first section}
\Section{A second section}

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.

share|improve this answer
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. – Chang Jul 6 '11 at 16:03
There isn't --- the definition of \section in article.cls is \newcommand\section{\@startsection {section}{1}{\z@}{-3.5ex \@plus -1ex \@minus -.2ex}{2.3ex \@plus.2ex}{\normalfont\Large\bfseries}}. If you'll use this workaround you can create one with \newcommand{\sectfont}{\bfseries} for example. I don't recommend changing the font size, as the sectioning command will come within the text. – henrique Jul 6 '11 at 20:32

Your Answer


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.