I have a small problem with a .sty file i'm creating.

I want to have the option to add a logo in the title, which was not problem.

But if I now have a situation where I don't add a logo (either by leaving the input empty or by not heaving the command in the main file) I create a ! Latex error: File `' not found.

The document is still created and looks fine.

Since I want to give the sty. to others I would still like to avoid the appearance of this error...

Here the code snippets i used so far:

%create a placeholder for a logo
\newcommand* {\@titlelogo}{}

And my (unsuccessful) try of avoiding the error:

\ifdefined \titlelogo {\includegraphics[height=1.5cm]{\@titlelogo} }
\else \fi

Maybe there is an elegant solution for optional parameters in for example title pages that I'm simply not aware of.

Thanks a lot and cheers Claudia


You can use the built in boolean checks and create \iftitlelogo that is false from the beginning. When you set the logo you turn it to true. (There are more fancy ways to do boolean checks but I think this works here).

\titlelogofalse% default no logo picture
    \includegraphics[width=1.5cm]{\@titlelogo} #1
\mytitle{Test without logo}

\mytitle{Test with logo}


enter image description here


Thanks a lot!

I meanwhile found a rather elegant workaround (to my taste), which just checks if the length of the String is larger 0

\stringlength[q]{\@titlepic}% Result is stored in \theresult

\else \fi

This requires the package:


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.