为了使其看起来如下所示,我想在每个节、小节和小小节的编号中添加一个框架。
但以下代码似乎不适用于“subsubsection”。
\documentclass[12pt,a4paper]{report}
\usepackage[french]{babel}
\usepackage[a4paper,margin=0.5in]{geometry}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[Glenn]{fncychap}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\renewcommand\thesection{\fbox{\Roman{section}}}
\renewcommand\thesubsection{\fbox{\arabic{subsection}}}
\renewcommand\thesubsubsection{\fbox{\begin{english}\textit{\alph{subsubsection}}\end{english}}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\chapter{}
\section{Section}
\subsection{Subsection 1}
\subsection{Subsection 2}
\subsubsection{\fbox{a} subSubsection}
\subsubsection{\fbox{b} subSubsection}
\section{section}
\subsection{subsection}
\subsubsection{\fbox{a} subsubsection}
\end{document}
答案1
一些评论,无特定顺序。
文档
report
类执行\setcounter{secnumdepth}{2}
,即它不会自动编号子节级标题。运行\setcounter{secnumdepth}{3}
告诉 LaTeX 也对子小节级别的标题进行编号。
将指令纳入、和
\fbox
的(重新)定义中是一个非常糟糕的主意。为什么?因为框架框将显示在对节、小节和小小节的所有交叉引用中 - 这几乎肯定不是您想要的。\thesection
\thesubsection
\thesubsubsection
相反,使用低级
\@seccntformat
宏 - 请参阅下面的应用程序代码 - 告诉 LaTeX 仅在标题中绘制框架框。由于您在子小节级别标题中使用字母字符,因此应采取预防措施,确保使用完全相同的框架框,无论字母既无上升部又无下降部(例如
a
和z
),只有上升部(例如b
),只有下降部(“y”或“j”),还是两者都有(斜体形状)。 可以通过在定义中f
插入指令来解决大小不规则问题。\vphantom{f}
\subsubsection@cntformat
\documentclass[12pt,a4paper]{report}
\usepackage[french]{babel}
\usepackage[margin=0.5in]{geometry}
\usepackage[Glenn]{fncychap}
\setcounter{secnumdepth}{3} % <-- new
\renewcommand\thesection{\Roman{section}}
\renewcommand\thesubsection{\arabic{subsection}}
\renewcommand\thesubsubsection{\alph{subsubsection}}
% Use method proposed in "The LaTeX Companion", 2nd ed., to determine
% how the section-like counters are displayed in sectioning headers
\makeatletter
\def\@seccntformat#1{\@ifundefined{#1@cntformat}%
{\csname the#1\endcsname\space}% default
{\csname #1@cntformat\endcsname}}% enable individual control
\newcommand\section@cntformat{% section
\fbox{\thesection}\quad}
\newcommand\subsection@cntformat{% subsection
\fbox{\thesubsection}\quad}
\newcommand\subsubsection@cntformat{% subsubsection
\fbox{\itshape\thesubsubsection\vphantom{f}}\quad}
\makeatother
\begin{document}
\arabic{secnumdepth}
\chapter{}
\section{Section}
\subsection{Subsection 1}
\subsection{Subsection 2}
\subsubsection{subSubsection}
\subsubsection{subSubsection}
\section{Section}
\subsection{Subsection}
\subsubsection{subSubsection}
\end{document}