【Windows】TeXworksにforestを入れる

dirtreeパッケージよりもforestのほうが綺麗にディレクトリツリーを表示できたのでメモ.

インストールの仕方

inlinedefパッケージのダウンロード

forestだけで宣言したらinlinedef.styがないとエラーが出たので依存関係がある
https://www.ctan.org/tex-archive/macros/latex/contrib/inlinedef

ビルドする

ディレクトリに行って

platex *.ins

TeXworksのディレクトリに入れる

自分の環境だとC:\w32tex\share\texmf-dist\tex\latex\0_mypackage\

TeXの環境を更新

$mktexlsr

サンプル

\usepackage{forest}
%forest definition-------------------------------------------
\definecolor{folderbg}{RGB}{124,166,198}
\definecolor{folderborder}{RGB}{110,144,169}

\def\Size{4pt}
\tikzset{
  folder/.pic={
    \filldraw[draw=folderborder,top color=folderbg!50,bottom color=folderbg]
      (-1.05*\Size,0.2\Size+5pt) rectangle ++(.75*\Size,-0.2\Size-5pt);  
    \filldraw[draw=folderborder,top color=folderbg!50,bottom color=folderbg]
      (-1.15*\Size,-\Size) rectangle (1.15*\Size,\Size);
  }
}
%-------------------------------------------
\begin{document}
\begin{figure}

 \begin{forest}
      for tree={
        font=\ttfamily,
        grow'=0,
        child anchor=west,
        parent anchor=south,
        anchor=west,
        calign=first,
        inner xsep=12pt,
        edge path={
          \noexpand\path [draw, \forestoption{edge}]
          (!u.south west) +(6.5pt,0) |- (.child anchor) pic {folder} \forestoption{edge label};
        },
        % style for your file node 
        file/.style={edge path={\noexpand\path [draw, \forestoption{edge}]
          (!u.south west) +(6.5pt,0) |- (.child anchor) \forestoption{edge label};},
          inner xsep=2pt,font=\small\ttfamily
                     },
        before typesetting nodes={
          if n=1
            {insert before={[,phantom]}}
            {}
        },
        fit=band,
        before computing xy={l=15pt},
      }  
    [Project
    	[Sample
    		[sample.py,file]
    		[sample.java,file]
	]
	[img
		[a.png,file]
		[b.png,file]
	]
    ]
\end{forest}
\centering\caption{プロジェクトの構成}\label{Project}
\end{figure}
\end{document}

f:id:umashika5555:20170913220033p:plain