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
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?
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
- Stefan Kottwitz
- Site Admin
- Posts: 10360
- Joined: Mon Mar 10, 2008 9:44 pm
Re: How to prevent a newline for a new section
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
-
- Posts: 7
- Joined: Sun Jul 04, 2010 7:07 pm
Re: How to prevent a newline for a new section
- Stefan Kottwitz
- Site Admin
- Posts: 10360
- Joined: Mon Mar 10, 2008 9:44 pm
How to prevent a newline for a new section
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
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
How to prevent a newline for a new section
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
- Stefan Kottwitz
- Site Admin
- Posts: 10360
- Joined: Mon Mar 10, 2008 9:44 pm
How to prevent a newline for a new section
Code: Select all
\titleformat{\section}[runin]{...