0

I saw already all the links about this problem here at StackOverFlow but none of them could help me. I am trying to change the section names in ToC to uppercase using also the hyperref package but it doesn't work.

Here is my code:

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[brazil]{babel}

\usepackage{geometry} \usepackage{caption} \usepackage{indentfirst} \linespread{1.5} \usepackage{afterpage} \usepackage{listofitems} \usepackage{amsmath} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsthm} \usepackage{lipsum} \usepackage{array,mathtools} \usepackage{graphicx} \usepackage{float} \usepackage{tikz} \usepackage{pgfplots} %\usepackage{xstring} \usepackage{lastpage} \pgfplotsset{compat=1.15} \usepackage{geometry} \usepackage{enumerate} \usepackage[labelsep=endash,format=hang,font=small]{caption} \geometry{a4paper, top=3cm, left=3cm, right=2cm, bottom=2cm, }

\usepackage[num]{abntex2cite}

% MODIFICAR TÍTULOS DAS SEÇÕES DE FIGURAS, TABELAS E SUMÁRIO \addto\captionsbrazil{% \renewcommand\contentsname{\hspace{\fill}\bfseries\large\sffamily SUMÁRIO\hspace{\fill}} \renewcommand\listfigurename{\hspace{\fill}\bfseries\large\sffamily LISTA DE FIGURAS\hspace{\fill}} \renewcommand\listtablename{\hspace{\fill}\bfseries\large\sffamily LISTA DE TABELAS\hspace{\fill}} }

% AJUSTAR AS SEÇÕES E SUBSEÇÕES \usepackage{titlesec} \usepackage{titletoc} \titlespacing{\section}{0pt}{0pt}{1.5cm} \titleformat{\section}[hang] {\bf\sffamily\large}{\thesection}{20pt}{\MakeUppercase} \titlespacing{\subsection}{0pt}{1.5cm}{1.5cm} \titlespacing*{\subsubsection}{0pt}{1.5cm}{1.5cm}

% MODIFICAR O SUMÁRIO \titlecontents{section}[1cm]{\bfseries\sffamily}{\contentslabel{3em}} {\hspace{0em}}{\titlerule*[1pc]{.}\contentspage}

\titlecontents{subsection}[1cm]{\sffamily}{\contentslabel{3em}} {\hspace{0em}}{\titlerule*[1pc]{.}\contentspage}

\titlecontents{subsubsection}[1cm]{\sffamily}{\contentslabel{3em}} {\hspace{0em}}{\titlerule*[1pc]{.}\contentspage}

% MODIFICAR A LISTA DE FIGURAS \titlecontents{figure}[0em]{ Figura~\thecontentslabel \enspace - \enspace }{}{\hspace{0em}}{\titlerule*[1pc]{.}\contentspage}

% MODIFICAR LISTA DE TABELAS \titlecontents{table}[0em]{ Tabela~\thecontentslabel \enspace - \enspace }{}{\hspace{0em}}{\titlerule*[1pc]{.}\contentspage}

\usepackage{fancyhdr} \pagestyle{fancy} \fancyhf{} \fancyhead[RO,LE]{\thepage} \fancyhead[RE,LO]{} \renewcommand{\headrulewidth}{0pt} \usepackage[colorlinks=true, linkcolor=blue, citecolor=blue, filecolor=blue, urlcolor=blue]{hyperref}

2 Answers2

0

I can't process your MWE; there is no \documentclass and no \begin{document} or \end{document}. I see no mention of hyperref.

Probably the easiest method is to use the optional argument to the \section command which gets put into the ToC and the header. Below I have redefined \section to uppercase the ToC entry but eliminated the opportunity to use the optional argument.

% sectocprob.tex  SE 566966

\documentclass{book} \usepackage{lipsum}

\let\oldsec\section \renewcommand{\section}[1]{\oldsec[\MakeUppercase{#1}]{#1}}

\begin{document} \tableofcontents

\chapter{One} \section{First section} \lipsum[1] \clearpage \lipsum[2] \clearpage \lipsum[3] \end{document}

If you need uppercase in the ToC but not in the headers consider using the memoir class which provides two optional section arguments, one for the ToC and the other for headers.

Peter Wilson
  • 28,066
-1

@BlackBird gave me that simplest solution and it worked perfectly. I just needed to put the option in the section command:

\section[INTRODUCTION]{Introduction}

Thank you for all of you.