Graphics, Figures & TablesTwo basic Graphics Questions: Placement and Matlab

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
sw3quant
Posts: 76
Joined: Tue Nov 02, 2010 11:40 pm

Two basic Graphics Questions: Placement and Matlab

Post by sw3quant »

I am using MikTex 2.8, Vista, WinEdt 6.0 and Matkab 2009a and Matlab 2010a

first question: I am using the following code to insert a jpeg from file into my PDF document:

\vspace{0.25cm}

\begin{figure}[!htbp]
\begin{center}
\leavevmode
\ifpdf
\includegraphics[height=3in]{res}
\fi
\caption{Response}
\label{FigAir}
\end{center}
\end{figure}

\vspace{0.25cm}

however, when latex judges this to be near the end of the page, it will force the graphic onto the next page and thus "seperate it" from the writing that came before in the tex file layout. How can I force the jpeg to appear in order with the tex writing, even if it means leaving white space on a page?

Ques 2. I am saving images made in matlab (eg graphs) as jpeg files and importing them into latex (as above). On making the PDF the graphic looking awful -- really low resolution.

What am I doing wrong?

Has anyone used this: http://www.mathworks.com/matlabcentral/ ... matlabfrag

Thank you

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

timtico
Posts: 6
Joined: Wed Sep 01, 2010 6:59 pm

Two basic Graphics Questions: Placement and Matlab

Post by timtico »

Hi, First of all I would stay away from the jpg format when dealing with vector based images, it´s horrible. You better export your images from matlab in tiff or png at a high resolution. Both format are lossless and have basically the same quality, however png files are abit smaller in filesize.

A much better option for exporting vector based images such as graphs from matlab is exporting it to pdf. Pdf supports vectors, and you will experience no loss of quality if you include it in your LaTeX document. I use pdf for all the graphs I export from R and want to include in my LaTeX document.

I'm a LaTeX beginner, so i'm not sure what some of the commands you use in your script do... but you're using htbp, and this should place your document either here (where you place it in your script), top, bottom, different page. So that you're doing right. Perhaps your image is simply to large, I would leave away the vertical space and put the image at the same width at the textsize, example:

Code: Select all

\includegraphics[width=1.0\textwidth]{bhc_pec_truncated.pdf}
User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

Re: Two basic Graphics Questions: Placement and Matlab

Post by frabjous »

As for placement, try changing \begin{figure}[!htbp] to simply \begin{figure}[!h].
Post Reply