[Tex/LaTex] How to change the ‘Section’ title and its arrangement in a LaTeX document

document-configurationsectioning

I am handing in an assignment that is structured by exercises, rather than sections. I have already written my responses using the \section{} command and would now like to structure the final output by exercises rather than sections. Concretely, I want the number to appear to the right of each exercise: Exercise 4 instead of 4 Section title.

I have been able to find information on how to do this for chapters and many other document parts here on SE, but strangely not for sections.

Here's an MWE:

\documentclass{article}
\begin{document}

\section{Exercise} % First exercise

\section{Exercise} % Second exercise

\section{Exercise} % Third exercise

\end{document}

Produces this:

MWE

Now all I really need to do is reverse the order from # Section title to Section title # because my section title is exercise. Also, ideally, the section numbering would be in roman numerals, while subsections remain as originally formatted.

Best Answer

With article class as you specified in the MWE, one can employ titlesec.

\documentclass{article}
\renewcommand{\thesection}{\Roman{section}}
\usepackage{titlesec}
\titleformat{\section}
{\normalfont\Large\bfseries}{Exercise~\thesection}{1em}{}

\begin{document}

\section{Exercise} % First exercise

\section{Exercise} % Second exercise

\section{Exercise} % Third exercise

\end{document}

enter image description here

Related Question