回忆录类中的悬挂式章节编号

回忆录类中的悬挂式章节编号

我希望在使用回忆录类时,可以悬挂、设置章节编号。答案使用回忆录类自定义章节格式(颜色和编号)解释如何只设置数字的样式,以及答案在回忆录中悬挂章节编号,但不悬挂子章节编号解释了如何挂起部分编号。但是,当我尝试组合它们时,我的样式消失了!

我使用的命令是:

\setsecnumformat{\color{blue}\csname the#1\endcsname\quad}
\setsechook{\hangsecnum}

有没有办法做到这一点?

答案1

这应该可以满足您的要求。它只是将\hangsecnum部分编号修改为蓝色。

\documentclass[article]{memoir}
\usepackage{xcolor}
\setcounter{secnumdepth}{3}

\makeatletter
\renewcommand{\hangsecnum}{%
  \def\@seccntformat##1{%
    \makebox[0pt][r]{%
      \color{blue}%
      \csname the##1\endcsname
      \quad
    }%
  }%
}
\makeatother

\setsechook{\hangsecnum}
\setsubsechook{\defaultsecnum}

\begin{document}

\section{First Section}
\subsection{First Subsection}
\subsubsection{First Subsubsection}

I would like hanging, styled section numbers while using the memoir
class. The answer customizing section formatting using memoir class
(color and numbering) explains how to style just the numbers, and the
answer Hang section number, but not subsection number in Memoir
explains how to hang the section number. However, when I attempt to
combine these, my styling vanishes!

\section{Second Section}
\subsection{Second Subsection}
\subsubsection{Second Subsubsection}

I would like hanging, styled section numbers while using the memoir
class. The answer customizing section formatting using memoir class
(color and numbering) explains how to style just the numbers, and the
answer Hang section number, but not subsection number in Memoir
explains how to hang the section number. However, when I attempt to
combine these, my styling vanishes!

\end{document}

相关内容