Are there file and folder/directory symbols in LaTeX?
Something like:

Font Awesome contains symbols for file and folder. However it needs XeTeX or LuaTeX, example:
\documentclass{article}
\usepackage{fontspec}
\usepackage{fontawesome}
\begin{document}
File: \faFile\ \faFileAlt\par
Folder: \faFolderOpen\ \faFolderClose\ \faFolderOpenAlt\ \faFolderCloseAlt
\end{document}
The symbol can be put in a stand-alone file. Then LuaTeX/XeTeX generates a PDF file that is then included as graphics, e.g.:
% FileAlt.tex
% lualatex/xelatex
\documentclass{standalone}
\usepackage{fontawesome}
\begin{document}%
\faFileAlt
\end{document}
Then the file FileAlt.pdf is generated:
lualatex FileAlt
and the result FileAlt.pdf can be included with pdflatex:
\documentclass{article}
\usepackage{graphics}
\begin{document}
\includegraphics{FileAlt}
\end{document}
Also an EPS file can be generated, e.g.:
pdftoeps -eps FileAlt.pdf
However, the bounding box is not too precise, it can be improved. Also I got some problems, if the included file is converted to PDF again, therefore I added a third step with purifyeps that converts the EPS to a simpler PostScript without font dependency:
pdftops -eps FileAlt.pdf temp1.eps
epstool --copy --bbox --output temp2.eps temp1.eps
purifyeps temp2.eps FileAlt.eps
Then it can be included with latex/dvips:
\includegraphics[hiresbb]{FileAlt}
fontawesome package now doesn't need the fontspec and works with PdfTeX / PdfLaTeX. Note that it is \faFileO, not \faFileAlt.
– Jakub Narębski
Dec 01 '15 at 12:08
You can include any graphic file with pdflatex. Just use XeLaTeX to prepare them.
For instance, save the following file as FolderOpen.tex:
\documentclass{standalone}
\usepackage{fontawesome}
\begin{document}
\fontsize{24}{0}\selectfont
\faFolderOpen
\end{document}
Compile it with XeLaTeX and use the PDF file like shown below:
\documentclass{article}
\usepackage{graphicx}
\newcommand{\FolderOpen}[1][.8\ht\strutbox]{%
\includegraphics[height=#1]{FolderOpen}%
}
\begin{document}
\begin{itemize}
\item[\FolderOpen] This is an open folder
\item This isn't
\end{itemize}
Also a big open folder: \FolderOpen[1cm].
\end{document}

fontawesome package now doesn't need the fontspec and works with PdfTeX / PdfLaTeX
– Jakub Narębski
Dec 01 '15 at 12:05
With tikz. Find a .svg file, open it in inkscape, and export as tikz code using inkscape2tikz.
\documentclass[tikz,border=5pt]{standalone}
\begin{document}
\definecolor{cc4a000}{RGB}{196,160,0}
\definecolor{ceeeeec}{RGB}{238,238,236}
\definecolor{c204a87}{RGB}{32,74,135}
\definecolor{cedd400}{RGB}{237,212,0}
\begin{tikzpicture}[y=0.80pt, x=0.8pt,yscale=-1, inner sep=0pt, outer sep=0pt]
\begin{scope}[shift={(-20.42857,-28.63543)}]
\path[draw=black,fill=cc4a000,line join=round,line cap=round,miter
limit=4.00,dash phase=15.792pt,line width=1.600pt,rounded corners=0.0000cm]
(21.4286,186.6479) rectangle (708.5715,643.7908);
\begin{scope}[cm={{0.58178,-0.81335,0.81335,0.58178,(165.90533,-14.59901)}}]
\path[cm={{-0.00202,1.0,-1.0,-0.00202,(0.0,0.0)}},draw=black,fill=ceeeeec,line
join=round,line cap=round,miter limit=4.00,dash phase=15.792pt,line
width=1.600pt,rounded corners=0.0000cm] (99.7727,-17.2073) rectangle
(641.2012,342.8532);
\begin{scope}[cm={{1.0,0.0,0.0,0.52631,(-1.66834,57.53025)}}]
\path[draw=c204a87,line join=miter,line cap=butt,line width=1.103pt]
(-317.9725,156.1510) -- (-5.8354,156.1510);
\path[draw=c204a87,line join=miter,line cap=butt,line width=1.103pt]
(-317.9725,121.9502) -- (-5.8354,121.9502);
\path[draw=c204a87,line join=miter,line cap=butt,line width=1.103pt]
(-317.9725,190.3519) -- (-5.8354,190.3519);
\path[draw=c204a87,line join=miter,line cap=butt,line width=1.103pt]
(-317.9725,224.5528) -- (-5.8354,224.5528);
\path[draw=c204a87,line join=miter,line cap=butt,line width=1.103pt]
(-317.9725,258.7537) -- (-5.8354,258.7537);
\path[draw=c204a87,line join=miter,line cap=butt,line width=1.103pt]
(-317.9725,327.1554) -- (-5.8354,327.1554);
\path[draw=c204a87,line join=miter,line cap=butt,line width=1.103pt]
(-317.9725,361.3563) -- (-5.8354,361.3563);
\path[draw=c204a87,line join=miter,line cap=butt,line width=1.103pt]
(-317.9725,395.5572) -- (-5.8354,395.5572);
\path[draw=c204a87,line join=miter,line cap=butt,line width=1.103pt]
(-317.9725,429.7581) -- (-5.8354,429.7581);
\path[draw=c204a87,line join=miter,line cap=butt,line width=1.103pt]
(-317.9725,463.9590) -- (-5.8354,463.9590);
\path[draw=c204a87,line join=miter,line cap=butt,line width=1.103pt]
(-317.9725,498.1598) -- (-5.8354,498.1598);
\path[draw=c204a87,line join=miter,line cap=butt,line width=1.103pt]
(-317.9725,532.3607) -- (-5.8354,532.3607);
\path[draw=c204a87,line join=miter,line cap=butt,line width=1.103pt]
(-317.9725,566.5616) -- (-5.8354,566.5616);
\path[draw=c204a87,line join=miter,line cap=butt,line width=1.103pt]
(-317.9725,600.7625) -- (-5.8354,600.7625);
\path[draw=c204a87,line join=miter,line cap=butt,line width=1.103pt]
(-317.9725,292.9545) -- (-5.8354,292.9545);
\end{scope}
\end{scope}
\path[draw=black,fill=cedd400,line join=round,line cap=round,miter
limit=4.00,dash phase=15.792pt,line width=1.600pt] (178.1531,232.3622) --
(795.0523,232.3622) .. controls (814.5098,232.3622) and (825.9769,246.5090) ..
(820.7633,264.0816) -- (717.0939,613.5000) .. controls (711.8803,631.0725) and
(692.0187,645.2193) .. (672.5613,645.2193) -- (55.6620,645.2193) .. controls
(36.2045,645.2193) and (24.7374,631.0725) .. (29.9510,613.5000) --
(133.6204,264.0816) .. controls (138.8340,246.5090) and (158.6956,232.3622) ..
(178.1530,232.3622) -- cycle;
\end{scope}
\end{tikzpicture}
\end{document}

Do the same for file icon or simply draw it:
\documentclass[tikz,border=5pt]{standalone}
\begin{document}
\begin{tikzpicture}
\draw (0,0) -- (0,1.2) -- (0.7,1.2) -- (0.7,0.8) -- (1,0.8) -- (1,0) -- cycle;
\draw (0.7,1.2) -- (1,0.8);
\foreach \y in {0.2,0.4,0.6}{
\draw (0.2,\y) -- (0.8,\y);
\draw (0.2,0.8) -- (0.6,0.8);
\draw (0.2,1) -- (0.6,1);
}
\end{tikzpicture}
\end{document}

If you want to have a node shape (in PGF/TikZ) that looks like a file or a folder symbol, you can use the following code (which can also be found, with two more shapes, in this example Overleaf project).
\documentclass[tikz]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}
\makeatletter
% based on
% https://raw.githubusercontent.com/Jubobs/gitdags/master/gitdags.sty
% custom shape, adapted from 102.5.3 in the TikZ 3.0 manual
\pgfkeys{/tikz/.cd,
dogear size/.initial=5pt,
}
\pgfdeclareshape{dogeared}{ % or 'document', or 'file'
% this is nearly a rectangle
\inheritsavedanchors[from=rectangle]
\inheritanchorborder[from=rectangle]
\inheritanchor[from=rectangle]{center}
\inheritanchor[from=rectangle]{north}
\inheritanchor[from=rectangle]{south}
\inheritanchor[from=rectangle]{west}
\inheritanchor[from=rectangle]{east}
\savedmacro\dogearsize{%
\edef\dogearsize{\pgfkeysvalueof{/tikz/dogear size}}%
}
\backgroundpath{% this is new
% store lower left in xa/ya and upper right in xb/yb
\southwest \pgf@xa=\pgf@x \pgf@ya=\pgf@y
\northeast \pgf@xb=\pgf@x \pgf@yb=\pgf@y
% compute corner of ‘‘flipped page’’ (‘‘dog ear’’)
\pgf@xc=\pgf@xb \advance\pgf@xc by-\dogearsize
\pgf@yc=\pgf@yb \advance\pgf@yc by-\dogearsize
% construct main path
\pgfpathmoveto{\pgfpoint{\pgf@xa}{\pgf@ya}}
\pgfpathlineto{\pgfpoint{\pgf@xa}{\pgf@yb}}
\pgfpathlineto{\pgfpoint{\pgf@xc}{\pgf@yb}}
\pgfpathlineto{\pgfpoint{\pgf@xb}{\pgf@yc}}
\pgfpathlineto{\pgfpoint{\pgf@xb}{\pgf@ya}}
\pgfpathclose
}
\foregroundpath{% this is new
% store lower left in xa/ya and upper right in xb/yb
\southwest \pgf@xa=\pgf@x \pgf@ya=\pgf@y
\northeast \pgf@xb=\pgf@x \pgf@yb=\pgf@y
% compute corner of ‘‘flipped page’’ (‘‘dog ear’’)
\pgf@xc=\pgf@xb \advance\pgf@xc by-\dogearsize
\pgf@yc=\pgf@yb \advance\pgf@yc by-\dogearsize
% construct main path
%%
% add little corner
\pgfpathmoveto{\pgfpoint{\pgf@xc}{\pgf@yb}}
\pgfpathlineto{\pgfpoint{\pgf@xc}{\pgf@yc}}
\pgfpathlineto{\pgfpoint{\pgf@xb}{\pgf@yc}}
\pgfpathclose
}
}
%% based on code in
%% https://github.com/GuITeX/guidatikzmark/blob/master/pacchetti_comandi/documento.tex
\pgfkeys{/tikz/.cd,
tab height/.initial=3pt,
tab width/.initial=10pt,
tab slope/.initial=1.5pt,
cover xoff/.initial=5pt,
cover yoff/.initial=2pt,
}
%% Note: use '\setlength{\pgf@xd}{\pgf@xb}' rather than '\pgf@xd=\pgf@xb'
%% ??? for some reason \pgf@ytt etc. didn't work, but \pgf@yd does
\newlength\pgf@yd
\newlength\pgf@xe
\newlength\pgf@xf
\newlength\pgf@xg
\newlength\pgf@yg
\newlength\pgf@xh
%% this didn't work
\newlength\pgf@xo %% note: \pgf@xx is pre-defined by pgf to mean something
%% from 95.2 Communicating with the Basic Layer via Macros
% \newdimen\pgf@xta \newdimen\pgf@xtb \newdimen\pgf@ytt
% \newdimen\pgf@xoa \newdimen\pgf@xob \newdimen\pgf@yoo
\pgfdeclareshape{folder open}{ % or 'directory'
%% this is nearly a rectangle
\inheritsavedanchors[from=rectangle]
\inheritanchorborder[from=rectangle]
\inheritanchor[from=rectangle]{center}
\inheritanchor[from=rectangle]{north}
\inheritanchor[from=rectangle]{south}
\savedmacro\tabheight{%
\edef\tabheight{\pgfkeysvalueof{/tikz/tab height}}%
}
\savedmacro\tabwidth{%
\edef\tabwidth{\pgfkeysvalueof{/tikz/tab width}}%
}
\savedmacro\tabslope{%
\edef\tabslope{\pgfkeysvalueof{/tikz/tab slope}}%
}
\savedmacro\coverxoff{%
\edef\coverxoff{\pgfkeysvalueof{/tikz/cover xoff}}%
}
\savedmacro\coveryoff{%
\edef\coveryoff{\pgfkeysvalueof{/tikz/cover yoff}}%
}
%% this didn't work; probably needs \pgf@process somewhere...
% \setlength{\pgf@xo}{\coverxoff}
% \setlength{\pgf@xo}{0.5\pgf@xo}
%% this didn't work either
% \setlength{\pgf@xo}{2pt}
% \advance\pgf@xo by \coverxoff\relax
%% this didn't work either
% \pgf@xx=0pt
% \advance\pgf@xx by \coverxoff\relax
% \pgf@xx=0.5\pgf@xx
%% fallback, so this at least compile
%% but moves text, because \pgf@xx is sed for node contents positioning
% \pgf@xx=2pt % this should be 0.5 of \coverxoff
% \inheritanchor[from=rectangle]{west}
\anchor{west}{
\pgf@process{\northeast}%
\pgf@ya=.5\pgf@y%
\pgf@process{\southwest}%
\pgf@y=.5\pgf@y%
\advance\pgf@y by \pgf@ya%
\advance\pgf@x by -2pt%
}
% \inheritanchor[from=rectangle]{east}
\anchor{east}{%
\pgf@process{\southwest}%
\pgf@ya=.5\pgf@y%
\pgf@process{\northeast}%
\pgf@y=.5\pgf@y%
\advance\pgf@y by \pgf@ya%
\advance\pgf@x by 2pt%
}
\backgroundpath{% this is new
%% store lower left in xa/ya and upper right in xb/yb
\southwest \pgf@xa=\pgf@x \pgf@ya=\pgf@y
\northeast \pgf@xb=\pgf@x \pgf@yb=\pgf@y
%% correction due to open front cover
\advance\pgf@xa by -2pt
\advance\pgf@xb by -2pt
%%
%% compute edges of the "divider tab" in the back cover
%%
\setlength{\pgf@yd}{\pgf@yb}
\advance\pgf@yd by \tabheight
\setlength{\pgf@xe}{\pgf@xa}
\advance\pgf@xe by \tabwidth % or make it dependent on box width
\setlength{\pgf@xf}{\pgf@xe}
\advance\pgf@xf by \tabslope % or make it dependent on divider height
%%
%% compute edges of second cover of a folder ("open" cover)
%%
\setlength{\pgf@xg}{\pgf@xa}
\advance\pgf@xg by \coverxoff % perhaps as an angle of open
\setlength{\pgf@xh}{\pgf@xb}
\advance\pgf@xh by \coverxoff
\setlength{\pgf@yg}{\pgf@yb}
\advance\pgf@yg by-\coveryoff % perhaps as an angle of open
%%
%% construct main path
\pgfpathmoveto{\pgfpoint{\pgf@xa}{\pgf@ya}}
\pgfpathlineto{\pgfpoint{\pgf@xa}{\pgf@yd}}
\pgfpathlineto{\pgfpoint{\pgf@xe}{\pgf@yd}}
\pgfpathlineto{\pgfpoint{\pgf@xf}{\pgf@yb}}
\pgfpathlineto{\pgfpoint{\pgf@xb}{\pgf@yb}}
\pgfpathlineto{\pgfpoint{\pgf@xb}{\pgf@yg}} % break for open cover
\pgfpathmoveto{\pgfpoint{\pgf@xb}{\pgf@ya}}
% \pfgpathlineto{\pgfpoint{\pgf@xa}{\pgf@ya}} % ??? causes error ???
\pgfpathclose
%% construct secondary path
\pgfpathmoveto{\pgfpoint{\pgf@xa}{\pgf@ya}}
\pgfpathlineto{\pgfpoint{\pgf@xg}{\pgf@yg}}
\pgfpathlineto{\pgfpoint{\pgf@xh}{\pgf@yg}}
\pgfpathlineto{\pgfpoint{\pgf@xb}{\pgf@ya}}
\pgfpathclose
}
}
\makeatother
\begin{document}
\begin{tikzpicture}[thick,draw]
\node [dogeared,fill=red!20,draw=red!20!black]
at (0, 0.0) { dogeareds };
\node [folder open,fill=orange!20,draw=orange!20!black]
at (0,-0.8) { folder open };
\end{tikzpicture}
\end{document}
This solution was cribbed from other sources (dogeared shape was taken from the GitDAGs project with some changes, and handling of parameters was based on code in guidatikzmark project (Italian TUG: GuIT). It is by no means complete solution, in particular handling connecting nodes doesn't work completely correctly.
As you can see there isn't any correction for the text box...
The result looks like this:
Folder_open_alt_font_awesome.svg. There are more icons in the same directory.convert Folder_open_alt_font_awesome.svg FolderOpen.pdfAs egreg explained:
\documentclass{article}
\usepackage{graphicx}
\newcommand{\FolderOpen}[1][.8\ht\strutbox]{%
\includegraphics[height=#1]{FolderOpen}%
}
\begin{document}
\begin{itemize}
\item[\FolderOpen] This is an open folder
\item This isn't
\end{itemize}
Also a big open folder: \FolderOpen[1cm].
\end{document}
\includegraphicsis your friend: it can be used anywhere. – egreg May 01 '14 at 12:20\includegraphics, if you can't use XeLaTeX or LuaLaTeX. – egreg May 01 '14 at 12:34\includegraphicsused insidetikzpicture? – alper May 27 '23 at 19:15