Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have a long UML diagram, I use the following code. The figure is about two and a half page long, but only the first page is showing, and the lower part of the figure is missing. How do I display the whole diagram in multiple page?

Exactly what code should I add?

\usepackage{graphicx} 
......
\includegraphics[height= 81.3cm, width=18cm]{myImage.png}
\captionof{figure}{Sequence Diagram}
share|improve this question
    
Do you have a question? –  Kerrek SB Sep 23 '11 at 16:17
    
Yes, I want to display the not showing part. Thanks. –  Jing Sep 23 '11 at 18:50
    
My best guess is to include the image as many times as needed each time with a suitable viewport option (and clip). I'll try a "proof of concept". –  egreg Sep 23 '11 at 20:54
    
Do you mean I use photoshop to cut the image and display it separately? Don't know how the viewport works, what code should I add? –  Jing Sep 23 '11 at 23:10
add comment

migrated from stackoverflow.com Sep 23 '11 at 20:33

This question came from our site for professional and enthusiast programmers.

1 Answer

I haven't a fully automated version, but the following works:

\documentclass{article}
\usepackage[a5paper,landscape]{geometry}
\usepackage{caption,graphicx,adjustbox}

\newsavebox{\bigincbox}
\newlength{\bigincht}
\sbox\bigincbox{\includegraphics[width=\textwidth]{tiger}}
\setlength{\bigincht}{\ht\bigincbox}
{\count0=\bigincht \dimen0=.8\textheight \divide\count0 by \dimen0
 \typeout{You need \number\numexpr\count0+1\relax\space chunks}}

\begin{document}
\begin{figure}
\centering
\clipbox*{0 {.5\bigincht} {\textwidth} {\bigincht}}{\usebox{\bigincbox}}
\caption{Upper half}
\end{figure}
\begin{figure}
\centering
\clipbox*{0 0 {\textwidth} {.5\bigincht}}{\usebox{\bigincbox}}
\caption{Lower half}
\end{figure}
\end{document}

Here A5 paper and landscape mode are just for giving the example. The \typeout will write on the log file how many chunks are needed. Once this is known, it's easy to build the chunks, remembering that the first argument to \clipbox* are the lower left corner and upper right corner coordinates determining the rectangle we want to see.

The .8\textwidth is just to leave some amount of space for the caption.

The tiger.pdf image can be found in the documentation directories of PSTricks.

More concrete code

Let's try with an image 81.3cm high and 18cm wide. It seems that chunks at 90% of the text height should be OK, so

\documentclass{article}
\usepackage{graphicx,adjustbox}

\newsavebox{\bigincbox}
\newlength{\bigincht}
\sbox\bigincbox{\makebox[\textwidth]{\includegraphics[width=18cm,height=81.3cm]{tiger}}}
\setlength{\bigincht}{\ht\bigincbox}
{\count0=\bigincht \dimen0=.9\textheight \divide\count0 by \dimen0
 \typeout{You need \number\numexpr\count0+1\relax\space chunks}}

\begin{document}
\begin{figure}
\centering
\clipbox*{0 {.8\bigincht} {\textwidth} {\bigincht}}{\usebox{\bigincbox}}
\caption{Chunk 1}
\end{figure}
\begin{figure}
\centering
\clipbox*{0 {.6\bigincht} {\textwidth} {0.8\bigincht}}{\usebox{\bigincbox}}
\caption{Chunk 2}
\end{figure}
\begin{figure}
\centering
\clipbox*{0 {.4\bigincht} {\textwidth} {0.6\bigincht}}{\usebox{\bigincbox}}
\caption{Chunk 3}
\end{figure}
\begin{figure}
\centering
\clipbox*{0 {.2\bigincht} {\textwidth} {0.4\bigincht}}{\usebox{\bigincbox}}
\caption{Chunk 4}
\end{figure}
\begin{figure}
\centering
\clipbox*{0 0 {\textwidth} {0.2\bigincht}}{\usebox{\bigincbox}}
\caption{Chunk 5}
\end{figure}

\end{document}

The part before \begin{document} is what must go in your preamble; remember to load the package adjustbox. The code after \begin{document} generates the five chunks. Change the captions.

share|improve this answer
    
Sorry I didn't understand your code. Say my image is myImage.png and it's [width=18cm and height=81.3cm], approximately 2 and a half A4 page. What code should I add to my existing code? Thanks. –  Jing Sep 23 '11 at 23:13
    
I would love a fully automated version of this that would work with any image height. I am considering just using a Python script to break my image up into bits. –  Gourneau Dec 21 '12 at 5:39
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.