5

This question already has an answer here:

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.

marked as duplicate by Werner, egreg, Jesse, ChrisS, jub0bs Mar 7 '14 at 23:35

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 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. – Gonzalo Medina Mar 8 '14 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 '14 at 2:58
  • 1
    @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? – Gonzalo Medina Mar 8 '14 at 3:25
5

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}

enter image description here

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}

enter image description here

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.

Not the answer you're looking for? Browse other questions tagged or ask your own question.