1

I'm using \docummentclass{amsart}and when using \section it prints it out in the center of the line how to make it on left I used \begin{flushleft} \section \end{flushlef} but it didn't work.

Werner
  • 603,163

1 Answers1

2

Remove \centering from the definition of \section using an etoolbox patch. Since the patch would be permanent from that point forward, you can save the original and modified definitions and creates switches to change the style on demand:

enter image description here

\documentclass{amsart}

\let\centeredsection\section% Copy original centered definition of \section

\usepackage{etoolbox}
% \patchcmd{<cmd>}{<search>}{<replace>}{<success>}{<failure>}
\patchcmd{\section}{\centering}{}{}{}

\let\flushleftsection\section% Copy updated non-centered definition of \section
\newcommand{\sectionscenter}{\let\section\centeredsection}% Switch to centered \section
\newcommand{\sectionsleft}{\let\section\flushleftsection}% Switch to flush left \section

\begin{document}

\noindent X\dotfill X

\section{A section}% Flush left

\sectionscenter

\section{Another section}% Centered

\noindent X\dotfill X

\end{document}
Werner
  • 603,163
  • i removed the '\centering' but it didn't work but i replaced it by putting '\flushleft' in the third brackets and it worked. thank you. – mostafax80 May 14 '16 at 06:35
  • Unfortunately it made the 'bibliography' shifted to the left too ( I didn't know it is treated as a section) how to make it in the center again. Thank you again. – mostafax80 May 14 '16 at 09:20
  • 1
    @mostafax80: See my updated answer which provides switches to change the style of the section on demand. – Werner May 14 '16 at 16:31