5

I've read through section 2 and 3 of titlesec's package documentation, and unfortunately I find it extremely cryptic, so I've given up trying to come to terms with it. Please bear with me as I'm just posting an example of how I want my \section headings to look.

\documentclass{article}
\usepackage{titlesec}
\begin{document}
\section{My first section}
Here is the content of my first section.\\

% Below how I want it to look
\noindent {\large{\textbf{1. My first section}}}\\
Here is the content of my first section.\\
\end{document}

enter image description here

1 Answer 1

7
\documentclass{article}
\usepackage{titlesec}

\titleformat{\section}
  {\normalfont\large\bfseries}{\thesection.}{.5em}{}
\titlespacing*{\section}
  {0pt}{3.5ex plus 1ex minus .2ex}{0.3ex plus .2ex}

\begin{document}

\section{Test section}
Some test text here.

\end{document}

An image before the changes:

enter image description here

an image after the changes:

enter image description here

Explanation of the code:

Take the default settings for \section:

\titleformat{\section}
  {\normalfont\Large\bfseries}{\thesection}{1em}{}
\titlespacing*{\section}
  {0pt}{3.5ex plus 1ex minus .2ex}{2.3ex plus .2ex}

change \Large to \large, add a period after \thesection, change 1em (the default separation between number and title) to 0.5em (or to the desired value), and reduce the length in the fourth argument of \titlespacing*.

By the way, and not related, to the question, \large (and the other font size switches also) doesn't take arguments; instead of \large{<text>} you should use {\large <text>} (the braces just in case grouping is required).

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .