how to include custom latex usepackage in matlab e.g. labels of figure

Hi, I want to use a usepackage e.g. \physics of latex in matlab to produce some special symbol in my label, but I did not find a easy wag to include it. I also open tex.m(%matlab\toolbox\matlab\graphics) file, but there is nothing in it. I use matlab2016b in win10, I have installed miktex 2.9 and all of the package. Is there a way to include the usepackage from miktex to matlab? Thanks forward

2 commentaires

As you've seen by now, what you want is an exercise in frustration in Matlab.
You could eventually make it work. Might take some time.
Might be easier, for this particular case, to do your plots using matplotlib that has pretty comprehensive support for Latex.
Maybe it's a good choice. I try it. Thanks for the advice.!

Connectez-vous pour commenter.

 Réponse acceptée

7 commentaires

I have see the answers, but I use matlab2016b, it is not allowed to edit tex.m file, it means ,there is nothing that I can edit there. Following are all of the content in the tex.m file, do you have any idea I can do ? Thanks !!
% MATLAB supports TeX/LaTeX for displaying equations
% and other mathematical expressions in the MATLAB figure
% window.
%
% Example:
%
% mytexstr = '$\frac{1}{2}$';
% h = text('string',mytexstr,...
% 'interpreter','latex',...
% 'fontsize',40,...
% 'units','norm',...
% 'pos',[.5 .5]);
%
% The MATLAB implementation of TeX is compiled from Donald Knuth's
% original TeX parser (version: 3.14159) located on the
% <a href="matlab: web('http://www.ctan.org')">TeX Archive Network</a>. The LaTeX distribution was also obtained
% from the TeX Archive Network.
%
% The True Type Computer Modern fonts were obtained from
% the BaKoMa Fonts Collection located on the TeX Archive Network:
% http://www.ctan.org/tex-archive/fonts/cm/ps-type1/bakoma
% The Type1 fonts were obtained from
% http://www.ams.org/publications/type1-fonts
%
% The most recent and complete version of BaKoMa Fonts is
% available at:
% http://www.ctan.org/tex-archive/systems/win32/bakoma
%
% For more information on TeX & LaTeX, please see the following:
% -<a href="matlab:web('http://www.tug.org')">TeX Users Group </a>
% -<a href="matlab:web('http://www.ctan.org')">TeX Archive Network </a>
% -Newsgroup: "comp.text.tex"
% Copyright 1984-2015 The MathWorks, Inc.
Hmmm. Possibly by modifying
fullfile(matlabroot, 'sys/tex/mwarticle.cls')

It does not work either... When I add in mwarticle.cls at line128 e.g.

 \RequirePackage{physics} %in mwarticle.cls

in this file, and also change the texpath with

 setappdata(0, 'TeXPath', [getappdata(0,'TeXPath') 'C:\Program Files\MiKTeX 2.9\tex\latex\physics']);

and restart matlab, the label with interpreter latex will not work at all even for the simple $V_{n}$. When I delete

 \RequirePackage{physics} %in mwarticle.cls

it can work again, but only for standard latex. Also when I excute

 texpath = getappdata(0,'TeXPath')

I got an empty chair. Maybe I use a version matlab16b, it is not allowed to add special usepackage of latex. Or do you have any other ideas?

Thanks in advance!!

Sorry; I suggest you open a support case about this.
Thanks a lot!! Maybe.., how can I open a support case?
Visit https://www.mathworks.com/mwaccount/ and click on Service Requests. On the page that comes up, click on "Create a new Service Request"
Thank you!!!

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by