I'd like to create a custom subsection that satisfies the followings:
- Bold letter
- The font size is the same as that of the paragraphs.
- Indent before the title
- Do not start a new line after the title.
I'd like to create a custom subsection that satisfies the followings:
This is easy to do with titlesec.
\documentclass{article}
\usepackage{lipsum}
\usepackage{titlesec}
\titleformat{\subsection}[runin]{\bfseries}{}{\parindent}{}[.]
\begin{document}
\section{A section}
\subsection{A subsection}
\lipsum[1-2]
\end{document}
I added a dot at the end of the subsection title because I thought it made sense to have a separation with the text. If you want to remove it or to change it, the part of the code responsible for that is the optional argument [.] of \titleformat.
You can use titlesec and specify \titleformat and \titlespacing.
I also suggest to add punctuation for run-in titles. You can make a period appear automatically, if you forget one, but not if the title already ends with punctuation.
\documentclass{article}
\usepackage{amsthm}% for \@addpunct
\usepackage{titlesec}
\usepackage{lipsum}
\makeatletter
\titleformat{\subsection}[runin]
{\normalfont\bfseries}
{\thesubsection}
{0.5em}
{}
[@addpunct{.}]
\titlespacing{\subsection}
{\parindent}
{3.5ex plus 1ex minus 0.2ex}
{0.5em}
\makeatother
\begin{document}
\section{A section}
\subsection{A subsection}
\lipsum[1][1-3]
\subsection{A subsection with period.}
\lipsum[2][1-3]
\subsection{Another subsection?}
\lipsum[3][1-3]
\lipsum[4][1-3]
\subsection*{Unnumbered!}
\lipsum[5][1-3]
\end{document}