Main Content

Print from Command Window and Editor

Since R2025a. Replaces Set Print Options for Command Window and Editor (R2024b).

You can print the contents of the Command Window or a file open in the Editor or Live Editor. When you print, MATLAB creates a PDF file. Then, you can either save the file or send it to a printer.

  • Command Window — To print the contents of the Command Window, click the Command Window actions button in the top-right corner of the Command Window and select Print. Alternatively, press Ctrl+P.

  • Editor and Live Editor — To print the current file open in the Editor or Live Editor, go to the Editor or Live Editor tab, and in the File section, click Print. Alternatively, press Ctrl+P.

In the Print to PDF dialog box that opens, specify the print options for your document. This table describes the different print options. When you are ready to print, click the Print to PDF button.

Print OptionDescription
Paper size

Select a paper size from the list. Paper size options include Letter (default), Legal, Tabloid, A2, A3, A4, A5, and Custom.

If you select the Custom option, specify the paper size using the Width and Height fields.

Page margin

Select a page margin option from the list. Page margin options include:

  • Default

  • Narrow

  • Moderate

  • Wide

  • Custom

If you select the Custom option, specify the page margins using the Left, Right, Top, and Bottom fields.

Page orientation

Select a page orientation. Options include Portrait or Landscape.

Page options

Select Print Selection to print only the current selection. This option is disabled if there is no selection.

Select Show page numbers to include a page number on each page.

Code options

Select Show line numbers to include a line number for each line of code. This option is only available when printing from the Editor for certain files types.

Select Wrap code lines to wrap any lines that are longer than the printed page width. If this option is not selected, the line is cut off at the page boundaries.

See Also

Functions

Settings

Topics