pdf page layout

classic Classic list List threaded Threaded
18 messages Options
Reply | Threaded
Open this post in threaded view
|

pdf page layout

marciobarbalho
This post was updated on .
Hi all

I've been plotting really beautiful graphs with octave for my thesis... and I noticed the best image format is 'pdf' because I am using LaTex/MikTeX/Windows8. PNG doesn't work well because it is not vectorial, EPS won't work with pdflatex, so... my alternatives are:
1) export the graph to pdf from octave.
2) export to graph to EMF from gnuplot and convert it to PDF. (not very much handy because I'll have to save the data and load it from gnuplot + a third party program to make the conversion)

My question is: Is there a way of making the page layout fit the graph in the PDF format? I noticed a huge space between the picture and its label in the latex final document.

example:
Octave> print -dpdf sombrero.pdf

Very much appreciated

Márcio

___________________________________________
Luck is when opportunity meets preparation. {Seneca}
Reply | Threaded
Open this post in threaded view
|

Re: pdf page layout

bpabbott
Administrator

On Mar 2, 2013, at 10:41 AM, marciobarbalho wrote:

> Hi all
>
> I've been plotting really beautiful graphs with octave for my thesis... and
> I noticed the best image format is 'pdf' because I am using
> LaTex/MikTeX/Windows8. PNG doesn't work well because it is not vectorial,
> EPS won't work with pdflatex, so... my alternatives are:
> 1) export the graph to pdf from octave.
> 2) export to graph to EMF from gnuplot and convert it to PDF. (not very much
> handy because i have to save the dat and load it from gnuplot + a third
> party program to make the conversion)
>
> My question is: Is there a way of making the page layout fit the graph in
> the PDF format? I noticed a huge space between the picture and its label in
> the latex final document.
>
> example:
> Octave> print -dpdf sombrero.pdf
>
> Very much appreciated
>
> Márcio

Octave's pdf output size is controlled by the figure's "papersize" property.  Meaning pdf output is a full page.  The placement of the figure on the page is controlled by the "paperposition" property.  If you just want a figure then you can either (1) adjust the figure's "papersize" and "paperpostion" properties, or (2) If you are using Octave 3.6.x, try using the pdfwrite device.

(1) To adjust the figure properties ...

        close all
        figure (1)
        set (gcf, "papersize", [6, 4], "paperposition", [0 0 6 4])
        plot (rand (3))
        print test1.pdf

(2) Use pdfwrite

        close all
        figure (1)
        plot (rand (3))
        set (gcf, "paperposition", [1.25 3.5 0 6 4])
        print -dpdfwrite test2.pdf

Ben

_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: pdf page layout

marciobarbalho
Thank you!

So the position and size of the paper must be set everytime octave creates a graph? I tried with sombrero and it didn't work well.

Very much appreciated

Márcio
___________________________________________
Luck is when opportunity meets preparation. {Seneca}
Reply | Threaded
Open this post in threaded view
|

Re: pdf page layout

bpabbott
Administrator
On Mar 2, 2013, at 12:04 PM, marciobarbalho wrote:

> Thank you!
>
> So the position and size of the paper must be set everytime octave creates a
> graph? I tried with sombrero and it didn't work well.
>
> Very much appreciated
>
> Márcio

The papersize and paperposition are always set for each graph.  If you want something other than the default, then you need to change them.

The properties will stay in place until the figure is deleted (closed).

What did you try that didn't work well?

Ben
_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: pdf page layout

marciobarbalho
I tried with 'sombrero', as it didn't work, I changed the page properties:

set (gcf, "papersize", [9, 9], "paperposition", [0 0 9 9])

but still there's a bit of space before and after the sombrero itself when loaded in the latex document. It seems the graph must be as tight as possible so the final layout looks professional.

Very much appreciated

Márcio



___________________________________________
Luck is when opportunity meets preparation. {Seneca}
Reply | Threaded
Open this post in threaded view
|

Re: pdf page layout

pathematica
This post was updated on .
In reply to this post by bpabbott
Hello there.

I know this is slightly off-topic (from Octave) but, as an alternative strategy, you might consider using the "trim" command when embedding pdf images in LaTeX. I used the following:

