5

I can do

\textcolor{red}{
  \fbox{
    \includegraphics{path}
  }
}

To get a red frame sitting tightly around an image inside a firgure environment. Now, is there a way to also get a red cross over the image?

Kind regards.

9

A TikZ solution that includes the image file inside a tikzpicture and draws a square and cross relative to the coordinates of the image:

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
    \node[inner sep=0] (image) at (0,0) {\includegraphics[width=0.5\textwidth]{example-image}};
    \draw[red,ultra thick] (image.south east) -- (image.north west);
    \draw[red,ultra thick] (image.north east) -- (image.south west);
    \draw[red,ultra thick] (image.south west) rectangle (image.north east);
\end{tikzpicture}
\end{document}

enter image description here

  • My compliments for your answer. I have deleted my previous comment for the OP. – Sebastiano Apr 25 at 11:48
  • 1
    Even shorter: \draw[red,ultra thick] (image.south west) rectangle (image.north east); \draw[red,ultra thick] (image.south east) -- (image.north west); \draw[red,ultra thick] (image.north east) -- (image.south west); ;-) – AndiW Apr 25 at 12:03
  • @AndiW Better indeed :) I've edited my answer. – Marijn Apr 25 at 12:06
  • 1
    Thanks to all of you. When changing the answer, you forgot one of the diagonals in the cross. You might want to fix that. Personally I also liked it better without ultra thick (then it's also more similar to \fbox) but I guess that's a matter of taste. – sigvaldm Apr 25 at 12:32
6

as supplement to @Marjin answer (+1), a little bit shorter code ...

\documentclass{article}
\usepackage{tikz}
\begin{document}
    \begin{tikzpicture}
\node  (image) [inner sep=0] {\includegraphics[width=0.5\textwidth]{example-image}};
\draw[red,ultra thick]  (image.south west) -- (image.north east)
                        (image.north west) -- (image.south east)
                        (image.south west) rectangle (image.north east);
    \end{tikzpicture}

the result is similar:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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