Format Files in the Live Editor

You can add formatted text, hyperlinks, images, and equations to your live scripts and functions to create a presentable document to share with others.

To insert a new item, go to the Insert tab and select from the available options:

OptionDescriptionAdditional Details


Insert a blank line of code.You can insert a code line before, after, or between text lines.

Section Break

Insert a section break.You can insert a section break to divide your live script or function into manageable sections to evaluate individually. A section can consist of code, text, and output. For more information, see Run Sections in Live Scripts.


Insert a blank line of text.A text line can contain formatted text, hyperlinks, images, or equations. You can insert a text line before, after, or between code lines.

Table of Contents

Insert a table of contents.

The table of contents contains a list of all the titles and headings in the document. Only the title of the table of contents is editable.

You can add a table of contents only in text lines. If you insert a table of contents into a code line, MATLAB® places it directly above the current code section.

Code Example

Insert a formatted code example.

A code example is sample code that appears as indented and monospaced text.

Select Plain to insert sample code as unhighlighted text.

Select MATLAB to insert sample code as text highlighted according to MATLAB syntax.


Insert an image.You can add images only in text lines. If you insert an image into a code line, MATLAB places the image in a new text line directly under the selected code line.


Insert a hyperlink.

Select External URL to insert an external URL.

Select Internal Hyperlink to insert a hyperlink that points to an existing location within the document. When prompted, click the desired location within the document to select it as the target. You also can use the Alt + Up Arrow and Alt + Down Arrow keyboard shortcuts. Location can be a code section, text paragraph, title, or heading. Linking to individual lines of text or code is not supported.

You can add hyperlinks only in text lines. If you insert a hyperlink into a code line, MATLAB places the hyperlink in a new text line directly under the selected code line.


Insert an equation.You can add equations only in text lines. If you insert an equation into a code line, MATLAB places the equation in a new text line directly under the selected code line. For more information, see Insert Equations into the Live Editor.

To format existing text, use any of the options included in the Live Editor tab Text section:

Format TypeOptions
Text Style


Heading 1

Heading 2

Heading 3


Text Alignment





Numbered list

Bulleted list

Standard Formatting





To change the case of selected text or code from all uppercase to lowercase, or vice versa, select the text, right-click, and select Change Case. You also can press Ctrl+Shift+A. If the text contains both uppercase and lowercase text, MATLAB changes the case to all uppercase.

To adjust the displayed font size in the Live Editor, use the Ctrl + Mouse Scroll keyboard shortcut. The change in the displayed font size is not honored when exporting the live script to PDF, Microsoft® Word, HTML, or LaTeX.


For quick formatting in live scripts and functions, you can use a combination of keyboard shortcuts and character sequences. Formatting appears after you enter the final character in a sequence.

This table shows a list of formatting styles and their available keyboard shortcuts and autoformatting sequences.

Formatting StyleAutoformatting SequenceKeyboard Shortcut

# text + Enter

Ctrl + Alt + L

Heading 1

## text + Enter

Ctrl + Shift + 1

Heading 2

### text + Enter

Ctrl + Shift + 2

Heading 3

#### text + Enter

Ctrl + Shift + 3

Section break with heading 1

%% text + Enter

With cursor at beginning of line with text:

Ctrl + Shift + 1, then Ctrl + Alt + Enter

Section break

%% + Enter

--- + Enter

*** + Enter

Ctrl + Alt + Enter

Bulleted list

* text

- text

+ text

Ctrl + Alt + U

Numbered list

number. text

Ctrl + Alt + O




Ctrl + I




Ctrl + B

Bold and italic



Ctrl + B, then Ctrl + I




Ctrl + M


Ctrl + U

LaTeX equation


Ctrl + Shift + L


URL + Space or Enter



Ctrl + K

Trademark, service mark, and copyright symbols (™, ℠, ®, and ©)







Title, heading, section break, and list sequences must be entered at the beginning of a line.

Sometimes you want an autoformatting sequence such as *** to appear literally. To display the characters in the sequence, escape out of the autoformatting by pressing the Backspace key or by clicking Undo . For example, if you type ## text + Enter, a heading in the Heading 1 style with the word text appears. To undo the formatting style and simply display ## text, press the Backspace key. You only can escape out of a sequence directly after completing it. After you enter another character or move the cursor, escaping is no longer possible.

To revert the autoformatting for LaTeX equations and hyperlinks, use the Backspace key at any point.

To force formatting to reappear after escaping out of a sequence, click the Redo button. You only can redo an action directly after escaping it. After you enter another character or move the cursor, the redo action is no longer possible. In this case, to force the formatting to reappear, delete the last character in the sequence and type it again.

To disable all or certain autoformatting sequences, you can adjust the Editor/Debugger Autoformatting Preferences.

Related Topics