I'm writing a class for LaTeX, and I need to make it general. I want to include a simple image, a logo, within the class, which would be inserted into the document as a simple command \insertCompanyLogo. To avoid extra files, I added the PostScript definition of the logo in the .sty file.
% Include PSTricks package
\usepackage{pstricks}
% Create new command to insert logo
\newcommand{\insertCompanyLogo}{
\psset{xunit=.5pt,yunit=.5pt,runit=.5pt}
\begin{pspicture}(180,180)
\psline(0,0)(180,180) %The actual image is far more complex
\end{pspicture}
}
This works good when I compile the document with latex <filename>. However, it fails when I try to use pdflatex.
In order to use PSTricks with pdflatex, some modifications are required. For example, I can add in the .sty file \usepackage[pdf]{pstricks}.
Then compile the document using pdflatex -shell-escape <filename>. But this won't be general, and it won't work using the regular latex command.
My question is: Is there any way to define a command that understand if the document is being compiled with pdflatex or latex? That way I can add a couple of \ifthenelse{}{}{} to the include line of PSTricks. Thus, the document that uses this .sty class and calls the \insertCompanyLogo could be compiled with both commands without any modification.
I hope I was clear enough. And any solution, tip, recommendation or workaround, as always, is more than welcome.
EDIT: Forgot to mention, I think that packages like xelatex and asymptote that could make this easier. But I would like this to work with a standard TexLive or MiKTeX installation, which is probably what 95% of the users of this class will have installed
EDIT 2: This question was marked as duplicate. The other questions address the engine issue (pdflatex vs. latex). Helpful information. But they leave out the PSTricks part, and how to make its use flexible and multi-engine, and that was the reason of my question.
EDIT 3: At the end, I opted for a completely different solution. What I wanted was to put a logo with a macro that works with both engines, latex and pdflatex. I used TiKz
\documentclass{article}
% Include package TiKz
\includepackage{tikz}
% Create new command to insert logo
\newcommand{\insertCompanyLogo}{
\begin{tikzpicture}
\draw[thick,rounded corners=8pt] (0,0) -- (0,2) -- (1,3.25)
-- (2,2) -- (2,0) -- (0,2) -- (2,2) -- (0,0) -- (2,0);
\end{tikzpicture}
}
\begin{document}
\insertCompanyLogo
\end{document}
The actual logo, and the contents of the tikzpicture environment, I got them from Inkscape, with an extension to export to TiKz format.
\usepackage{ifpdf}for distinguishing between (say) usinglatexvspdflatex. There is also\usepackage{ifplatform}for conditionals based on the OS; and\usepackage{ifxetex}and\usepackage{ifluatex}for when you want to do special things depending on which engine you wish to use (the XeTeX engine and the relatedxelatexcommand are not packages). Betweenifplatform,ifpdf,ifluatex, andifxetex, you're pretty much covered, I think.... – jon May 01 '14 at 03:50@Werner: Sorry for posting the question in the wrong forum. Won't happen again
– phollox May 01 '14 at 04:33