Skip to content

Instantly share code, notes, and snippets.

@megrxu
Created June 27, 2018 12:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save megrxu/6e2008f94050902e4d6747f91ef4a80a to your computer and use it in GitHub Desktop.
Save megrxu/6e2008f94050902e4d6747f91ef4a80a to your computer and use it in GitHub Desktop.
Exporting a figure in Matlab to PDF often outputs a A4-sized pdf file. This snippet can export an standalone pdf which can be used in TeX file directly.
% Exporting a figure in Matlab to PDF often outputs an A4-sized pdf file. This snippet can export a minimal size pdf which can be used in TeX files directly.
% some figures here
figure;
plot(zeros([1, 5]));
% codes that works
fig = gcf;
fig.PaperPositionMode = 'auto';
fig_pos = fig.PaperPosition;
fig.PaperSize = [fig_pos(3) fig_pos(4)];
@erdicn
Copy link

erdicn commented Jun 12, 2023

Thank you!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment