4

Sorry to ask again in a few days. The fact is, that I just upgraded from TeX Live 2015 to TeX Live 2017, and a few things started misbehaving.

The result of the following test example is surprising.

\documentclass{letter}
\usepackage{graphicx}
\begin{document}
Hello World\\
Mr. X\includegraphics[bb=30mm 25mm 0mm 0mm,scale=.5]{signature.png}b
\end{document}

The result does not include any graphics, and swaps the text too:

Hello World
b             Mr. X

I need the bb to place the signature with transparency on top of the typed name.

Why \includegraphics now rejects the explicit bounding box?

UPDATE

Re bb with negative values: It is a trick that worked very well for a long time. The graphicx manual, page 2, section 3, includes bb as option. I used this option with negative values, to move the image where it needs to be. It worked with texlive 2015. It does not work with texlive 2017.

Re \llap: no, it places the image to the left of the text area. Result is horrible.

Re \raisebox: no, I do not want to move the text around.

Re \adjustbox: no, it places the signature on top of the name, without overlapping.

UPDATE #2

The following works with pdflatex, but fails with lualatex.

\documentclass{letter}
\usepackage{graphicx}
\begin{document}
~\\A. Dolittle, MD\\
Job title\\
~\includegraphics[bb=0 0 10 10, scale=.5]{signature.png}
\end{document}

With pdflatex, the two lines are printed, and the image is placed on top of them. With lualatex, no image is included at all.

This is pdfTeX, Version 3.14159265-2.6-1.40.18 (TeX Live 2017) (preloaded format=pdflatex 2018.1.8)  8 JAN 2018 22:20

This is LuaTeX, Version 1.0.4 (TeX Live 2017)  (format=lualatex 2018.1.8)  8 JAN 2018 22:29

UPDATE #3

The following works with both pdflatex and lualatex.

\documentclass{letter}
\usepackage{graphicx}
\begin{document}
~\\A. Dolittle, MD\\
Job title\\
\begin{picture}(0,0)
\put(-30,25){\includegraphics[scale=.5]{signature.png}}
\end{picture}
\end{document}

I LOVE YOU DAVID :-)

14
  • 3
    bb is only for EPS files.
    – egreg
    Dec 28, 2017 at 18:33
  • 1
    No, it didn't; only scale was applied.
    – egreg
    Dec 28, 2017 at 18:39
  • 1
    @Rupert: How about using \makebox[0pt][l]{\includegraphics[scale=0.5]{image}} your name here?
    – Werner
    Dec 28, 2017 at 18:51
  • 1
    @Rupert: No overlapping? Surely your name here should overlap with the image, since the image is placed in a zero-width box and the text is printed after the image.
    – Werner
    Dec 28, 2017 at 19:08
  • 3
    Any behaviour of bb with implicit negative size was only the result of a lack of error checking to reject that input (as it never occurred to me that that would be necessary) If it produced an offset that you expected then that was only by accidental, untested code. Note that bb is documented as providing the coordinates of the bottom left and top right coordinates, this does imply that the first two coordinates are smaller values than the second two. Personally I would use picture mode and \put(???,??) to over-print the text and graphic in whatever positions are needed. Jan 8, 2018 at 21:58

4 Answers 4

9

If driver pdftex.def is used (pdflatex), then option bb is not supported, because pdfTeX is able to extract the size of the image formats it supports (e.g., PDF, PNG, JPEG, ...). As bb specifies the bounding box of the image and pdfTeX already knows the bounding box (/MediaBox, ...), bb serves no purpose and as error recovery option viewport is used instead. This behavior was implemented many, many years before; from the revision history (at the top of pdftex.def):

% 2000/09/14 v0.03e
%  * Options `bbllx', `bblly', `bburx', `bbury' disabled,
%    option `bb' redirected with a warning to `viewport' (HO).

From the question:

\includegraphics[bb=30mm 25mm 0mm 0mm,scale=.5]{signature.png}

