The pgf/TikZ manual suggests using the command \pgftext
to insert external graphics (section 53.3.3 "Inserting Text and Images"). Here's an example taken from this seminar (slides 5 and 6 in the presentation version):
\begin{figure}
\begin{tikzpicture}
\pgftext{%
\includegraphics[width=\textwidth]{Bridge05a}%
}%
\node[fill=black, opacity=.5, text opacity=1] at (0,.5) {\Large \color{yellow} Geometry};
\node[fill=black, opacity=.5, text opacity=1] at (0,-.5) {\Large \color{red} \emph{Manifolds}};
\node[fill=black, opacity=.5, text opacity=1] at (-4,.5) {\Large \color{yellow} Algebra};
\node[fill=black, opacity=.5, text opacity=1] at (4,.5) {\Large \color{yellow} Analysis};
\end{tikzpicture}
\end{figure}
There is also a hint elsewhere in the manual (in 53.3.1) that the command \pgfimage
can be used instead of \includegraphics
(although still within the \pgftext
command); however, searching for \pgfimage
in the manual doesn't turn up any further explanation of this command.
The \pgftext
command is something of a special command. It "escapes" out of the current picture back to "normal TeX". It is, therefore, somewhat like a \node
command. It works by constructing a box which is then put into the picture. By default this box is put at the current origin. A simple way to move it, therefore, is to (temporarily) tell TikZ/PGF to move the origin priori to issuing the \pgftext
command.
An alternative way of positioning it is to use the initial optional argument. Thus one can say \pgftext[<positioning information>]{text}
where <positioning information>
is some set of PGF keys that relocate the box. These are similar to the positioning of a \node
, but have a slightly "low level" feel to them. For example, to locate the box at a particular point one would say \pgftext[at={\pgfpoint{1cm}{2cm}}]{text}
. Note the \pgfpoint
syntax rather than the TikZ coordinate syntax.
In the 2.10-CVS version of the manual, the \pgftext
command is documented in Section 77.3.3. There is also some important information about how it interacts with scopes in Section 77.1.2 (note especially item 5 about the ability to put another pgfpicture
inside a \pgftext
command, something that should never be done with \node
!).
In summary, \pgftext
is somewhat akin to \node
in that it allows you to put "normal TeX" in your picture. However, the two are different in that a \node
is considered part of the picture but \pgftext
is for things that are meant to be somewhat separate.
Here's an example using the tocstyle
package which is part of KOMA-script
. (You may replace \rule
with \includegraphics
from the graphicx
package.) Graphics for the "section" ToC entries may be changed using \setsectiongraphics
.
\documentclass{article}
\DeclareRobustCommand{\sectiongraphics}{}
\newcommand*{\setsectiongraphics}[1]{%
\addtocontents{toc}{\protect\renewcommand{\sectiongraphics}{\protect #1}}%
}
\usepackage{tocstyle}
\usetocstyle{standard}
\settocstylefeature{entryhook}{\rule{0.15cm}{0.15cm}\hspace{0.15cm}}% for all ToC levels
\settocstylefeature[1]{entryhook}
{\sectiongraphics\hspace{0.3cm}\bfseries}% "[1]" for sections
\begin{document}
\setsectiongraphics{\rule{0.3cm}{0.3cm}}
\tableofcontents
\section{bla}
\setsectiongraphics{\rule{0.5cm}{0.5cm}}
\section{blubb}
\subsection{foo}
\subsubsection{bar}
\end{document}
Best Answer
What I typically do is to create a folder, say
figures
, to organize all images. The folder hierarchy would be:Then add the command
\graphicspath{./figures/}
in the preamble of the document to point to the folder.Using the package
epstopdf
allows us to incorporate.eps
figures.A MWE followed by the output is below: