I am using TexLive and TexStudio as a compiler. I created a custom class in order to produce tests. In that class file there is an option for the color output so I can choose for example to use blue color if I want to upload the test in the internet and black if I want to print it.

As we can see in the following test.cls class file the ifthen package is loaded and reads the option I want to give. If the option inside the documentclass is internet then the main color of the document is red and if I use the option print then the color is set to black.


\ProvidesClass{test}[29/7/2019 Test]
\RequirePackage[left=2.00cm, right=2.00cm, top=2.00cm, bottom=3.00cm]{geometry}


{\bf {\Large Test}}

\section*{{\huge \textcolor{\Col}{#2}}}
{\large\bf{\MakeUppercase{Test type: #3}}}

At the top of the document an image is supposed to be loaded, which is red when the internet option is on and black for the print option. These images are located in the following directory C:\texlive\texmf-local\tex\latex\local\test named Test.eps and Test1.eps respectively. The ifthen command reads the documentclass option and imports the red Test.eps file for the internet or the black Test1.eps for printing, using the \image command.

That's where the error show up. I get the error File C:/texlive/texmf-local/tex/latex/local/test/Test.eps' not found. \titleStart{Mathematics}{Algebra}{X}

Before I switch to Texlive I used MikTex and the class was working fine producing the desired output. Now the only way to avoid the error is to specify the exact name of the file I want to use inside the \includegraphics command inplace of \image

I quote the MWE and the the two different type of exams I want to use.

\setmainfont[Mapping=tex-text,Numbers=Lining,Scale=1.0,BoldFont={Times New Roman Bold}]{Times New Roman}


enter image description here

enter image description here

  • 1
    \bf has been deprecated since 1993. Why figure? There's nothing that imposes \includegraphics to appear in a figure environment, which is actually wrong in the context you're in, because it defines a floating object, while you want the picture exactly there. Finally, xunicode is no longer recommended with fontspec.
    – egreg
    Jul 29 '19 at 15:23
  • @egreg That's true. I used an old code which needs improvements.Either way the errors shows up even without these commands.
    – mac
    Jul 29 '19 at 15:27
  • Oh, I forgot that titlesec and sectsty don't go along. About the problem with the path: are you sure you need it?
    – egreg
    Jul 29 '19 at 15:31
  • Why is that? In thw specific folder I have an image I use for my tests. How can I include it in all my documents without the path?Is there another way?
    – mac
    Jul 29 '19 at 15:35
  • Things below texmf-local/tex are automatically found, with a well set up TeX Live.
    – egreg
    Jul 29 '19 at 15:38

As explained in How to use a command as path in 'includegraphics'? the \includegraphics command has problems parsing file names that consist of multiple elements. The solution is also given in that post, although a bit hidden. The idea is to compose a fully expanded path+filename string and use that as argument.


\edef\imagepath{/path/to/your/file/\image} % note the \edef, i.e., expanded def

Alternatively, as noted in https://tex.stackexchange.com/a/493974/, using the grffile package also works.



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.