I am using this customization How to automatically put a [Go To Summary] | [Go Back] on each section?, but when I load it together with abntex2 class, my go back buttons are put on the next line for the \chapter{} command. Everything works fine for \section{} and others:
If I remove the following code from the abntex2 class, then, it is fixed:
\def\printchaptertitle##1{%
\chaptitlefont%
\ifthenelse{\boolean{abntex@innonumchapter}}{\centering\ABNTEXchapterupperifneeded{##1}}{%
\ifthenelse{\boolean{abntex@apendiceousecao}}{%
\centering%
\settowidth{\chapternamenumlength}{\printchaptername\printchapternum\afterchapternum}%
\ABNTEXchapterupperifneeded{##1}%
}{%
\settowidth{\chapternamenumlength}{\printchaptername\printchapternum\afterchapternum}%
\parbox[t]{\columnwidth-\chapternamenumlength}{\ABNTEXchapterupperifneeded{##1}}}%
}
}
This is my minimal example:
\documentclass[
10pt,
a5paper
]{abntex2}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{xcolor}
\definecolor{ultramarine}{RGB}{0,32,96}
\RequirePackage{amssymb}
\newcommand{\goToSummaryText}
{%
\small\mdseries
\hyperlink{summary}{\textcolor{ultramarine}{$\leftleftarrows$}}
{$|$}
\Acrobatmenu{GoBack}{\textcolor{ultramarine}{$\leftarrow$}}
}
\makeatletter
\newif\ifismemoirloaded\ismemoirloadedfalse
\@ifclassloaded{memoir}
{%
\ismemoirloadedtrue
}{}
\newcommand{\addGoToSummary}
{%
\renewcommand{\Sectionformat}[2]{##1 \protect\goToSummaryText}
\ifismemoirloaded
\let\oldprintchaptertitle\printchaptertitle
\renewcommand{\printchaptertitle}[1]{\oldprintchaptertitle{##1} \protect\goToSummaryText}
\else\fi
}
\newcommand{\removeGoToSummary}
{%
\renewcommand{\Sectionformat}[2]{##1}
\ifismemoirloaded
\let\printchaptertitle\oldprintchaptertitle
\else\fi
}
\makeatother
\let\oldtableofcontents\tableofcontents
\renewcommand{\tableofcontents}
{%
\hypertarget{summary}%
\oldtableofcontents%
}
\begin{document}
\addGoToSummary
\chapter{Section contents}
thing2.
\end{document}
How can I patch abntex2 class or my command to fix this issue?
References:

