25

I want to fix my figure in slide (latex frame) as per my wish with x,y position specification.

23

You could use the textpos package for absolute positioning of figures or text boxes.

Here's an example:

\documentclass[demo]{beamer}
\usepackage[absolute,overlay]{textpos}
  \setlength{\TPHorizModule}{1mm}
  \setlength{\TPVertModule}{1mm}
\begin{document}
 \begin{frame}
   \begin{textblock}{20}(40,20)
      \includegraphics{file}
    \end{textblock}
 \end{frame}
\end{document}

with the syntax \begin{textblock}{*width*}(*x-position,y-position*)

| improve this answer | |
  • 4
    \begin{picture}(50,50) \put(250,0){\hbox{\includegraphics[scale=0.3]{figs/set}}} \end{picture} This works simply to locate picture... Kindly give your suggestion over this code with your code. – Palani Kannan Oct 25 '11 at 14:11
  • @PalaniKannan: good! You could make an answer from that code in your comment. – Stefan Kottwitz Oct 25 '11 at 14:13
  • @PalaniKannan: with textpos you could use a grid, relative positioning, and positioning on the background, For a simple single placement a picture environment is also fine. – Stefan Kottwitz Oct 25 '11 at 14:17
13

As far as I remember,

\usepackage{tikz}
\usepackage{graphicx}
\usetikzlibrary{calc}

...

\begin{tikzpicture}[remember picture,overlay]
  \node[anchor=south west,inner sep=0pt] at ($(current page.south west)+(2cm,5cm)$) {
     \includegraphics{imgfile}
  };
\end{tikzpicture}

should place imgfile.pdf at x=2cm and y=5cm from the lower left page corner.

| improve this answer | |
  • A more convenient and flexible macro for absolute positioning is given here: tex.stackexchange.com/a/311031 . – AlexG Jun 28 '16 at 8:24
  • When I run this, I get " ! LaTeX Error: Cannot determine size of graphic in img.png (no BoundingBox). " – user43326 Aug 16 '18 at 14:46
  • Something must be wrong with your img.png. Try example-image. – AlexG Aug 16 '18 at 14:56
  • Actually the code works if I compile with pdflatex, but it doesn't if I try to compile with latex. So presumably the issue is not with the image file. – user43326 Aug 16 '18 at 17:11
10

As suggested by @PalaniKannan you could do the following:

\begin{picture}(50,50)
\put(200,-300){\hbox{\includegraphics[scale=0.3]{file}}}
\end{picture}

This will place the image at position "200 right and 300 down" relative to the top left corner of the current page.

Also have a look at this wiki page.

| improve this answer | |
  • 1
    I'd rather recommend {50,100} for the start position and [width=0.66\textwidth,height=0.5\textheight,keepaspectratio] for the scaling, but the picture environment is the way to go for simple things. – stefanct Aug 6 '18 at 14:12
  • 1
    This code is useless for absolute positioning, because the picture environment is placed at the current position. – AlexG Aug 17 '18 at 14:42
  • @AlexG it can work for uses by putting it as the first command in the slide and using a size (0,0) environment (so that it does not move stuff coming after it). The actual size is then set by \includegraphics and the position by \put. I used this before the \titlepage command and it worked for me. – fqq Dec 11 '19 at 16:35
  • 1
    @fqq OP asked for absolute positioning, which means relative to the paper edges. In the way you suggest, even with a zero-size picture, (200,-300) would still be relative to the reference point of picture at the time of its use, which is, at best, the upper left corner of the text area. – AlexG Dec 11 '19 at 16:56
  • Yes, I agree, indeed (0,0) does not put the figure in the upper left corner of the page. Your answer gives absolute positioning, this is a less reliable hack with (slightly) simpler code. – fqq Dec 11 '19 at 17:13

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.