I am trying to get a fa-home icon in a document that I am compiling using pdflatex. I am aware that fa-home works only under XeLaTeX. Is there anyway, I could reproduce this icon using Tikz drawing? Any input will be greatly appreciated.
[Tex/LaTex] fa-home icon using TikZ
tikz-pgf
Related Solutions
You can avoid the issue by selecting the page size to be equal to the picture size. Therefore you don't need preview
and it works fine with XeLaTeX. For this you need to save the picture in a box register. Because geometry
only allows to select the page size in the preamble you need to move the picture there, which is OK as long it inside a savebox (like inside a lrbox
environment).
I'm planning to build a feature like this into standalone
as an alternative to preview
.
\documentclass[a4paper,12pt]{article}
\usepackage{tikz}
\usepackage{geometry}
%\usepackage[active,tightpage]{preview}
%\usepackage[pdftex,active,tightpage]{preview}
%\PreviewEnvironment[]{tikzpicture}
\pagestyle{empty}
\normalfont% required to select normal font already in the preamble
\begin{lrbox}{0}%
\begin{tikzpicture}[line width=1ex]
\draw (0,0) -- (3,1);
\filldraw [fill=red,draw opacity=0.5] (1,0) rectangle (2,1);
\end{tikzpicture}%
\end{lrbox}
\geometry{paperwidth=\wd0,paperheight=\ht0,margin=0cm}
\parindent=0pt
\begin{document}
\usebox{0}%
\end{document}
(The outer dark frame is the background of the PDF viewer)
The upcoming version 1.0 of standalone
includes code similar to this and avoids the need of preview
. It should work fine for XeLaTeX.
Just for fun! [2]
Now with tikz.
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows}
\usetikzlibrary{calc}
\usetikzlibrary{intersections}
\tikzset{
tips/.style = {
triangle 45-triangle 45
, font = \it
}
}
\begin{document}
\begin{tikzpicture}
\pgfmathsetlengthmacro{\a}{5cm}
\pgfmathsetlengthmacro{\b}{8cm}
\pgfmathsetlengthmacro{\billedplan}{\a - \b}
\draw [thick] (-4, 0) -- (4, 0) node [right] {Vannoverflate (linse)};
\draw [thick, name path = bill] (-4, \billedplan) -- (4, \billedplan) node [below right] {Billedplan};
\draw [tips] (-4.5, \billedplan) -- (-4.5, \a) node [midway, left] {b};
\draw [tips] (-3.5, 0) -- (-3.5, \a) node [midway, left] {a};
\draw[red, thick, domain = -2:2] plot [smooth] (\x,{0.3 * sin(\x * pi r)});
\coordinate (ref) at (0.5, \a);
\node [right] at (ref) {Lyskilde};
\coordinate (sin A) at ($(-1.5, 0.3 * sin(-1.5 * pi r)$);
\coordinate (aux A) at ($(ref)!1.1 * \b!(sin A)$);
\coordinate (sin B) at ($(0.5, 0.3 * sin(0.5 * pi r)$);
\path [name path = a] (ref) -- (aux A);
\fill [name intersections = {of= bill and a, by = i}];
\draw [thick] (ref) -- (i);
\draw [thick] (ref) -- (-2, 0) -- (i);
\draw [thick] (ref) -- (-1, 0) -- (i);
\draw [thick] (ref) -- (0.5, \billedplan);
\draw [thick] (ref) -- (0, 0) -- (0.5, \billedplan);
\draw [thick] (ref) -- (1, 0) -- (0.5, \billedplan);
\path (-1, 0) -- (0, 0) node [midway, above] {$\lambda$};
\path (i) -- (0.5, \billedplan) node [midway, above] {$\lambda'$};
\end{tikzpicture}
\end{document}
Best Answer
You cat take the SVG version of Font Awesom copy the code of
ha-home
(unicode: f015) in\fill svg={...};
by scaling (and yshifting) using the information from<font-face units-per-em="1792" ascent="1536" descent="-256" />
. Put all this in a pic and use it like this\tikz\pic{fa-home};
.The only problem is that when you compile you get
! Dimension too large.
. One possible solution is to divide all coordinates by 1792 and then to use them withsimple scale=1em
. Here is the final code :If you want to use the
descent="-256"
information, you can yshift by -256 like this\fill[scale=1em/1792, yscale=-256]
and then use it withbaseline
like this\tikz[baseline]\pic{fa-home};
(if you use the second code, you should replace -256 by -256/1792 = 0.14)