\begin{figure}[h]
\begin{center}
\includegraphics[trim = 75mm 108mm 77mm 130mm, clip, scale=0.88]{Fig.pdf}
\end{center}
\end{figure}

For convenience, I have called the figure Fig.pdf, and I had placed the following command in the preamble:
\graphicspath{{./figures/}}

The values passed to trim refer, in order, to: left; bottom; right; top. Do not forget to include the "clip" command otherwise the trim will not happen. Also note that I have used a scale parameter, which was appropriate for my particular needs.

To defend posting LaTeX code here, I found this a very useful way to include graphics generated by Octave in LaTeX documents.

You will need to experiment to see what works for you but, if you produce standard pictures, for which the same parameters will be appropriate in each case, then you could define new commands in your LaTeX preamble eg (note different values for parameters than above, which was for a special case for the frontispiece)

\newcommand{\FigScale}{0.55}
\newcommand{\Lcol}{35}
\newcommand{\Rcol}{35}
\newcommand{\Tcol}{93}
\newcommand{\Bcol}{65}

Then a figure might be embedded with eg

\begin{figure}
\begin{center}
\includegraphics[trim = \Lcol mm \Bcol mm \Rcol mm \Tcol mm, clip, scale=\FigScale]{AnotherFig.pdf}
\end{center}
\caption{\textit{My legend for this figure}}\label{fig:MyLabelForThisFigureSoICanReferToItInTheText}
\end{figure}

I have included a caption and a label to this one, in case it might be helpful. I would then refer to the figure in the text as, for example, see figure \ref{fig:MyLabelForThisFigureSoICanReferToItInTheText}.

Best wishes

David
However good you think Octave is, it's much, much better.
Reply | Threaded
Open this post in threaded view
|

Re: pdf page layout

marciobarbalho
It actually works... but the graphs I need are not standardised (same size) so I'll have the same problem as before.
All this trouble because I want vectorised pictures, if not, I'd go with PNG and it'd be much less work.

Thank you for your time!

Márcio
___________________________________________
Luck is when opportunity meets preparation. {Seneca}
Reply | Threaded
Open this post in threaded view
|

Re: pdf page layout

pathematica
Hi Marcio

Even if the graphs are not standard size, perhaps they might be arranged in groups of similar size. Should that be the case, and you can find trim and scale parameters for each group, then you could include suitable new commands in your preamble. Eg

\newcommand{\FigScaleClass1}{0.55}
\newcommand{\LcolClass1}{35}
\newcommand{\RcolClass1}{35}
\newcommand{\TcolClass1}{93}
\newcommand{\BcolClass1}{65}

\newcommand{\FigScaleClass2}{0.65}
\newcommand{\LcolClass2}{45}
\newcommand{\RcolClass2}{45}
\newcommand{\TcolClass2}{97}
\newcommand{\BcolClass2}{55}

etc

then you could use the particular set of parameters that are appropriate for some particular figure. It will be obvious to all who post here that use modular code all the time but it is worth restating for neophytes that the advantage of using the new command approach is that you need not remember the parameters once you have discovered the ones that work best, and you can change them for all the figures in one fell swoop if you decide to change the layout (eg from article to book etc).

(I have used random numbers for illustrative purposes.)

Certainly, this worked for me when I was producing plots that could be grouped in broadly similar types.

Hope you find a solution that works!

Best wishes

David
However good you think Octave is, it's much, much better.
Reply | Threaded
Open this post in threaded view
|

Re: pdf page layout

marciobarbalho
Works like charm if i have a pdf viewer with a ruler, so I know how much to crop/trim.

Thank you

Márcio
___________________________________________
Luck is when opportunity meets preparation. {Seneca}
Reply | Threaded
Open this post in threaded view
|

Re: pdf page layout

Seetha Parameswaran
Hi,

EPS works in LaTeX

Include the package

           \usepackage{epsfig}

and in the document 
           \begin{figure}[h]
           \begin{center}
           \epsfig{width=1in, file=image.eps}
           \end{center}
           \end{figure} 

--
Regards,
Seetha

_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: pdf page layout

marciobarbalho
EPS won't work with pdflatex unfortunately!

I've had great results with the trim command.

Thank you.
___________________________________________
Luck is when opportunity meets preparation. {Seneca}
Reply | Threaded
Open this post in threaded view
|

