Discovery of an output device in LaTeX

Is there any way in the LaTeX style / class file to determine which output device is being used (or at least what features it has)? The reason is because I am writing a class file in which I want to use some PostScript-specific packages (for example pstricks) if Postscript is available, but if I just write

\RequirePackage{pstricks}

then, of course, bad things happen if I compile a document with pdflatex. Therefore, ideally, I am looking for something that I can use, for example

\if@postscriptokay\RequirePackage{pstricks}\fi

It seems that this should be possible because I know that packages like pgfcan change their behavior to use the appropriate graphic commands based on the output device, but I did some Google searches and checked in my LaTeX book and in the harbors , t found a way.

+5
source share
4 answers
\usepackage{ifpdf}

\ifpdf
  % nothing
\else
  \RequirePackage{pstricks}
\fi
+7
source

You can detect pdfTeX like this (this is what it does ifpdf.sty):

\makeatletter
\ifx\pdfoutput\@undefined
  no pdfTeX
\else\ifnum\pdfoutput<1
  pdfTeX is outputting a .dvi file
\else
  pdfTeX is outputting a .pdf file
\fi\fi

graphicx.sty, hyperref.sty pgf.sty . (, pdftex.def hpdftex.def) . .tex , , . :

/usr/share/texmf/tex/generic/pgf/systemlayer/pgfsys-*.def
/usr/share/texmf-texlive/tex/latex/hyperref/hpdftex.def
/usr/share/texmf-texlive/tex/latex/graphics/*.def
  /usr/share/texmf-texlive/tex/latex/pdftex-def/pdftex.def

pgf.sty graphicx.sty \Gin@driver. .

+6

pstool auto-pst-pdf. pstricks pdfLaTeX.

+3

KOMA-Script ( , ) : \ifpdfoutput{pdf output}{dvi output} . , ifpdf, .

+1

All Articles