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).

7
  • have you tried to specify \includegraphics[width=1\textwidth, angle=90]{...}?
    – Holene
    Apr 7, 2013 at 8:24
  • @Holene I tried it an it shrinks the image, even though all of it is there Apr 7, 2013 at 8:30
  • @KevinC Could you expand on that? I'm not even sure where in the manual I would be able to find that. Apr 7, 2013 at 8: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 7, 2013 at 8: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 7, 2013 at 9:03

3 Answers 3

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.

2
  • 13
    Sorry to interrupt; why use the starred version of \hspace? Apr 7, 2013 at 9:35
  • 19
    @SvendTveskæg because if it is the beginning of a line white glue is discarded so white space and normal \hspace have no effect. Apr 7, 2013 at 9:39
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}
5
  • 6
    It is better so post complete working examples instead fragments of code
    – user31729
    Jul 15, 2014 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"). May 11, 2018 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 7, 2018 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. Mar 16 at 6:44
  • That's an interesting perspective to consider, @GlenWhitney, thanks for sharing it! :) Mar 18 at 4: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

6
  • 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 7, 2013 at 9: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 7, 2013 at 9: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. Apr 7, 2013 at 9: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 7, 2013 at 9: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 7, 2013 at 9:22

You must log in to answer this question.

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