如何创建带有子目录的内部部分环境?

如何创建带有子目录的内部部分环境?

有没有一种简单的方法可以创建一个类似于内部部分的环境,可以在首选位置生成子目录?子表不一定需要提供页码,但它应该设置指向内部子部分项目的链接。我的想法看起来有点像这样

\section{Lorem Ipsum}
\myinnersec_subtable

\myinnersec{InnerSubSectionOne}\label{InnerSubSectionOne}
....
\myinnersec{InnerSubSectionTwo}\label{InnerSubSectionTwo}
....

并应该产生类似

带有子表的内部子部分

答案1

您可以使用以下方式实现部分 ToCtitletoc包及其\startcontents\printcontents\stopcontents命令。一个小例子,显示了部分目录和活动超链接:

\documentclass{article}
\usepackage{titletoc}
\usepackage{hyperref}

\newcommand\innercontentsname[1]{%
  Contents for section~\ref{#1}}

\let\oldthesubsection\thesubsection

\begin{document}

\section{A regular section}
\subsection{Regular subsection one}
\subsection{Regular subsection two}

\section{Section with inner units and partial ToC}
\label{sec:ptoc}
\renewcommand\thesubsection{\Alph{subsection}}

\startcontents[inner]
\printcontents[inner]{}{1}{\subsection*{\innercontentsname{sec:ptoc}}}

\subsection{Inner special subsection one}
\subsection{Inner special subsection two}
\subsubsection{Inner special subsubsection one}
\subsubsection{Inner special subsubsection two}
\subsection{Inner special subsection three}

\stopcontents[inner]
\renewcommand\thesubsection{\oldthesubsection}

\section{Another regular section}
\subsection{Regular subsection one}
\subsection{Regular subsection two}

\end{document}

在此处输入图片描述

在对该问题的评论中,有人要求内部小节不应包含在总目录中;这可以通过使用\startcontents\printcontents\resumecontents打印总目录来实现:

\documentclass{article}
\usepackage{titletoc}
\usepackage{hyperref}

\newcommand\innercontentsname[1]{%
  Contents for section~\ref{#1}}

\let\oldthesubsection\thesubsection

\begin{document}

\startcontents
\printcontents{}{1}{\section*{\contentsname}}

\section{A regular section}
\subsection{Regular subsection one}
\subsection{Regular subsection two}

\section{Section with inner units and partial ToC}
\label{sec:ptoc}
\renewcommand\thesubsection{\Alph{subsection}}
\stopcontents[default]

\startcontents[inner]
\printcontents[inner]{}{1}{\subsection*{\innercontentsname{sec:ptoc}}}

\subsection{Inner special subsection one}
\subsection{Inner special subsection two}
\subsubsection{Inner special subsubsection one}
\subsubsection{Inner special subsubsection two}
\subsection{Inner special subsection three}

\stopcontents[inner]
\renewcommand\thesubsection{\oldthesubsection}

\resumecontents
\section{Another regular section}
\subsection{Regular subsection one}
\subsection{Regular subsection two}

\end{document}

在此处输入图片描述

相关内容