I want to fix my figure in slide (latex frame) as per my wish with x,y position specification.
Asked
Active
Viewed 5.7k times
3 Answers
28
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*)
lockstep
- 250,273
Stefan Kottwitz
- 231,401
17
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.
Jay Sullivan
- 2,468
AlexG
- 54,894
-
1A more convenient and flexible macro for absolute positioning is given here: http://tex.stackexchange.com/a/311031 . – AlexG Jun 28 '16 at 08: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
-
-
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
15
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.
m13r
- 291
-
1I'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 06 '18 at 14:12 -
1This code is useless for absolute positioning, because the
pictureenvironment 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\includegraphicsand the position by\put. I used this before the\titlepagecommand 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 ofpictureat 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
textposyou could use a grid, relative positioning, and positioning on the background, For a simple single placement apictureenvironment is also fine. – Stefan Kottwitz Oct 25 '11 at 14:17