Include MATLAB Figure in LATEX Document

In summary, you can save your figure as a .png file and then use Inkscape to ungroup the figure and format it the way you want.
  • #1
Curl
758
0
I have a MATLAB figure I want to put in a document. I'm using MikTex and Texmaker. However in the past half hour I have not been able to get this to work using any format and I tried everything I found on google. If I try to use .eps/.pdf file, all the axis labels disappear. And .jpg is ugly. I don't know what else to try. Anyone know how to do this?
 
Physics news on Phys.org
  • #2
Curl said:
I have a MATLAB figure I want to put in a document. I'm using MikTex and Texmaker. However in the past half hour I have not been able to get this to work using any format and I tried everything I found on google. If I try to use .eps/.pdf file, all the axis labels disappear. And .jpg is ugly. I don't know what else to try. Anyone know how to do this?

Hey Curl.

I did a quick google and got this:

http://amath.colorado.edu/documentation/LaTeX/reference/figures.html

It mentions at the very bottom of the page that you need to specify information that corresponds to the bounding box that is used for the image.

Maybe this is why your axis are getting cut off. Perhaps you could change the bounding box information so that your axis are not cropped out?
 
  • #3
Wow i tried it with TeXworks and it works. Any reason why it doesn't work with Texmaker? I'm using the same compiler (PDFLaTeX) on both apparently. Weird.
 
  • #4
I had trouble using .jpg images, so I started saving my MATLAB plots as .png and everything worked fine. :)
 
  • #5
PNG is ugly unless you are looking at the picture at 100%.
 
  • #6
You want to keep the figure in a vector base format, such as eps.

When making figures with MATLAB for use in papers for example, I often use an image program as a middle step for formatting the figure. Adobe Illustrator works, but it costs money. A free open source program that also works pretty well is Inkscape, which is designed to deal with vector based graphics.

The typical procedure would be to save the MATLAB figure as eps, then use the import option in Inkscape. This allows you to ungroup the components in the MATLAB graph and format it as you wish, for example changing fonts or lineshapes/colors. Then save it as eps, just remember to set the boundry box to fit the image components.

Hope that helps.
 

1. How do I include a MATLAB figure in my LATEX document?

To include a MATLAB figure in your LATEX document, you will need to save the figure as a PDF or EPS file. Then, in your LATEX document, use the \includegraphics command to insert the figure at the desired location.

2. Can I customize the appearance of the MATLAB figure in my LATEX document?

Yes, you can customize the appearance of the MATLAB figure by using additional LATEX packages such as graphicx or epstopdf. These packages allow you to manipulate the figure size, resolution, and other properties.

3. How do I ensure that the MATLAB figure appears at the correct location in my LATEX document?

To ensure that the MATLAB figure appears at the correct location, use the float option when including the figure in your LATEX document. This will allow the figure to be placed at the top or bottom of a page, depending on your document's layout.

4. Can I include multiple MATLAB figures in one LATEX document?

Yes, you can include multiple MATLAB figures in one LATEX document by using the \subfigure or \subfloat commands. These commands allow you to insert multiple figures side by side or on different lines.

5. Is it possible to update a MATLAB figure in my LATEX document without having to manually replace the file?

Yes, it is possible to update a MATLAB figure in your LATEX document without having to manually replace the file. You can use the \includegraphics command with the draft option to display a placeholder for the figure and then use the \includegraphics command again with the final option to display the updated figure.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
927
  • MATLAB, Maple, Mathematica, LaTeX
Replies
10
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
20
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
11
Views
4K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
7K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
10
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
11
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
805
  • MATLAB, Maple, Mathematica, LaTeX
Replies
7
Views
7K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
Back
Top