1

I have quite a few diagrams created by Gnu Octave/MathLab which I need to include in a document. Octave can create several different outputs, but its PDF output is not really that nice as it has a lot of empty space above and below the diagram. I have tried to create diagrams as latex documents which in can use \input on, but then I can't figure out how to rescale the diagram. The most ideal solution would be to be able to scale just the image keeping the text at the same size, but if that is not possible it would also be great to be able to scale the diagram and let Octave increase the text size. How can I rescale such images when Octave creates the latex document and an EPS image and I can only include the latex document?

  • If they are .tikz files, there is tikzscale. Can you add a sample file to the question? – user11232 Jan 13 '14 at 9:10
  • I recommend you check out matlab2tikz. See my previous answer tex.stackexchange.com/a/120151/21963 – marczellm Jan 13 '14 at 9:56
  • @HarishKumar The result as far as I can tell(not very familiar with Octave) are a .tex file and an EPS file. – Nordmoen Jan 13 '14 at 10:00
  • @marczellm does that program work with GNU Octave? – Nordmoen Jan 13 '14 at 10:01
  • @Nordmoen Yes it does. – marczellm Jan 13 '14 at 10:02
3

GNU Octave can export to PDF+supplementary TeX file, EPS+TeX, PGF and also TikZ, as described in its official manual. However, it has the following problems:

  • Exported PDF has too much blank space around.
  • Exported PGF/TikZ code sometimes has to be modified to work
  • Exported PGF/TikZ code output looks bad when zoomed in.

I recommend using the matlabtikz script instead. It can be downloaded from MATLAB Central or you can follow the development on GitHub. You can invoke it as a regular function from both MATLAB and Octave. It has the following advantages:

  • It exports to PGFPlots, which results in prettier and smoother plots than the other approaches.
  • You can specify the dimensions in TeX terms, like this:

    matlab2tikz('width', '.8\textwidth')
    

This last feature answers your question about scaling.

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.