Re: pdf page layout

lukshuntim
On Sunday, March 03, 2013 11:07 AM, marciobarbalho wrote:
> EPS won't work with pdflatex unfortunately!
>
> I've had great results with the trim command.
>
> Thank you.

Glad that you had an excellent solution!

If you have the oberdiek bundle installed (which usually is with a
modern tex/latex system), eps can be converted on the fly to pdf.

http://www.ctan.org/pkg/epstopdf-pkg

Regards,
ST
--

_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: pdf page layout

marciobarbalho
I tried epstopdf, the graph quality is great. I'll read the documentation (myabe I can make it convert with colours too) and run some tests to compare 'greatness' in graph display!

Thank you
___________________________________________
Luck is when opportunity meets preparation. {Seneca}
Reply | Threaded
Open this post in threaded view
|

Re: pdf page layout

marciobarbalho
In reply to this post by bpabbott
bpabbott wrote
(1) To adjust the figure properties ...

        close all
        figure (1)
        set (gcf, "papersize", [6, 4], "paperposition", [0 0 6 4])
        plot (rand (3))
        print test1.pdf
Dear Ben,

just to clarify, are those values above (in bold) in inches?

very much appreciated
___________________________________________
Luck is when opportunity meets preparation. {Seneca}
Reply | Threaded
Open this post in threaded view
|

Re: pdf page layout

bpabbott
Administrator

On Mar 4, 2013, at 7:33 AM, marciobarbalho wrote:

> bpabbott wrote
>> (1) To adjust the figure properties ...
>>
>> close all
>> figure (1)
>> set (gcf, "papersize", [
> *
>> 6, 4
> *
>> ], "paperposition", [0 0 6 4])
>> plot (rand (3))
>> print test1.pdf
>
> Dear Ben,
>
> just to clarify, are those values above (in bold) in inches?
>
> very much appreciated
>

Yes.  You can change the units by modifying the "paperunits" property.  For example, to use centimeters ...

        set (gcf (), "paperunits", "centimeters")

Ben

_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: pdf page layout

marciobarbalho
Very much appreciated!

Octave and its functions plus the trim command in Latex are doing an excellent job here!

Regards

Márcio
___________________________________________
Luck is when opportunity meets preparation. {Seneca}
Reply | Threaded
Open this post in threaded view
|

Re: pdf page layout

Petr Mikulik
In reply to this post by marciobarbalho
> My question is: Is there a way of making the page layout fit the graph in
> the PDF format? I noticed a huge space between the picture and its label in
> the latex final document.

You want to fix the bounding box. Similarly to eps2eps or fixbb programs to
fix the bounding box for eps files, there is pdfcrop (in texlive) for pdf
files.

Don't confuse it with PDFCrop on sourceforge which does rescaling and not
cropping.

---
PM
_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: pdf page layout

John Frain
In reply to this post by marciobarbalho
Have alook at the briss gui based pdf cropper. I have used in the exact way you describe. It can be downloaded from


sourceforge.net/projects/
briss/

John


On 2 March 2013 15:41, marciobarbalho <[hidden email]> wrote:
Hi all

I've been plotting really beautiful graphs with octave for my thesis... and
I noticed the best image format is 'pdf' because I am using
LaTex/MikTeX/Windows8. PNG doesn't work well because it is not vectorial,
EPS won't work with pdflatex, so... my alternatives are:
1) export the graph to pdf from octave.
2) export to graph to EMF from gnuplot and convert it to PDF. (not very much
handy because i have to save the dat and load it from gnuplot + a third
party program to make the conversion)

My question is: Is there a way of making the page layout fit the graph in
the PDF format? I noticed a huge space between the picture and its label in
the latex final document.

example:
Octave> print -dpdf sombrero.pdf

Very much appreciated

Márcio





-----
___________________________________________
Luck is when opportunity meets preparation. {Seneca}
--
View this message in context: http://octave.1599824.n4.nabble.com/pdf-page-layout-tp4650462.html
Sent from the Octave - General mailing list archive at Nabble.com.
_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave



--
John C Frain, Ph.D.
Trinity College Dublin
Dublin 2
Ireland
www.tcd.ie/Economics/staff/frainj/home.htm
mailto:[hidden email]
mailto:[hidden email]

_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave