Does anyone knoy how can we increase the labels fontsize when we use the matlab2tikz (see this link) function from the mathworks file exchange? I always have to access the *.tikz generated file and then add an insctruction to increase the font. Can't that be done as an input to the mat2tikz function?

UPDATE: Using the suggested solution by Torbjørn T, the function matlab2tikz does modify the labels fontsize, however, since I am using nested functions in the following manner (to generate the PDF version):

plotviatikztopdf(strcat(filename,'PPT','.tikz'),'standalone', true,'extraAxisOptions','label style={font=\Large}')
    function plotviatikztopdf(filename,varargin)


ind = find(filename=='.',1,'last');
basename = filename(1:ind-1);
if ispc
    command = sprintf(' pdflatex -jobname %s \\documentclass{standalone}\\usepackage{pgfplots,amsmath}\\begin{document}\\input{%s}\\end{document}',basename,filename);
elseif isunix
    command = sprintf(' pdflatex -jobname %s \\\\documentclass{standalone}\\\\usepackage{pgfplots,amsmath}\\\\begin{document}\\\\input{%s}\\\\end{document}',basename,filename);


if ispc
    system(sprintf('del "%s.aux"',basename));
    system(sprintf('del "%s.log"',basename));

    %%moving to required directory
elseif isunix
    system(sprintf('rm %s.aux %s.log',basename,basename));

sozrce of the above function Link The output is ignoring the 'ExtraAxisOptions' . Is there something wrong in my varargin?


  • Just axis labels, or ticklabels, titles, legends as well? Does adding \pgfplotsset{label style={font=\Large}} to the preamble of your .tex file help? Commented Nov 20, 2013 at 16:43
  • When I add it manually to the resulting *.tikz file, it does work, however, using { matlab2tikz(strcat(filename,'PPT','.tikz'),'extraCode','\pgfplotsset{label style={font=\Large}}') } which is supposed to add exactly the same piece of code at the beginning of the generated file, is not working. I mean, it is not added at all to the generated file. Commented Nov 21, 2013 at 7:00
  • I didn't mean adding it to the .tikz file, but to the .tex file where you \input the .tikz. Then you only have to add it once, and if you want to change it, you only have to change it one place. Commented Nov 21, 2013 at 9:08
  • Actually, I have written a small function in Matlab, which c alls the matlab2tikz function, and generates directly the PDF versions as well. The function takes the figure, generates a PDF version for a report, then, edits the fontsize, and generates a PDF version for presentations. Hence, there is no \input{} . Commented Nov 21, 2013 at 9:54
  • Ah, I wasn't aware of the 'standalone' option, I assume you're using that. You could try adding the label style to 'extraAxisOptions', i.e. 'extraAxisOptions','label style={font=\Large}'. Commented Nov 21, 2013 at 10:20

1 Answer 1


When I first wrote that function I thought I had tested with optional arguments as well, but it seems it doesn't work after all. To fix that change the first line of plotviatikztopdf to


i.e. just add {:} at the end of varargin.

To use 'standalone',true the preamble and document environment has to be removed from the command string, so change that to sprintf('pdflatex %s',filename) (untested).

(I'll update my other answer later.)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .