2

I would like to know whether it is possible to put a frame around an included image (via \includegraphics).

I would like to add a coordinate system to an image.

wirrbel
  • 437

3 Answers3

4
\documentclass{article}
\usepackage{overpic}
\begin{document}

\begin{overpic}[grid, scale=0.5]{tiger.pdf}
\end{overpic}

\end{document}

enter image description here

1

Howdy please take a look at the following code

\documentclass{book}

\usepackage[demo]{graphicx}
\usepackage{tikz}
\begin{document}

%Define grid size type=int
\def\gmin{-2}
\def\gmax{2}

 \begin{tikzpicture}
    % include a graphic with border
    % strip {\color{blue}} its there for a showcase purpose only
    \node[draw, line width=10pt, red, inner sep=0pt, anchor=center] at (0,0) {{\color{blue}\includegraphics[width=100pt, height=100pt]{demo}}};
   % now the manually drawn grid. It uses the  variables from above.
    \foreach \x in {\gmin,...,\gmax} \draw (\x ,\gmin) -- (\x ,\gmax) node[anchor=south] {$\x$};
    \foreach \y in {\gmin,...,\gmax} \draw (\gmin,\y) -- (\gmax,\y) node[anchor=west] {$\y$};


 \end{tikzpicture}

\end{document}

resulting image

This answers both of your questions. Remarks: there are many possible ways to achieve something like that. If you prefer another way please follow the links @Jake gave you.

For putting a frame around something there are many packages around (most of them have "frame" in their name). A defulat method (build into LaTeX2e) is using fbox \fbox{\includegraphics[width=100pt, height=100pt]{demo}} .

bloodworks
  • 10,178
1

Please read the given comments.

Case 1 (using 4 quadrants)

enter image description here

% please "TeXify" it with xelatex because 
% it imports a PDF image which is explicitly specified by .pdf extension.

\documentclass[border=12pt]{standalone}
\usepackage{graphicx}
\usepackage{pstricks}

\def\M{3}% the number of columns
\def\N{3}% the number of rows
\def\filename{example-image-a.pdf}% filename of the imported image
\def\scale{1}% scalling factor


\newsavebox\IBox
\savebox\IBox{\includegraphics[scale=\scale]{\filename}}

\psset
{
    xunit=0.5\dimexpr\wd\IBox/\M\relax,
    yunit=0.5\dimexpr\ht\IBox/\N\relax,
}

\begin{document}
\begin{pspicture}(-\M,-\N)(\M,\N)
    \rput(0,0){\usebox\IBox}
    \psgrid
\end{pspicture}
\end{document}

Case 2 (only using the first quadrant)

enter image description here

% please "TeXify" it with xelatex because 
% it imports a PDF image which is explicitly specified by .pdf extension.

\documentclass[border=12pt]{standalone}
\usepackage{graphicx}
\usepackage{pstricks}

\def\M{3}% the number of columns
\def\N{3}% the number of rows
\def\filename{example-image-a.pdf}% filename of the imported image
\def\scale{1}% scalling factor


\newsavebox\IBox
\savebox\IBox{\includegraphics[scale=\scale]{\filename}}

\psset
{
    xunit=\dimexpr\wd\IBox/\M\relax,
    yunit=\dimexpr\ht\IBox/\N\relax,
}

\begin{document}
\begin{pspicture}(\M,\N)
    \rput[bl](0,0){\usebox\IBox}
    \psgrid
\end{pspicture}
\end{document}