I experience odd behavior of one of my figures created with Matlab2Tikz. I have three alike figures which differ only in terms of data points. Weirdly only the one with the smallest amount of data points gives the error

\begin{tikzpicture} ended by \end{document}

The other two figures have about 20% more more data samples in them. So I don't think its due to lack of memory!? Please find the figure here:


Any help is appreciated. Thanks a lot! Here is my MWE:



  • 2
    Please provide a complete example here. Questions should remain useful to other users and so must not rely on the content of external links. In any case, many people are rightly suspicious of such material - especially if you expect people to run your code with shell escape. – cfr Sep 11 '16 at 19:30
  • 2
    The options to \begin{axis} all seem to end with ticklabel style={font=\footnotesize which is then closed by the ] which concludes the axis options, LaTeX probably gets confused by the fact that the ticklabel style={ is never closed by a } – Dai Bowen Sep 11 '16 at 19:31
  • Go through fig01.tex and see if there are any misplaced or non-escaped % in it. Not at a pc, so cannot test. – daleif Sep 11 '16 at 19:31
  • 1
    @DaiBowen that's an answer. – percusse Sep 11 '16 at 19:36
  • 1
    I strongly suspect the downvote you recieved on this question was for linking to code elsewhere/not having a fully compilable example accessible from this page. It might be worth remembering that while you care about compiling many plots with many data points, if they're all pretty similar then an MWE works with a single plot and a couple of data points (this also helps you do an important test which is are all my plots affected or is it something specific about a few). Links also die after a while, making questions more difficult to answer, as I commented on one of your other questions :) – Dai Bowen Sep 11 '16 at 23:01

All \begin{axis} environments you have seem to end abruptly with an unclosed option. The last option below is ticklabel style={font=\footnotesize ] clearly the style option is never closed but instead LaTeX finds the entire list of keys is concluded while it's still processing one of them. Hopefully if you add a closing brace, replacing ticklabel style={font=\footnotesize with ticklabel style={font=\footnotesize} there will be no other issues.

(Code below extracted from the link provided by the OP)

scale only axis,
xlabel={time [s]},
ylabel={$\lambda_r$ [\%]},
axis background/.style={fill=white},
axis x line*=bottom,
axis y line*=left,
legend style={font=\tiny}, ticklabel style={font=\footnotesize

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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