LaTeX forum ⇒ Graphics, Figures & Tablesmanual positioning of several pdfs on one page

Information and discussion about graphics, figures & tables in LaTeX documents.
moshiko
Posts: 30
Joined: Fri May 08, 2009 9:03 am

manual positioning of several pdfs on one page

Postby moshiko » Sun Aug 01, 2010 11:34 pm

Hi,

I have several pdf files (call them input files) which I would like to put on a single page, with appropriate scaling and positions.
pdfpages should be the solution, though I couldn't manage to make it do what I need.

Here are the steps I would like to perform:
1. Each input file has some text, surrounded by white space. I need to crop the pdf tightly to the area where the contents are in it.
2. For each input file, I know the scaling and position on the page I would like it to appear.
3. I need to combine all the input files to the *same* page a single output pdf.

As an alternative to #1, I can assume that I have the source .tex of each input file. Is there any way to instruct pdflatex (preferrably within the .tex source) that the output should be cropped to the tight boundaries of the contents ? I would prefer a solution that does not involve treating the sources of the input files, if possible.

Any idea how to perform this task ?

thanks.
Last edited by moshiko on Tue Aug 03, 2010 7:52 am, edited 1 time in total.

moshiko
Posts: 30
Joined: Fri May 08, 2009 9:03 am

Postby moshiko » Sun Aug 01, 2010 11:49 pm

two more points about my question:

1. I know about the nup flag of pdfpages, but I don't want to use it since then scaling and position become dependent on the number of input files I have.
I would like to have a kind of solution
\includepdf[scale=0.4,crop=tight, position=15mm 30mm]{input1.pdf}
\includepdf[scale=0.6,crop=tight, position=55mm 20mm]{input2.pdf}
and so on...

2. I am actually using latex as a script for combining a set of input pdfs to one output pdf. Unfortunately, after spending hours on googling this, and in many other forums, I could only find merging to different pages, certainly not with control on scaling and positioning. This is why I am trying to solve this with Latex, but if you know a better way.. then please tell me.

thanks.

php1ic
Posts: 192
Joined: Wed Jan 28, 2009 8:17 pm

Postby php1ic » Mon Aug 02, 2010 1:07 am

This seems like an ugly way, but assuming you are on a unix based system, have the source tex files and are scripting so don't mind doing a few commands on each file.

For each 'input' file:
1) Use latex to create dvi a file.
2) Run "dvips -E file.dvi" on each file create a ps file with a tight bounding box.
3) Run ps2pdf on the ps file that is output.

After that you will have a pdf with a tight margin around the text, allowing you to include it in the main document.

P.S. I say assuming a unix system because I don't know if the final two commands exist on windows

moshiko
Posts: 30
Joined: Fri May 08, 2009 9:03 am

Postby moshiko » Mon Aug 02, 2010 7:40 am

this is nice for cropping the input files to their tight bounding box.

but how can I combine them into one file in the positions and scales I need ?

thanks.

moshiko
Posts: 30
Joined: Fri May 08, 2009 9:03 am

Postby moshiko » Mon Aug 02, 2010 1:15 pm

Is there any way to use the xy package for my task ?

I read the manual but it appears to import a single graphics and then to add annotations on it.
What I would like is to import the first input pdf and then import the other pdf and place them in known positions with repsect to the first file.

any idea of how to use xy for that task ?

maybe there are other packages to put graphics (which in my case are pdf files) in exact positions ?

thanks.

php1ic
Posts: 192
Joined: Wed Jan 28, 2009 8:17 pm

Postby php1ic » Mon Aug 02, 2010 2:06 pm

You could treat the input pdfs as figures, and use the 'subfig' package to create an array.

In this way you can control their position and size relative to the first input pdf.

moshiko
Posts: 30
Joined: Fri May 08, 2009 9:03 am

Postby moshiko » Mon Aug 02, 2010 2:10 pm

Right... but I would like to place them in exact position with respect to each other.
Moreover, I would like to overlay figures, so that one figure is place in front of the other on the same locations. This cannot be done with subfig.

I think that xy gives this capability.
I managed to do the following:

\documentclass[a4paper,12pt]{article}
\usepackage{graphics}
\usepackage{xy}
\begin{document}
\begin{xy}
0*{\includegraphics{file1.pdf}}
+/r1cm/*{\includegraphics{file2.pdf}}
\end{xy}
\end{document}

This puts file2.pdf 1cm to the right of file1.

I still need to understand how it decides on the location of the origin, but this should not be a major problem.

User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Postby gmedina » Mon Aug 02, 2010 2:14 pm

Hi,

the textpos package lets you easily place objects (in particular, figures) at absolute positions on the page.
1,1,2,3,5,8,13,21,34,55,89,144,233,...

moshiko
Posts: 30
Joined: Fri May 08, 2009 9:03 am

Postby moshiko » Mon Aug 02, 2010 2:40 pm

thanks a lot!
This indeed solves my main problem how to position the pdfs relatively to each other.

Now, I would like to return to the more simple task of cropping pdf to its tightest boundary box.

I would like to use something like \includegraphics[tight]{a.pdf} so that it will crop all margins to the tightest possible bounding box around the contents.

Any idea how to do that ?

Note, I don't want to calculate the bounding box by myself.. I would prefer this to be automatically....

thanks.

moshiko
Posts: 30
Joined: Fri May 08, 2009 9:03 am

Postby moshiko » Mon Aug 02, 2010 2:43 pm

one more comment.
At present I use latex on .tex file to create .dvi, then dvipng -T tight produces .png file that contains only the contents of the .tex without any white spaces.

Can we do the same with pdf ?
I have the .tex files of the .pdf files, but if I compile them with pdflatex (or even dvi2pdf after latex) then the pdf have many white spaces around the text... I want to remove those margins.

thanks.


Return to “Graphics, Figures & Tables”

Who is online

Users browsing this forum: No registered users and 6 guests