1

I have a document with a graphics and I want to replaced this graphics with another as part of a revision. To make this clear I want to show the old version of a figure next (or below) to the new version, but struck out.

I tried using the changes package (\deleted around the \includegraphics command) which gives an error and also with the sout package, which gives a weird result.

How can strike out a graphics reliable in LaTeX?

\documentclass{article}
\usepackage{graphics}
\begin{document}
\begin{figure}
   \includegraphics{old} \\ %strike this figure out, with a diagonal, horizontal or cross lines
   \includegraphics{new}
   \caption{description}
\end{figure}
\end{document}
alfC
  • 14,350

2 Answers2

2

You can modify the selected answer to this question to get what you've asked:

\documentclass{article}
\usepackage{graphicx}
\usepackage[many]{tcolorbox}
\newtcolorbox{cross}{blank,breakable,parbox=false,
  overlay={\draw[red,line width=5pt] (interior.south west)--(interior.north east);
    \draw[red,line width=5pt] (interior.north west)--(interior.south east);}}
\begin{document}
\begin{cross}
\begin{center}
\includegraphics[width=2in]{P1.pdf}
\end{center}
\end{cross}

\begin{figure}[h!]
\begin{center}
\includegraphics[width=2in]{P2.pdf}
\end{center}
\caption{Use the correct diagram!}
\end{figure}
\end{document}

The output in Gummi looks like this: enter image description here

DJP
  • 12,451
  • Thank you. 1) this deserves to be somehow used by one of the strike out packages. 2) changes could fall back to this when other types of strike out don't work (see comment in https://tex.stackexchange.com/a/135334/1871) – alfC Dec 08 '18 at 03:41
  • 3
    When I copy and paste this code, adjust the image file names, and run it, the cross appears behind the image -- what am I doing wrong? – NCH32 Feb 04 '19 at 10:21
  • This worked, though (you may have to adjust the location of the corners to the size of your image, or vice versa):

    \documentclass{article} \usepackage{graphicx,tikz} \begin{document} \begin{tikzpicture} \node(mypic){\includegraphics[width=2in]{image}}; \node[above left of = mypic](corner1){}; \node[above right of = mypic](corner2){}; \node[below left of = mypic](corner3){}; \node[below right of = mypic](corner4){}; \draw[red, thick](corner1)--(corner4); \draw[red, thick](corner2)--(corner3); \end{tikzpicture} \end{document}

    – NCH32 Feb 04 '19 at 10:55
  • Yes, the cross appears behind the image. I don't know how to get in on top of the image, but the approach does avoid the hassle of adjusting the location of the corners. – DJP Feb 04 '19 at 14:41
  • 1
    Thanks to @NCH32 , I got to find a way to locate the cross in front of the image as well as automatically fit the cross to the size of your image! https://tex.stackexchange.com/q/487546/185010 – user3415167 Dec 27 '21 at 07:05
2

Here is my solution, adapted from an answer over here

\documentclass{article}
\usepackage{graphicx}
\usepackage{tikz}

\begin{document}    
    \begin{tikzpicture}
        \node[anchor=south west,inner sep=0] (image) at (0,0) {
            \includegraphics{my_figure.png}
        };
        \begin{scope}[x={(image.south east)},y={(image.north west)}]
            \draw[red,line width=1 mm] (0, 1)--(1, 0);
            \draw[red,line width=1 mm] (0, 0)--(1, 1);
        \end{scope}
    \end{tikzpicture}
\end{document}