This question is about how to center all the sections (including chapters) without centering subsections.

I have browsed all the related questions asked here but I found no one to which my question is duplicate. I have tried a proposed solution that centers all the headlines. But I do not know how to partially center the headlines.

Need your help, thanks so much, with my codes:

\usepackage{amsmath}`enter code here`
\usepackage{rotating, threeparttable, booktabs}

\newcommand\laref{\fontsize{12}{20pt}\selectfont \smallskip\noindent%

% To increase line space in footnote.

%centering all titles
  • 1
    If your .tex file contains a line \documentclass, you are not writing a 'plain TeX' document, but a LaTeX document. The correct answer to your problem depends on you specifying whether you are using LaTeX or not. – jon Sep 26 '14 at 3:09
  • @jon, much appreciated, I see. :) – Megadeth Sep 26 '14 at 3:11
  • 1
    And the article class doesn't define chapters! – user11232 Sep 26 '14 at 4:05
  • @HarishKumar - I've deleted the 'article' tag and added the 'formatting' tag. You've got editing rights too, right? – Mico Sep 26 '14 at 5:31
  • @Mico hehe!. I do certainly. But I don't use it well ;-) – user11232 Sep 26 '14 at 5:37

One way with sectsty:

  \section{Some section}
  \subsection{A subsection}

enter image description here

sectsty also offers \chapterfont (but in article class, there ain't no chapter), \subsectionfont etc along with \allsectionsfont which will apply to all sections.

With titlesec:

  \section{Some section}
  \subsection{A subsection}
  • Thanks. But they did not work for me; they both changed nothing :) – Megadeth Sep 26 '14 at 5:44
  • @Comeseeconquer That is why we need to see your code ;-) – user11232 Sep 26 '14 at 5:47
  • Right, please see the edit. – Megadeth Sep 26 '14 at 6:36
  • I was mistaken; it is alright now. – Megadeth Sep 26 '14 at 6:43
  • titlesec didn't work for me here either btw, sectsty did though thanks – baxx Dec 14 '15 at 19:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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