TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I used the OzTeX implementation of TeX, also I used to typeset my docs in plain TeX, not LaTeX for me, so I had no problem to insert an image using the OzTeX, now I'm back to TeX docs, am using the TeXWorks frontend, but I can't insert an .eps image file, it seems the \includegraphics macro its only for LaTeX, so I can't use it, any idea on how to insert an image when using plain TeX?

share|improve this question

By far the easiest approach here is to use miniltx to allow you to use LaTeX's graphics package with plain TeX:

\input miniltx %
\input graphicx.sty %


\input graphicx.tex %

(See comments for the minor differences here.)

The only thing you will need to watch is that TeXworks is designed around a PDF-based workflow. Thus you will need to convert your .eps files to .pdf format using epstopdf and then use pdfTeX in TeXworks. (In LaTeX, there is now automatic conversion method from .eps to .pdf files, but this does not apply to plain TeX.)

share|improve this answer
Is there a difference between this and simply \input graphicx.tex (no miniltx)? – Alan Munn Jul 18 '12 at 18:27
@AlanMunn I've simply gone with 'what I know'. A quick look at graphicx.tex shows it loads miniltx, adds a default driver line (dvips) and tidies up the catcode of @ using \resetatcatcode. The last point might make it very slightly preferable, but it's not a bit difference. – Joseph Wright Jul 18 '12 at 18:32
@JosephWright Also the automatic conversion from EPS to PDF for pdfTeX will work, if package epstopdf-base is loaded after graphicx: \input miniltx \def\Gin@driver{pdftex.def} \input graphicx.sty \input epstopdf-base \resetatcatcode – Heiko Oberdiek Dec 25 '14 at 16:36

You can use the simple epsf package which is designed for plain TeX:

\input epsf
%optional \epsfxsize=dimen or \epsfysize=dimen
share|improve this answer

For pdftex users the \pdfximage approach might seem appealing. The \pdfximage command creates an image object. The dimensions can be controlled in a similar way to a rule, i.e.

\pdfximage width ... height ... depth ... <general text>

where <general text> is the file name. (\pdfximage has many more parameters which can be looked up in the pdftex manual. For advanced things such as adjusting the bounding box also consult the manual.)

Still, \pdfximage only creates an object but does not insert anything yet. Therefore \pdfrefximage has to be used. The command

\pdfrefximage <integer>

places a whatsit including the image stored in the object referred to by <integer> in the output at shipout. In principle one could output the number corresponding to each image object, write them down and then later do, e.g. \pdfrefximage3. This is tedious and error prone, though. That's why there is \pdflastximage which is a count register always containing the number of the last \pdfximage, so including an image can be boiled down the following code

\pdfximage width 3cm {example-image-a.pdf}

TL;DR: See the code right above this line

share|improve this answer

The \inspic macro is provided by opmac.tex. You can set \picwidth register or \picheight register (or both, but the aspect is probably deformed in such case) and you can type \inspic file.jpg or \inspic file.pdf etc.

\input opmac

\picwidth=3cm \inspic file.png

You can look into opmac.tex to get the ispiration how this macro is defined at primitive level:

\def\inspic #1 {\hbox{%
    \pdfximage \ifdim\picwidth=0pt \else width\picwidth\fi 
               \ifdim\picheight=0pt \else height\picheight\fi {\picdir#1}%

This works in pdfTeX. When XeTeX is used then the additional opmac-xetex.tex macro file is loaded and the \inspic macro is redefined:

\def\inspic #1 {\hbox{\def\tmp##1.pdf##2\relax{%
   \ifnum\strcmp{##2}{.pdf}=0 \XeTeXpdffile \else \XeTeXpicfile \fi}%
   \lowercase{\tmp #1}.pdf\relax \picdir#1
       \ifdim\picwidth=0pt \else width\picwidth\fi
       \ifdim\picheight=0pt \else height\picheight\fi}}

The main complication of this code is the fact that XeTeX needs to use different primitive for PDF including (\XeTeXpdffile) and different for another bitmap images (\XeTeXpicfile`).

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.