[Tex/LaTex] Forcing some \section text to not be capitalized

capitalization

I have a document with the configuration below. I tried to use \MakeLowercase to force some text inside some sections to not be capitalized, but I'm get a warning (figure below). I would like to know how to solve this.

\documentclass[
    12pt,       
    openright,   
    twoside,    
    a4paper,     
    chapter=TITLE, 
    section=TITLE,
    english,
    french,
    spanish,
    brazil, 
]{abntex2}


\usepackage{lmodern}    
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc} 
\usepackage{lastpage}       
\usepackage{indentfirst}        
\usepackage{color}          
\usepackage[final]{graphicx}    
\usepackage{microtype}          
\usepackage[table,xcdraw]{xcolor}
\usepackage{hyperref}
\usepackage{subcaption}
\usepackage{epigraph}
\usepackage{url}
\usepackage{placeins}
\usepackage{multirow}
\usepackage[figuresright]{rotating}
\usepackage{chemfig}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{enumitem}
\usepackage{bigints}
\usepackage{environ}
\usepackage{listings}
\usepackage[brazilian,hyperpageref]{backref} 
\usepackage[alf]{abntex2cite}


\begin{document}

\chapter{Foo}

\section{This is my title \MakeLowercase{this cannot be capitalized!} foo bar}

\end{document}

enter image description here

Best Answer

The following is a solution which works with hyperref. If hyperref is not loaded you can just use \lowercase like this: \section{Foo \lowercase{no upper case} bar}

If hyperref is loaded this results in a warning ("Token not allowed in a PDF string...") and because of this we have to additionally use \texorpdfstring. I defined a \titlelowercase macro for this usage. Now you'd have to use \section{Foo \titlelowercase{no upper case} bar}:

\documentclass[
    12pt,       
    openright,   
    twoside,    
    a4paper,     
    chapter=TITLE, 
    section=TITLE,
    english,
    french,
    spanish,
    brazil, 
]{abntex2}


\usepackage{lmodern}    
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc} 
\usepackage{lastpage}       
\usepackage{indentfirst}        
\usepackage{color}          
\usepackage[final]{graphicx}    
\usepackage{microtype}          
\usepackage[table,xcdraw]{xcolor}
%\usepackage{hyperref}% hyperref is loaded by the class abntex2
\usepackage{subcaption}
\usepackage{epigraph}
\usepackage{url}
\usepackage{placeins}
\usepackage{multirow}
\usepackage[figuresright]{rotating}
\usepackage{chemfig}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{enumitem}
\usepackage{bigints}
\usepackage{environ}
\usepackage{listings}
\usepackage[brazilian,hyperpageref]{backref} 
\usepackage[alf]{abntex2cite}

\newcommand\titlelowercase[1]{\texorpdfstring{\lowercase{#1}}{#1}}

\begin{document}
\tableofcontents
\chapter{Foo}

\section{This is my title \titlelowercase{this cannot be capitalized!} foo bar}

\end{document}

enter image description here

You might as well use \MakeTextLowercase instead of \lowercase. It is provided by the textcase package (which is loaded by abntex2 as well) and should handle some characters \lowercase doesn't (as far as I know).