1

When I use this bellow to make the section text upper case:

\makeatletter
\renewcommand*{\l@section}[2]
{%
    \l@chapapp{\uppercase{#1}}{#2}{\cftsectionname}
}
\makeatother

The spacing between my chapter and section is added to the same length as set by (TOC Spacing in Memoir):

\setlength{\cftbeforechapterskip}{12pt}

enter image description here

But if I remove these lines:

\makeatletter
\renewcommand*{\l@section}[2]
{%
    \l@chapapp{\uppercase{#1}}{#2}{\cftsectionname}
}
\makeatother

The spacing between chapters and section is correct:

enter image description here

How to make the table of contents section title upper case without messing with the space between the chapter and section?


With this full code, you can reproduce the problem after building it two times:

\documentclass{abntex2}

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

% TOC Spacing in Memoir
% https://tex.stackexchange.com/questions/60317/toc-spacing-in-memoir
\setlength{\cftbeforechapterskip}{12pt}

\makeatletter
\renewcommand*{\l@section}[2]
{%
    \l@chapapp{\uppercase{#1}}{#2}{\cftsectionname}
}
\makeatother

\begin{document}

\begin{KeepFromToc}
\tableofcontents
\end{KeepFromToc}

\chapter*{Foreword}
\addcontentsline{toc}{chapter}{Foreword}

\chapter*{Abstract}
\addcontentsline{toc}{chapter}{Abstract}

\chapter{Chapter One}
\section{Section One One}
\subsection{Section One One}

\section{Section One Two}
\subsection{Section One Two}
\section{Section One Three}
\section{Section One Four}


\chapter{Chapter One}
\section{Section One One}

\section{Section One Two}
\section{Section One Three}
\section{Section One Four}

\end{document}
1

I managed to fix it using a general solution for the article class I find on How to make section name uppercase in ToC?:

\documentclass{memoir}
\usepackage{textcase}

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

\makeatletter
\let\oldcontentsline\contentsline
\def\contentsline#1#2{%
  \expandafter\ifx\csname l@#1\endcsname\l@section
    \expandafter\@firstoftwo
  \else
    \expandafter\@secondoftwo
  \fi
  {%
    \oldcontentsline{#1}{\MakeTextUppercase{#2}}%
  }{%
    \oldcontentsline{#1}{#2}%
  }%
}
\makeatother

\begin{document}

    \begin{KeepFromToc}
        \tableofcontents
    \end{KeepFromToc}

    \chapter*{Foreword}
    \addcontentsline{toc}{chapter}{Foreword}

    \chapter*{Abstract}
    \addcontentsline{toc}{chapter}{Abstract}

    \chapter{Chapter One}
    \section{Section One One}
    \subsection{Section One One}

    \section{Section One Two}
    \subsection{Section One Two}
    \section{Section One Three}
    \section{Section One Four}


    \chapter{Chapter One}
    \section{Section One One}

    \section{Section One Two}
    \section{Section One Three}
    \section{Section One Four}

\end{document}

enter image description here

Also it was required to remove these statements from my file:

\renewcommand*{\l@chapter}[2]
{%
    \l@chapapp{\uppercase{#1}}{#2}{\cftchaptername}
}

\renewcommand*{\l@section}[2]
{%
    \l@chapapp{\ABNTEXsectionfont\uppercase{#1}}{#2}{\cftsectionname}
}

They were the cause of all my problems. I am not sure why they are scrolling everything, as causing the spacing between the section and chapter to be the same as the space between chapters.

This last should be due the fact that the command is redefining the \l@section with \l@chapapp, which is just like begging for trouble and weird behaviors.

Here are some related references for the memoir class and table of contents:

  1. Uppercase sections and subsections on ToC
  2. Uppercasing in a "memoir" Table of Contents with "hyperref"
  3. Making memoir Chapter entries in ToC all-caps and Appendix entries regular case, without breaking hyperref
  4. hyperref, MakeUppercase and memoir
  5. TOC Spacing in Memoir
  6. Bind vertical spacing change in ToC to \*matter commands
  7. How to change this specific TOC margin in memoir
  8. Change vertical space of chapters temporarly in Table of Contents

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.