This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

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

Code

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.

Text

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.

Image

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.

Hyperlink

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. 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.

Equation

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

Normal

Heading 1

Heading 2

Heading 3

Title

Text Alignment

Left

Center

Right

Lists

Numbered list

Bulleted list

Standard Formatting

Bold

Italic

Underline

Monospace

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.

Autoformatting

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
Title

# 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

Italic

*text*

_text_

Ctrl + I

Bold

**text**

__text__

Ctrl + B

Bold and italic

***text***

___text___

Ctrl + B, then Ctrl + I

Monospace

`text`

|text|

Ctrl + M

UnderlineNone

Ctrl + U

LaTeX equation

$LaTeX$

Ctrl + Alt + G

Hyperlink

URL + Space or Enter

<URL>

[Label](URL)

Ctrl + K

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

(TM)

(SM)

(R)

(C)

None

Note

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. Adjusting the autoformatting preferences is not available in MATLAB Online™.

Related Topics