General ⇒ How to prevent a newline for a new section
-
- Posts: 7
- Joined: Sun Jul 04, 2010 7:07 pm
How to prevent a newline for a new section
Folks,
Latex always leaves a line, and text goes on the line below when we create a new section or subsection or subsubsection. Is there a way to prevent this? That is, the text begins on the same line?
Latex always leaves a line, and text goes on the line below when we create a new section or subsection or subsubsection. Is there a way to prevent this? That is, the text begins on the same line?
Last edited by cool_divya_4u on Sun Jul 04, 2010 8:00 pm, edited 1 time in total.
NEW: TikZ book now 40% off at Amazon.com for a short time.

- Stefan Kottwitz
- Site Admin
- Posts: 10348
- Joined: Mon Mar 10, 2008 9:44 pm
Re: How to prevent a newline for a new section
Hi,
LaTeX base classes provide \paragraph and \subaragraph, they produce a run-in heading, they don't cause a line break.
Or do you have to use \section and \subsection? Which document class do you use?
Stefan
LaTeX base classes provide \paragraph and \subaragraph, they produce a run-in heading, they don't cause a line break.
Or do you have to use \section and \subsection? Which document class do you use?
Stefan
LaTeX.org admin
-
- Posts: 7
- Joined: Sun Jul 04, 2010 7:07 pm
Re: How to prevent a newline for a new section
Thanks for your reply. I am using article class, and using \section, \subsection, and \subsubsections for the sections.
- Stefan Kottwitz
- Site Admin
- Posts: 10348
- Joined: Mon Mar 10, 2008 9:44 pm
How to prevent a newline for a new section
Try this in your preamble:
These are definitions like in the article class except they now produce a run-in heading.
Stefan
Code: Select all
\makeatletter
\renewcommand\section{\@startsection {section}{1}{\z@}%
{-3.5ex \@plus -1ex \@minus -.2ex}%
{-1em}%
{\normalfont\Large\bfseries}}
\renewcommand\subsection{\@startsection{subsection}{2}{\z@}%
{-3.25ex\@plus -1ex \@minus -.2ex}%
{-1em}%
{\normalfont\large\bfseries}}
\renewcommand\subsubsection{\@startsection{subsubsection}{3}{\z@}%
{-3.25ex\@plus -1ex \@minus -.2ex}%
{-1em}%
{\normalfont\normalsize\bfseries}}
\makeatother
Stefan
LaTeX.org admin
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
How to prevent a newline for a new section
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
-
- Posts: 7
- Joined: Sun Jul 04, 2010 7:07 pm
Re: How to prevent a newline for a new section
By the way, I am using titlesec package to reduce section title fontsize. Can I use the same package to prevent the lines as well? If so, do you mind letting me know?
- Stefan Kottwitz
- Site Admin
- Posts: 10348
- Joined: Mon Mar 10, 2008 9:44 pm
How to prevent a newline for a new section
If you're already using titlesec, simply state the optional argument runin:
Stefan
Code: Select all
\titleformat{\section}[runin]{...
LaTeX.org admin