LaTeX プロジェクトのツリー ビュー構造を取得するためのコマンド ライン オプション

LaTeX プロジェクトのツリー ビュー構造を取得するためのコマンド ライン オプション

セクション、章、図などを表示する LaTeX プロジェクトのツリー ビューを取得したいと思います。

- Table of contents
- Introduction (1.0)
--- fig 1  fig one title
--- fig 2   fig two title
- Second section (2.0)
--- fig 3 fig three title
- First Subsection in section 2 (2.1)
- Conclusion (3.0)
- References (4.0)

単語数をカウントできる texcount など、これに使用できる便利なコマンドライン ツールはありますか。

答え1

申し訳ありませんが、ツールではありませんが、非常にシンプルなtree

\documentclass{article}

\newwrite\tvhandle%


\usepackage{pgffor}
\usepackage{xpatch}

\makeatletter
\newcounter{mylevel}

\newcommand{\writetv}[3]{%
  \edef\mydef{\space}
  \ifnum #3 > 0
  \foreach \x in {1,...,#3}
  {
    \xdef\mydef{\mydef-}
  }
  \fi
  \immediate\write\tvhandle{\mydef #1 #2}
}

\xapptocmd{\tableofcontents}{%
  \addtocontents{tvaux}{\protect\writetv{}{\contentsname}{0}}%
}{}{}

\xapptocmd{\listoffigures}{%
  \addtocontents{tvaux}{\protect\writetv{}{\listfigurename}{0}}%
}{}{}

\newcommand\starttreeview{%
  \immediate\openout\tvhandle=\jobname.tv
  \@starttoc{tvaux}%
  \immediate\closeout\tvhandle
}

\xpatchcmd{\@sect}{%
  \addcontentsline{toc}{#1}{%
    \ifnum #2>\c@secnumdepth \else
    \protect\numberline{\csname the#1\endcsname}%
    \fi
    #7}%
}{%
  \addtocontents{tvaux}{\protect\writetv{\csname the#1\endcsname}{#7}{#2}}%
  \addcontentsline{toc}{#1}{%
    \ifnum #2>\c@secnumdepth \else
    \protect\numberline{\csname the#1\endcsname}%
    \fi
    #7}%  
}{}{}

\makeatother

\begin{document}
\starttreeview
\tableofcontents
\listoftables
\listoffigures

\section{first}

\subsection{first}

\subsubsection{first}

\paragraph{first}

\subparagraph{first}

\section{Second}


\subsection{second}

\subsubsection{second}

\paragraph{second}

\subparagraph{second}



\end{document}

\jobname.tvこれにより、ファイル内に整列されていない「ツリー」(残念ながら、図はまだありません)が生成されます。

 Contents
  List of Figures
 -1 first
 --1.1 first
 ---1.1.1 first
 -2 Second
 --2.1 second
 ---2.1.1 second

関連情報