2

Using XeTeX, I would like to insert a bitmap image file which is in .bmp format, or alternatively, the same image in a .jpg format. I am using plain TeX, not LaTeX.

Using PCTeX version 6,

\special{bmp:nhsealBW.bmp x=1in y=1in}

puts the .bmp image at the current location.

With pdfTeX I was using a set of pdfTeX special commands which are not available in XeTeX:

\newbox\stateseal

\setbox\stateseal\hbox{\pdfximage height 1in width 1in {nhsealbw.jpg}
\pdfrefximage\pdflastximage}

Puts the .jpg image into the box and

\copy\stateseal

inserts it at the current location.

How do I do that in XeTeX?

  • Please use 4 spaces to indent code blocks and back ticks for inline code. For blocks, you can highlight them and then click the {} button or ctrl+k. – cfr May 1 '16 at 23:54
  • Have you looked at PGF/TikZ? Although it recommends graphicx where that's an option (obviously not here), it also have image inclusion capabilities. You just have to declare the image first, if I remember rightly. – cfr May 2 '16 at 0:08
  • What would that look like in plain TeX source file? And where does PGF/TikZ come from? Thank you. – GAS4 May 2 '16 at 0:30
  • What do you mean where does it come from? It is part of all standard TeX distributions, like other packages. – cfr May 2 '16 at 0:44
  • 1
    See section 105 of the manual. Actually, it won't help as you are using XeTeX. If pdfTeX is an option, you can use PGF image declaration and inclusion with plain TeX. Otherwise, it only works with the LaTeX format, apparently. – cfr May 2 '16 at 0:55
0

The simplest way is to:

  1. Convert image_01.bmp to image_01.eps [the imagemagik suite will do this.

  2. Use the following PSTRICKS command \centerline{\epsfysize = 5.0truecm\epsfbox{image_01.eps}}

[see do-it-yourself-tex on CTAN for the import PSTRICKS commands, etc]

  • Thank you. I will give it a try. Is imagemagik suite on any TL distributions or do I get it from imagemagick.org? – GAS4 Mar 31 at 22:03
5

It is possible to use the XeTeX primitives to query the image size and specify the image inclusion to xdvipdfmx driver, but even in plain TeX using system-specific \special is painful and makes switching tex engines or drivers more complicated than need be.

You can use the same driver independent image inclusion macros as latex, which are already set up to do the right thing for bmp files with xetex.

enter image description here

from the plain xetex file

\input graphicx


a work of art:


\includegraphics{man.bmp}


\bye

where man.bmp is

enter image description here

  • But is it a your picture with your hands:-)? +1. – Sebastiano Aug 25 '18 at 21:27
  • I need to query the image size so I can position the image without trial & error. Using Xetex primitives, can you demonstrate with your example please? Thank you. – GAS4 Sep 12 '18 at 10:44
  • @GAS4 easiest is to use \box0\hbox{\includegraphics{man}} then use \ht0 and \wd0 for the height and width. and finally \box0 to use the image – David Carlisle Sep 12 '18 at 12:06
  • @GAS4 I guess you figured it out, but for any future readers, my comment above should start \setbox0 not \box0 – David Carlisle Sep 12 '18 at 18:01
0

Old question, but it should be pointed out that you can just do

\XeTeXpicfile <filename> [scaled <int> width <dimen> height <dimen>]

with XeTeX.

More options can be found in the reference document.

0

graphviz is available for many platforms (in particular it is on most LINUX distributions); see: https://graphviz.org/download/ it may already be there; you want the "convert" command: You can test via:

convert picture.bmp picture.eps

There are probably other convertors for your system; probably based on graphviz.

  • Actually convert does not belong to Graphviz, but to ImageMagick, which is a dependency of Graphviz (see apt-cache rdepends graphviz) and is installed too. – Phelype Oleinik Apr 13 at 1:43
  • Sorry about writing "graphviz" instead of "imagemagick"; thank you Phelype for correcting me. I had been using the former all day and I inadvertently typed "graphviz". The best place for determining where to obtain a version of imagemagick for your system is: en.wikipedia.org/wiki/ImageMagick – morris roger Apr 14 at 15:39

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.