TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?


share|improve this question
Just axis labels, or ticklabels, titles, legends as well? Does adding \pgfplotsset{label style={font=\Large}} to the preamble of your .tex file help? – Torbjørn T. Nov 20 '13 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. – user2536125 Nov 21 '13 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. – Torbjørn T. Nov 21 '13 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{} . – user2536125 Nov 21 '13 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}'. – Torbjørn T. Nov 21 '13 at 10:20
up vote 0 down vote accepted

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.)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.