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}
1

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

| improve this answer | |
  • 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 tex.stackexchange.com/a/135334/1871) – alfC Dec 8 '18 at 3:41
  • 1
    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 4 '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 4 '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 4 '19 at 14:41
1

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}
| improve this answer | |

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.