2

I decided to use \usepackage[center]{titlesec} in order to center my sections, but I don't want them displaying the chapter/section numbering in the chapter/section headings so I applied the titleformat. But with this new macro, it erased the [center] command.

\documentclass[14pt]{memoir}

\usepackage[center]{titlesec}
\usepackage{lipsum}

\titleformat{\chapter}
{\Large\bfseries}
{}
{0pt}
{\huge}

\titleformat{\section}
{\Large\bfseries} 
{}
{0pt}
{\large}

\begin{document}

\tableofcontents

\chapter{This shouldn't be centered}
\clearpage
\section{This should be centered}
\lipsum[1]
\subsection{This should be centered}
Nothing to see here.
\end{document}

Result:

enter image description here

2

2 Answers 2

2

like this ? :

\documentclass[14pt]{memoir}

\usepackage[center]{titlesec}
\usepackage{lipsum}

\titleformat{\chapter}
  {\centering\Large\bfseries} % format
  {}% label
  {0pt} % sep
  {\huge}  

\setcounter{secnumdepth}{0}

\begin{document}

\tableofcontents

\chapter{This shouldn't be centered}
\clearpage
\section{This should be centered}
\lipsum[1]
\subsection{This should be centered}
Nothing to see here.
\end{document}

Result: enter image description here

2
  • I tried it and saw that \chapter{This shouldn't be centered} actually centered. Oh well but once I removed \centering it was all good!... But the numbers came back.
    – Xyd
    Jan 19, 2016 at 18:56
  • I found an answer elsewhere and used \setsecnumdepth{none} \maxsecnumdepth{none} instead of \setcounter{secnumdepth}{0} and now it worked (as for removing the darn numbers).
    – Xyd
    Jan 19, 2016 at 19:18
2

You shouldn't use titlesec with memoir, see About memoir and titlesec incompatibility

\documentclass[14pt]{memoir}

\usepackage{lipsum}

\setsecheadstyle{\centering\Large\bfseries}
\setsubsecheadstyle{\centering\large\bfseries}

\setsechook{\setsecnumformat{\csname the##1\endcsname\ }}

\begin{document}

\tableofcontents

\chapter{This shouldn't be centered}
\section{This should be centered}
\lipsum[1]
\subsection{This should be centered}
Nothing to see here.
\end{document}

enter image description here

You must log in to answer this question.

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