Code covered by the BSD License

# latexfigure

### Matthias Pospiech (view profile)

This package enables the use of all fonts that are supported by LaTeX in a figure.

plotTest.m
```clf; clc; clear all;

figure_width  = 8*2;
figure_height = 6*2;
FontSize = 11*1.5;

xaxis = linspace(0,10,50);
data1 =sin(xaxis);
data2 =sin(xaxis + 0.6);
data3 =sin(xaxis + 1.2);

hfig  = figure(1); clf;
set(gcf, 'units', 'centimeters', 'pos', [0 0 figure_width figure_height])
set(gcf, 'PaperPositionMode', 'auto');
set(gcf, 'Color', [1 1 1]); % Sets figure background
set(gca, 'Color', [1 1 1]); % Sets axes background
set(gcf, 'Renderer', 'painters');  %

hLine1 = line(xaxis, data1);
hLine2 = line(xaxis, data2);
hLine3 = line(xaxis, data3);
hdots = line(xaxis, data3);

set(hLine1                        , ...
'LineStyle'       , '--'        , ...
'LineWidth'       , 2           , ...
'Color'           , [0.75 0 0]  );

set(hLine2                        , ...
'LineStyle'       , ':'         , ...
'LineWidth'       , 2           , ...
'Color'           , [0 0 0.75]  );

set(hLine3                        , ...
'LineStyle'       , '-'         , ...
'LineWidth'       , 2           , ...
'Color'           , [0.5 0 0.5]  );

set(hdots                         , ...
'LineStyle'       , 'none'      , ...
'Marker'          , 'o'         , ...
'MarkerSize'      , 6           , ...
'MarkerEdgeColor' , [.5 .0 .5]  , ...
'MarkerFaceColor' , [.7 .5 .7]  );

hTitle  = title ('test graphics');
hXLabel = xlabel('x-axis');
hYLabel = ylabel('y-axis');

hLegend = legend( ...
[hdots, hLine1, hLine2, hLine3], ...
'Data' , ...
'Model'    , ...
'Fit'      , ...
'Validation Data'       , ...
'location', 'Best' );

set( gca                       , ...
'FontName'   , FontName );
set([hTitle, hXLabel, hYLabel], ...
'FontName'   , FontName);
set([hLegend, gca]             , ...
'FontSize'   , FontSize - 2);
set([hXLabel, hYLabel]  , ...
'FontSize'   , FontSize    );
set( hTitle                    , ...
'FontSize'   , FontSize    , ...
'FontWeight' , 'bold'      );

set(gca, ...
'Box'         , 'off'     , ...
'TickDir'     , 'out'     , ...
'TickLength'  , [.02 .02] , ...
'XMinorTick'  , 'on'      , ...
'YMinorTick'  , 'on'      , ...
'YGrid'       , 'on'      , ...
'XColor'      , [.0 .0 .0], ...
'YColor'      , [.0 .0 .0], ...
'YTick'       , -1:0.5:1, ...
'GridLineStyle','--', ...
'LineWidth'   , 1.0         );

% set(gca,'XScale','log')

distPath = 'C:/texlive/2012/bin/win32/';
% latexfigure(hfig,'latexfigure','eps','packages', latexPackages);
latexfigure(hfig,'latexfigure','png','packages', latexPackages, 'distpath', distPath); % 'mathmode', false, 'debug', true
% latexfigure(hfig,'latexfigure','pdf','packages', latexPackages);
```