0

I am looking to use find and replace to change my graphic file locations without the need to do each one individually.

So I currently have several

\includegraphics[scale=0.5]{fig1}
\includegraphics[scale=0.85]{fig2}

etc.

Is there a way at which I can find and replace to something like this

*find(\includegraphics[*]{/Chapter/Images/* *

where * is this thing I am trying to ignore and not change. This would result in

    \includegraphics[scale=0.5]{/Chapter/Images/fig1}
    \includegraphics[scale=0.85]{/Chapter/Images/fig2}

If anyone knows of a way I'd greatly appreciate it!

2
  • 1
    Assuming you use texstudio (as you tagged your question), you could do this with regex matches and capture groups. See for example, tex.stackexchange.com/questions/432218/… – David Purton Jul 17 '19 at 14:34
  • 6
    why do you need to do that at all? it is almost always better just to have \includegraphics[scale=0.5]{fig1} you can use \graphicspath{{Chapter/Images/}} so tex looks in the subdirectory. – David Carlisle Jul 17 '19 at 14:54
1

The best answer is the comment from @David Carlisle, but, just to make a regex exercise, in TeXStudio you should search for:

\\includegraphics\[(.*)\]\{(.*)\}

And subtitute with

\includegraphics[\1]{/Chapter/Images/\2}

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.