获取 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

相关内容