2

An earlier post How to handle figures and images using MikTeX Plain TeX (not LaTeX) on a 35 year old document (that I am not allowed to comment on) suggested this simple solution. (I also am working on converting a thesis from the 1980s.)

\pdfximage width .25\hsize{man.png}
\pdfrefximage\pdflastximage

which worked immediately for me using the pdftex command. Thank you!

However, the image is not centered on the page but up against the left margin. Does anyone know how to center the image?

2
  • Welcome to tex,sx. There is a "package" on CTAN called miniltx that can be used within plain TeX to incorporate graphics. I remember using it in the past to do the sort of thing you're trying to do. Unfortunately, miniltx on CTAN comes without user documentation, and I no longer have access to projects I worked on before I retired. But since what you have might be treated as a box, you might try to pack it in a \centerline. Apr 13 at 2:21
  • 2
    Thank you Barbara. This loss of files and project when you retire is a pain. I will try \centerline which I use, but thought only applied to text. Half hour later. SUCCESS! The key is to put it around the second line in my original post, the one with pdfrefximage. Hope your answer helps someone else. I do love how I can take a tex file written over 30 years ago and get it working today with very very minor c changes. 300 pages in less than a second on an iMac Pro. Used to take a long time on a VAX 11/780. Hail Donald Knuth's genius. Apr 13 at 3:46

1 Answer 1

6

You can do in vertical mode (i.e after empty line):

\centerline{\pdfximage width .25\hsize{man.png}
            \pdfrefximage\pdflastximage}

or

\pdfximage width .25\hsize{man.png}
\centerline{\pdfrefximage\pdflastximage}

The first line only loads data of the image to the memory (it is used in PDF file as a numerated object) but doesn't draw it. The number of this object is accessible by \pdflastximage register. And the primitive \pdfrefximage <num> really draws the image saved in the object <num>.

The \centerline plain TeX macro is defined as

\def\centerline#1{\hbox to\hsize{\hss#1\hss}}

so, it does centering of its parameter to the width \hsize.

Another method is doing this in vertical mode:

\noindent\hfil ...image...

finalized by empty line. This works if the the value of the \parfillskip register is 0pt plus 1fil. This is very common value. The value is used as \hskip at the end last line of each paragraph.

1
  • Thanks to wipet for the answer and to Barbara Beeton for comment with the \centerline solution. Apr 14 at 5:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .