Include MATLAB Figure in LATEX Document

  • Context: MATLAB 
  • Thread starter Thread starter Curl
  • Start date Start date
  • Tags Tags
    Figure Latex Matlab
Click For Summary

Discussion Overview

The discussion revolves around the challenges of including MATLAB figures in LaTeX documents, specifically using MikTex and Texmaker. Participants explore various file formats and methods for ensuring that figures are displayed correctly without losing axis labels or quality.

Discussion Character

  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant reports issues with .eps and .pdf formats causing axis labels to disappear, while .jpg is considered visually unappealing.
  • Another participant suggests that the problem may relate to bounding box specifications, recommending adjustments to prevent cropping of axis labels.
  • A different participant shares success using TeXworks, questioning why Texmaker fails despite using the same compiler (PDFLaTeX).
  • One participant mentions that switching to .png format resolved their issues, although they note that .png images may appear unattractive unless viewed at 100% size.
  • Another participant advocates for maintaining figures in vector formats like .eps, suggesting the use of Inkscape for further editing and formatting of MATLAB figures before including them in LaTeX documents.

Areas of Agreement / Disagreement

Participants express differing opinions on the best file formats and methods for including MATLAB figures in LaTeX, indicating that no consensus has been reached on a single effective solution.

Contextual Notes

Some participants mention specific software tools and settings that may influence the outcome, such as bounding box adjustments and the choice of image format, but these factors remain unresolved in the discussion.

Curl
Messages
756
Reaction score
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
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?
 
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.
 
I had trouble using .jpg images, so I started saving my MATLAB plots as .png and everything worked fine. :)
 
PNG is ugly unless you are looking at the picture at 100%.
 
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 boundary box to fit the image components.

Hope that helps.
 

Similar threads

  • · Replies 3 ·
Replies
3
Views
4K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 4 ·
Replies
4
Views
4K
  • · Replies 10 ·
Replies
10
Views
3K
  • · Replies 20 ·
Replies
20
Views
4K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 11 ·
Replies
11
Views
6K
  • · Replies 7 ·
Replies
7
Views
8K
Replies
11
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K