How can I reference a file path that contains a %? Using the standard escape (\%) does not seem to work. Unfortunately, changing the directory name is not an option. Example:

      \includegraphics{Q:/2014 - 2015/Change (%)/Graphic Name.png}

Thanks in advance.


3 Answers 3


You could try with

\def\x{\def\strangepath{Q:/2014 - 2015/Change (%)}}

in your document preamble and

\includegraphics{\strangepath/Graphic Name.png}

in the document.


Filenames with spaces and percent :(

You could \@percentchar instead of % if @ is a letter at that point, or locally put \catcode`\%=12 before the \includegraphics, to make % a normal character. You need " .. " around the filename as well because of the spaces.


\detokenize{} around the filename worked for me.

Example: \includegraphics{\detokenize{file name including \% sign.png}}.

  • 2
    \detokenize with \% will (under normal circumstances) produce \% and not % Jul 13, 2021 at 15:21
  • Hm, it worked for me, but maybe it really produced \% and LaTeX still finds the correct graphic?
    – clel
    Jul 14, 2021 at 12:31
  • 1
    Sorry, I should have checked. What I said in my first comment is true, but when LaTeX is parsing a filename it is not under those normal circumstances I mentioned: when scanning a file name LaTeX sets \escapechar=-1, so \detokenize{\%} produces %. Your solution indeed works! (but since LaTeX from 2019 or so). P.S.: \includegraphics{file \string\% name.png} also works Jul 14, 2021 at 12:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .