# Subsection starting in same line as subsection name [duplicate]

Many articles are structured in the following way:

# 1. [Title of section 1]

1.1.[title of subsection 1.1].text of subsection 1.1

1.2.[title of subsection 1.2].text of subsection 1.2.

# 2. [Title os section 2]

2.1.[title of subsection 2.1].text of subsection 2.1

2.2.[title of subsection 2.2].text of subsection 2.2.

How can I do that (in a proper way)? Thanks.

• – Werner
Mar 7, 2014 at 23:03
• Why is this a duplicate of that other question? I know it's extremely similar, but the answer there addresses the case of subsubsections; here, the OP asks about subsections. It's not clear in the other answer how to handle the case for subsections; the definition is different. I voted to re-open. Mar 8, 2014 at 0:08
• @GonzaloMedina: The questions are so similar that they might just as well be considered duplicates, unless the OP can explain why the solution doesn't work. Using your motivation, then a question about \paragraph, \subparagraph, \section, \chapter, and any other sectional title would all require separate solutions? Of course this is just my opinion.
– Werner
Mar 8, 2014 at 2:58
• @Werner up to a certain point a agree with you; however, the definitions in this case are different, so it's not immediate for an unexperienced user what the definition for subsection is or where to find it. The best thing to do (in my opinion), would be to add to your answer the settings for sections and subsections. Then it can be considered as a complete canonical answer to the problem for all sectional units (except chapter, which I don't think is required). What do you think? Mar 8, 2014 at 3:25

One option using titlesec:

\documentclass{article}
\usepackage{titlesec}

\titleformat{\subsection}[runin]
{\normalfont\large\bfseries}{\thesubsection}{1em}{}
\titleformat{\subsubsection}[runin]
{\normalfont\normalsize\bfseries}{\thesubsubsection}{1em}{}

\begin{document}

\section{Test section}
test text
\subsection{Test subsection}
test text
\subsection{Test subsection}
test text
\section{Test section}
test text
\subsection{Test subsection}
test text
\subsection{Test subsection}
test text

\end{document}


Without packages:

\documentclass{article}

\makeatletter
\renewcommand\subsection{\@startsection{subsection}{2}{\z@}%
{-3.25ex\@plus -1ex \@minus -.2ex}%
{-1.5ex \@plus .2ex}%
{\normalfont\large\bfseries}}
\renewcommand\subsubsection{\@startsection{subsubsection}{3}{\z@}%
{-3.25ex\@plus -1ex \@minus -.2ex}%
{-1.5ex \@plus .2ex}%
{\normalfont\normalsize\bfseries}}
\makeatother

\begin{document}

\section{Test section}
test text
\subsection{Test subsection}
test text
\subsection{Test subsection}
test text
\section{Test section}
test text
\subsection{Test subsection}
test text
\subsection{Test subsection}
test text

\end{document}


In Subsubsection: remove the newline (like paragraph) Werner has provided a similar answer for the case of subsubsections; he has also given a nice explanation of \@startsection there.

• So, what if I would like to change the subsections and subsubsections to be in smallcaps (boldfont) in order to distinguish with paragraph? Aug 9, 2021 at 0:47