我正在使用这个定制如何在每个部分自动添加[转至摘要] | [返回]?但是当我将它与abntex2
类一起加载时,我的返回按钮被放在命令的下一行。对于其他所有\chapter{}
功能,一切正常:\section{}
如果我从类中删除以下代码abntex2
,那么它就被修复了:
\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}}}%
}
}
这是我的最小例子:
\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}
我该如何修补abntex2
类或我的命令来解决这个问题?
参考:
答案1
abntex2
我设法通过检查是否已加载并直接修补来修复它\ABNTEXchapterupperifneeded
。
如果有人知道更好或更通用的答案,请分享!
\documentclass[
10pt,
a5paper
]{memoir}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{xcolor}
\definecolor{ultramarine}{RGB}{0,32,96}
\RequirePackage{xpatch}
\RequirePackage{amssymb}
\RequirePackage{hyperref}
\newcommand{\goToSummaryText}{{%
\small\mdseries
\hyperlink{summary}{\textcolor{ultramarine}{$\leftleftarrows$}}
{$|$}
\Acrobatmenu{GoBack}{\textcolor{ultramarine}{$\leftarrow$}}
}}
\makeatletter
\newif\ifismemoirloaded\ismemoirloadedfalse
\newif\ifisabntexloaded\isabntexloadedfalse
\@ifclassloaded{memoir}{%
\ismemoirloadedtrue%
}{}
\@ifclassloaded{abntex2}{%
\isabntexloadedtrue%
}{}
\newcommand{\addGoToSummary}
{%
\@ifundefined{printparttitle}{\message{printparttitle patch for addGoToSummary could NOT
be applied because there is no printparttitle command available!^^J}}{%
\let\oldAddGoToprintparttitle\printparttitle
\xapptocmd{\printparttitle}{~\protect\goToSummaryText}{}{}
}
\@ifundefined{Sectionformat}{\message{Sectionformat patch for addGoToSummary could NOT
be applied because there is no Sectionformat command available!^^J}}{%
\let\oldAddGoToSectionformat\Sectionformat
\xapptocmd{\Sectionformat}{~\protect\goToSummaryText}{}{}
}
\ifismemoirloaded
\ifisabntexloaded
\let\oldAddGoToABNTEXchapterupperifneeded\ABNTEXchapterupperifneeded
\xapptocmd{\ABNTEXchapterupperifneeded}{~\protect\goToSummaryText}{}{}
\else
\let\oldAddGoToprintchaptertitle\printchaptertitle
\xapptocmd{\printchaptertitle}{~\protect\goToSummaryText}{}{}
\fi
\else
\@ifundefined{Chapterformat}{\message{Chapterformat patch for addGoToSummary could NOT
be applied because there is no Chapterformat command available!^^J}}{%
\let\oldAddGoToChapterformat\Chapterformat
\xapptocmd{\Chapterformat}{~\protect\goToSummaryText}{}{}
}
\fi
}
\newcommand{\removeGoToSummary}
{%
\@ifundefined{oldAddGoToprintparttitle}{}{\let\printparttitle\oldAddGoToprintparttitle}
\@ifundefined{oldAddGoToSectionformat}{}{\let\Sectionformat\oldAddGoToSectionformat}
\ifismemoirloaded
\ifisabntexloaded
\@ifundefined{oldAddGoToABNTEXchapterupperifneeded}{}{\let\ABNTEXchapterupperifneeded\oldAddGoToABNTEXchapterupperifneeded}
\else
\@ifundefined{oldAddGoToprintchaptertitle}{}{\let\printchaptertitle\oldAddGoToprintchaptertitle}
\fi
\else
\@ifundefined{oldAddGoToChapterformat}{}{\let\Chapterformat\oldAddGoToChapterformat}
\fi
}
\makeatother
\let\oldAddGoTotableofcontents\tableofcontents
% Insert internal document link
\renewcommand{\tableofcontents}{%
\hypertarget{summary}%
\oldAddGoTotableofcontents%
}
\begin{document}
\addGoToSummary
\part{My}
\chapter{Chapter title}
thing1.
\removeGoToSummary
\section{Section title}
thing2.
\addGoToSummary
\section{Section title}
thing3.
\end{document}
参考: