內容表為右側生長的樹

內容表為右側生長的樹

如何準備目錄如下:

樣本

\documentclass{article}
\usepackage{tikz}
\usepackage{tikz-qtree}
\begin{document}

\begin{tikzpicture}
\tikzset{grow'=right,level distance=32pt}
\tikzset{execute at begin node=\strut}
\tikzset{every tree node/.style={anchor=base west}}
\Tree [.S [.Introduction ] [.Taxonomy
 ] ]
\end{tikzpicture}
\section{Introduction}
\section{Taxonomy}
\section{User Association}
\subsection{Subsection Header}
\end{document}

答案1

絕對不應該嘗試回答這個問題...

概念證明:

\documentclass{article}
\usepackage[edges]{forest}
\forestset{%
  subsection/.style={%
    delay n={%
      >O{n} %
    }{%
      for preceding siblings={do dynamics},
      temptoksa/.option=name,
      if nodewalk valid={previous}{%
        for previous={%
          if section={append/.register=temptoksa}{}%
        }%
      }{%
        replace by={[, coordinate, append]},
      },
    },
  },
  declare boolean={section}{0},
}
\makeatletter
\newcommand\foresttoc{%
  \begingroup
    \xdef\foresttoctoc{}%
    \renewcommand\contentsline[3]{%
      \let\tempb\foresttoctoc
      \xdef\foresttoctoc{\tempb[{##2}, ##1]}%
    }%
    \renewcommand\numberline[1]{Sec.~##1 }%
    \bracketset{action character=@}%
    \@starttoc{toc}%
    \begin{forest}
      before typesetting nodes={
        forked edges,
        for tree={
          grow'=0,
          anchor=parent,
          tier/.option=level,
        },
        where level=1{fork sep'=0pt}{},
      },
      [, coordinate,   @+\foresttoctoc  ]
    \end{forest}%
  \endgroup
}
\makeatother
\begin{document}
\foresttoc
% \tableofcontents
\subsection{Awkward}
\section{User Association}
\subsection{Subsection Header}
\subsection{Subsection Header}
\section{Introduction}
\section{Taxonomy}
\section{User Association}
\subsection{Subsection Header}
\subsection{Subsection Header}
\end{document}

樹目錄

這允許(但不再要求)您也有一個常規的目錄。這很好,因為所需的格式對於定位內容幾乎沒有用處,而常規目錄的設計就是這樣做的。

相關內容