0

I've managed to change the section formating mid-document. However, in the table of contents, the formatting resets. I'm new to latex so I don't fully understand the \titleformat option. I want it to say "Anexo A" but in the table of content it says "A Anexo". Thanks in advance.

\documentclass[12pt]{article}  
\usepackage[explicit]{titlesec}
\usepackage{blindtext}
\begin{document}
    \tableofcontents
    \section{Introdução}
    \blindtext

    \setcounter{section}{0}
    \renewcommand{\thesection}{\Alph{section}} 
    \titleformat{\section}{\normalfont\Large\bfseries}{}{0em}{#1\ \thesection}
    \section{Anexo}
    \blindtext
\end{document}

enter image description here

0

You should simply switch #1 and \thesection. The #1 is the argument (i.e. the section title), whereas the \thesection is the value of the section counter.

\documentclass[12pt]{article}  
\usepackage[explicit]{titlesec}
\usepackage{blindtext}
\begin{document}
    \tableofcontents
    \section{Introdução}
    \blindtext

    \setcounter{section}{0}
    \renewcommand{\thesection}{\Alph{section}} 
    \titleformat{\section}{\normalfont\Large\bfseries}{}{0em}{\thesection\ #1}

    \section{Anexo}
    \blindtext
\end{document}
|improve this answer|||||
  • Thanks for the reply, but that does the opposite of what I want. I want the section counter to appear after the section title in both the table of context and the document, "Anexo A". Where "Anexo" is the section title and "A" the section counter. – Renato Morais Jan 21 at 23:56

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.