I would like to use titlesec
to center my sections as follows (MWE):
\documentclass[10pt,a4paper,twoside]{book}
\usepackage[latin1]{inputenc}
\usepackage{lipsum}
\usepackage{titlesec}
\titleformat{\section}% command to format the section titles
[block]% shape/type of title
{\LARGE\bfseries}% formatting commands applied to both label and title
{\begin{center} \thesection \end{center}}% section number; here set inside an invisible box with a constant width
{0em}% separation between number and chapter title; we've already covered this with the box
{}% additional formatting command for title itself not applied to number
[
]%
\begin{document}
\chapter{The first chapter}
\lipsum[1-5]
\section{First section}
\lipsum[3]
\section*{Section}
\lipsum[4]
\end{document}
But this does not center the title of the section, and it is not very beautiful either. How can I beautifully center sections using titlesec
?
\centering
rather than\begin{center}...\end{center}
and put it with the\LARGE\bfseries
which applies to the title, too.@cfr
, I have tried, but it does not work.