55

I composed a diagram that takes up the entire sheet of paper in landscape mode, called diagram.tex (compiled it to generate pdf). I'm trying to include that into an article, but only half of it is showing; the bottom half is cut off by the right end of the paper.

I was able to get it in the proper orientation by using

\includegraphics[angle=90]{diagram.pdf}

But because the bottom half of it is cut off, I need some sort of option where I can do something like this:

\includegraphics[angle=90, shift left = 5cm]{diagram.pdf}

to pull the rest of the image left (or up, depending on how you're looking at it).

So how can I move the figure around?

I'm not sure if this is relevant, but I'm using the following documentclass and packages in my paper:

\documentclass[11pt,a4paper,twoside]{article}
\usepackage{tikz, graphicx}

Edit:

This is not an issue with pushing it past the margins. Half of the picture is not on the paper (sort of like if you stuck half of your left hand behind the left side of your monitor). I need to pull the paper left (just like you would shift your hand left to see it).

  • have you tried to specify \includegraphics[width=1\textwidth, angle=90]{...}? – Holene Apr 07 '13 at 08:24
  • @Holene I tried it an it shrinks the image, even though all of it is there – TheRealFakeNews Apr 07 '13 at 08:30
  • @KevinC Could you expand on that? I'm not even sure where in the manual I would be able to find that. – TheRealFakeNews Apr 07 '13 at 08:32
  • 1
    width = 1\textwidth will scale the input pdf such that it actually fits the page. I may misunderstand how your problem really looks like, but to me it sounds like you want to push the left side of the pdf past the page margins. In my opinion it's better to stay to the margins. Alternatively you could use the PDFpages package and include the entire PDF? – Holene Apr 07 '13 at 08:34
  • @AlanH: Sorry I was wrong about my previous suggestion. But how about this: \hspace{-<some number>in}\includegraphics[angel=90]{...}? Basically this shifts the included picture left by <some number> inch. – Herr K. Apr 07 '13 at 09:03
  • @KevinC Still doesn't work :\ – TheRealFakeNews Apr 07 '13 at 09:09
  • @AlanH: It works on my computer... If you are okay with including a landscape page in your document, here's an alternative solution – Herr K. Apr 07 '13 at 09:13

3 Answers3

81

\includegraphics makes a box that is positioned the same way \mbox{} or A are positioned. If you want to move it 3cm to the left use

\hspace*{-3cm}\includegraphics.....

The reason we use \hspace* instead of \hspace is that at beginning of a line, white glue is discarded, so any white space added by the normal \hspace would have no effect.

Stefan Pinnow
  • 29,535
David Carlisle
  • 757,742
43

To include shifts directly in the options part of the \includegraphics[options]{graphic.pdf} part of the command, a more straight forward way is the

`trim=left bottom right top` 

option. Here, left, bottom, right, and top are units of length, which trim the graphic for positive values and add space for negative values.

So to move to the right by 5cm and 1 cm from the top, you would do:

\includegraphics[trim=-5cm 0 0 -1cm]{diagram.pdf}
littlemind
  • 531
  • 4
  • 2
  • 6
    It is better so post complete working examples instead fragments of code –  Jul 15 '14 at 12:54
  • 2
    Does the trick, even though I find the parameter name to be misleading (I associate "trimming" with "cropping" instead of "offsetting"). – Waldir Leoncio May 11 '18 at 11:46
  • This works especially well with figures that have some trailing whitespace preventing any accurate automatic centering! If you trim the whitespace, automatic centering with \includegraphics[width=\linewidth] works again. – bhnn Oct 07 '18 at 17:31
  • @WaldirLeoncio, it isn't offsetting. It is trimming -- it is cutting off a negative amount of the image on the corresponding border, which is to say, it is adding whitespace there. That often has the apparent effect of moving the image around. – Glen Whitney Mar 16 '24 at 06:44
  • That's an interesting perspective to consider, @GlenWhitney, thanks for sharing it! :) – Waldir Leoncio Mar 18 '24 at 04:51
8

Opting for an answer as the comments with a lot of code have pretty low readability. The ninja pic is taken from http://tinyurl.com/btapmmx

\documentclass[12pt]{article}
\usepackage{tikz}
\begin{document}
\begin{figure}
\begin{tikzpicture}
    \begin{scope}
    \node {Node 1: \includegraphics[width=1 in]{images/ninja}};
    \end{scope}
    \begin{scope}[xshift=-5cm]
    \node {Node 2: \includegraphics[width=1 in]{images/ninja}};
    \end{scope}
\end{tikzpicture}
\end{figure}
\end{document}

Node 2 is now shifted, so if you skip the code for the scopes and node 1, and include your pdf in node 2 you should be able to shift the included pdf here and there.

The result: enter image description here

Holene
  • 6,920
  • Hmm, does the xshift option only work when there are two scopes? I was trying with only one scope, and the xshift option wasn't doing anything... – Herr K. Apr 07 '13 at 09:16
  • 1
    @KevinC No, you can simply do: \begin{tikzpicture}[xshift=-5cm] \node{node content}; \end{tikzpicture}. I added the two scopes just to illustrate the difference with and without xshift =) It works fine for me using only one scope too. – Holene Apr 07 '13 at 09:17
  • @Holene Okay, I think it's because the picture I'm importing has a slight margin, so I need to pull it past the margin in my article, which is why nothing was shifting for me, it's already pulled to the margin of the article. If I rescale it, which I tried, the picture doesn't look right. – TheRealFakeNews Apr 07 '13 at 09:19
  • Have you tried adding the .tex source file in a figure environment instead of the compiled pdf, e.g. \input{source_file.tex}. I think you'll have to fix the orientation etc. in the .tex file though. – Holene Apr 07 '13 at 09:21
  • @Holene: I did exactly what you said there... Perhaps it's my home computer's fault (I haven't updated my MikTeX for ages). – Herr K. Apr 07 '13 at 09:22
  • @KevinC If you use \centering or similar for your figure environment it doesn't work to specify one scope or xshift the entire tikzpicture. – Holene Apr 07 '13 at 09:30