Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Are there file and folder/directory symbols in LaTeX?

Something like:

file and folder symbols

share|improve this question
    
\includegraphics is your friend: it can be used anywhere. –  egreg May 1 at 12:20
    
@egreg, I don't want to include the above shown graphics, it's just a quick example. I am looking for a symbol like in Heiko Oberdiek's answer. –  sergej May 1 at 12:32
    
Make a PNG or PDF from it and use \includegraphics, if you can't use XeLaTeX or LuaLaTeX. –  egreg May 1 at 12:34

3 Answers 3

up vote 12 down vote accepted

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}

enter image description here

share|improve this answer

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}

Result

Without LuaTeX/XeTeX

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}
share|improve this answer
    
Very nice! However I can't use XeLaTeX or LuaLaTeX. –  sergej May 1 at 12:46

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}

enter image description here

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}

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.