The values for bb or viewport are quite wrong, from the documentation of LaTeX's graphics bundle:

  • bb The argument should be four dimensions, separated by spaces. These denote the `Bounding Box' of the printed region within the file.

  • bbllx,bblly,bburx,bbury Set the bounding box. Mainly for compatibility with older packages. Specifying bbllx=a,bblly=b,bburx=c,bbury=d is equivalent to specifying bb = a b c d.

  • viewport The viewport key takes four arguments, just like bb. However in this case the values are taken relative to the origin specified by the bounding box in the file. So to `view' the 1 in square in the bottom left hand corner of the area specified by the bounding box, use the argument viewport=0 0 72 72.

bb=30mm 25mm 0mm 0mm or viewport=30mm 25mm 0mm 0mm means that the width (-30mm) and height (-25mm) are negative. The four parameters are left (llx), bottom (lly), right (urx), and top (ury) with the x axis from left to right and the y axis from bottom to top.

A negative width or height is an user error and confuses package graphics/graphicx). For example, LaTeX moves 30mm to the left, thus that b after the image is drawn left of Mr. X that is written before the image in the source.

Fix the values, e.g. viewport=0mm 0mm 30mm 25mm, to get back to the documented behavior.

There are lots of ways to place an image. For example, it can be put to the left and overwriting the left text by putting it in \llap:

Mr. X\llap{\includegraphics[scale=.5]{signature.png}}

\raisebox with its options (also check the optional options) can be used to place the image vertically. Another way is offered by environment picture.

6
  • Re \\llap: it places the image to the left of the text area. Result is horrible.
    – Rupert
    Dec 29, 2017 at 10:20
  • Re \raisebox: no, I do not want to move the text around.
    – Rupert
    Dec 29, 2017 at 10:20
  • Re bb with negative values: It is a trick that worked very well for a long time. The graphicx manual, page 2, section 3, includes bb as option. I used this option with negative values, to move the image where it needs to be. It worked with texlive 2015. It does not work with texlive 2017.
    – Rupert
    Dec 29, 2017 at 10:25
  • @Rupert \llap puts the contents to the left (it also does not start a new paragraph unlike \mbox). If you put it at the left border of the text area, it places the image to the left of the text area. You haven't given any example, how you have used it. Also the question left out important details, how large the image is and where you want to place the image exactly. Dec 31, 2017 at 0:09
  • @Rupert You can only fix the vertical position with \raisebox with the correct arguments. But you cannot move the image "around". Dec 31, 2017 at 0:10
4

I tried your example with a default PNG image. With TeX Live from 2012 to 2016 I get the warning

Package pdftex.def Warning: Option `bb' does not make sense,
(pdftex.def)                using `viewport' instead on input line 5.

So, no, it has never worked. It sort of did, but the support was not really precise.

9
  • I used it for at least 15 years, same code, and it worked very well on PDF.
    – Rupert
    Dec 28, 2017 at 18:39
  • 1
    @Rupert No. You got a warning, at least in the last five years.
    – egreg
    Dec 28, 2017 at 18:41
  • 2
    @Rupert That viewport is used with a warning instead of bb was introduced in the year 2000 in driver pdftex.def. If you haven't noticed this in the last 15 years, this means either you are not using pdflatex, or you use software that is older than 17 years. BTW, luatex.def is much younger, but it inherits from pdftex.def. Dec 28, 2017 at 20:00
  • 1
    I guess I'll need to re-introduce the recovery code here, even though I really don't like the idea of messing with the bounding box of images at all ...
    – Joseph Wright
    Dec 28, 2017 at 20:03
  • 2
    @Rupert Relax and be happy that a collection of the best LaTeX experts of this community are willing to help you free of charge :). Your problem seems to be solved within less than two hours, isn't that great Dec 28, 2017 at 20:57
3

As-of release 2018-01-01, the pdftex and luatex drivers revert to treating bb as equivalent to viewport (see https://github.com/latex3/graphics-def/commit/9e6d682fe28c3811410e0faae70c75e586fc8b05). In contrast to the earlier behaviour (described in Heiko's answer), this mapping is treated as 'information' not a warning.

1
2

Any behaviour of bb with implicit negative size was only the result of a lack of error checking to reject that input (as it never occurred to me that that would be necessary) If it produced an offset that you expected then that was only by accidental, untested code. Note that bb is documented as providing the coordinates of the bottom left and top right coordinates, this does imply that the first two coordinates are smaller values than the second two. Personally I would use picture mode and \put(???,??) to over-print the text and graphic in whatever positions are needed

You must log in to answer this question.

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