Wednesday, October 07, 2009

Split big image to two in Latex with ease

If you have one large image that doesn't fit in your page, then you open some photo editor, split the image into two and put those images in two images. Nice! Now your text gets edited (added, removed, updated) and the split images do not seem to fit as they were. You again open up image editor and do the process, hoping that no more edits are required.

You are in luck if you are latex user, you can just change some numbers and split the image on the fly without having to tinker with image editors.

(0,1500)                (600,1500)
 ---------------------
|                               |
|                               |
|                               |
 ---------------------
(0,900)                  (600,900)
 ---------------------
|                               |
|                               |
|                               |
 ---------------------
(0,0)                     (600,0)

First display the first half image with the coordinates(0,900) and (600,1500).
\begin{figure}[h]
 \centering
  \fbox{
   \scalebox{0.5}{\includegraphics*[viewport=0 900 600 1500]{large_image.png}}
  }
\end{figure}
Now display the second part of the image.
\begin{figure}[h]
 \centering
  \fbox{
   \scalebox{0.5}{\includegraphics*[viewport=0 0 600 900]{large_image.png}}
  }
 \caption{Caption only here}
 \label{Label only here}
\end{figure}

No comments: