Rich Text Editor help - MATLAB Central

Using Rich Text Editor

Table of contents:

Summary

Use rich editor to enhance your content display with the addition of rich text formatting, hyperlinks, images, and attachments. For your MATLAB code, you can include MATLAB syntax highlighting and LaTeX equations.
RTC help summary

Try this live demo

This rich editor supports rich text formatting for text, code, and insert controls:

Text Controls

The text controls can be used to add formatting such as bold, italic, underline, and monospace. You can also insert numbered and bulleted lists:
  • List item 1
  • List item 2

Code Controls

Code controls allow you to add MATLAB syntax highlighted code, with the code toggle button. Make your code easier to read and understand with the comment, uncomment, indent, and unindent options.
The following example demonstrates code formatting:
% Display Hello World! three times
for i = 1:3
disp('Hello World!');
end

Insert Controls

Insert controls allow you to add images, hyperlinks, LaTeX equations, and attachments. The following image has been inserted using the Image button:


Toolbar Commands

TEXT CONTROLS

Option Description
text toggle icon Text toggle Enables text mode (switches to text mode if you are in code mode).
Note: Text mode is active by default.
normal text icon Normal text Enables normal text.
heading icon Heading Enables heading style.
bold icon Bold Displays text in bold.
italic icon Italic Displays text in italic.
underline icon Underline Underlines text.
monospace icon Monospace Displays text in monospace font.
bulleted list icon Bulleted list Adds bulleted list.
numbered list icon Numbered list Adds numbered list.

CODE CONTROLS

Option Description
code toggle icon Code toggle Enables code mode (switches to code mode if you are in text mode).
comment icon Comment Comments current line.
uncomment icon Uncomment Uncomments current line (if commented).
indent icon Indent Adds tab space to the start of the current line.
unindent icon Unindent Removes tab space from start of current line.

INSERT CONTROLS AND HELP

Option Description
insert image icon Image Add an image. Learn more
hyperlink icon Hyperlink Convert selected text to hyperlink.
equation icon Equation Add LaTeX equation. Learn more
attachments icon Attachments Add attachments. Learn more
code examples icon Code examples Add formatted code examples. Learn more
help icon Help Get help for Rich Text Editor (this page).

RUN CONTROLS

Option Description
run icon Run Run MATLAB code. Learn more
clear all outputs icon Clear outputs Clears all outputs.
Note: The Rich Text Editor is a MATLAB Live Editor component for creating live scripts but with limited functionalities. Learn more about the MATLAB Live Editor formatting.

Keyboard Shortcuts:

Formatting Style Autoformatting Sequence Keyboard Shortcut
Text/code toggle - Ctrl+E (⌥Enter)
Normal Text - Ctrl+Alt+T (⌃⌥T)
Heading ## text + Enter Ctrl+Alt+H (⌃⌥H)
Bold **text**
__text__
Ctrl+B (⌘B)
Italic *text*
_text_
Ctrl+I (⌘I)
Bold and italic ***text***
___text___
Ctrl+B, then Ctrl+I (⌘B, then ⌘I)
Underline - Ctrl+U (⌘U)
Monospace `text`
|text|
Ctrl+M (⌃M)
Bulleted list * text
- text
+ text
Ctrl+Alt+U (⌃⌥U)
Numbered list number. text Ctrl+Alt+O (⌃⌥O)
Comment - Ctrl+R (⌘/)
Indent - Ctrl+] (⌘])
Tab
Unindent/Outdent - Ctrl+[ (⌘[)
Hyperlink URL+Space or Enter
<URL>
[Label](URL)
Ctrl+K (⌘K)
LaTeX equation $LaTeX$ Ctrl+Alt+G (⌘⌥G)
Inline equations - Ctrl+Shift+E (⌘⇧E)
Trademark, service mark, and copyright symbols (™, ℠, ®, and ©) (TM)
(SM)
(R)
(C)
-

  1. Click hyperlink icon on the editor toolbar
  2. Enter link text and target URL in the popup dialog box.
  3. Click OK to add link.

Images

  1. Click insert image icon on the editor toolbar.
  2. Select whether you are uploading from your computer or the Web. Image files must be 15 MB or smaller.
    1. If uploading from your computer, click Choose File to browse and select a file.
    2. If uploading from the Web, enter the URL.
  3. When inserting an image, you can specify the following parameters:
    • Alt text – Specifies an alternate text for an image, if the image cannot be displayed.
    • Size – Scales the image to specified percentage.
    • Alignment – Aligns the image with the text according to the value selected.
  4. Click OK to insert the image.

Attachments

From the Toolbar

  1. Click attachments icon on the editor toolbar.
  2. Click Open to attach the file.

Drag and Drop

  1. Select one or more files and drag them to the editor.
  2. When the editor turns gray, release the file(s).
All attachments must meet the following requirements:
  • Files must be 5 MB or smaller.
  • Attachments must be one of the following formats: bmp, csv, fig, gif, jpg, jpeg, m, mat, mdl, mlx, slx, pdf, png, txt, xls, xlsx, zip.
  • You can upload a maximum of 10 attachments in a 24-hour period. If you need to upload an additional file during this period, delete an existing attachment and upload the new file.

Run feature

Available in: MATLAB Answers

The Run feature allows you to write, run, generate output and validate code inside the editor window without having to start up MATLAB. Run evaluates code using the most recent MATLAB release only.

Some notes about Run:

  • To use Run, your text must be formatted as code using the options on the Code menu.
  • Run is not available on mobile devices.
  • Run does not support MATLAB Coder and GPU Coder toolboxes.

Run feature example

Attachments with Run feature

Attached files are automatically included when you run your code in MATLAB Answers.

This example Answer has an attachment file named mathworks-icon.png, and it is available in the current directory of MATLAB for the code to use. The code reads the image from the attached file and then displays the image.

Attachments in run demo

Code Examples with Run feature

Available in: MATLAB Answers

A code example is sample code that appears as indented monospaced text with MATLAB syntax highlighting. You can use a code example when you don't want the code to be executed by Run.

Code examples demo

Accelerators

User Mentions

Available in: MATLAB Answers, MathWorks Communities, Community Highlights, Community Contests, Blogs

When you type @, a popup displays the community members already in the Q/A thread. As you keep typing, the list expands to include members not in the thread. A mentioned community member receives a notification when the question/answer/comment is posted. Each mention links the post to the community member's user profile.




Available in: MATLAB Answers, MathWorks Communities, Community Highlights, Community Contests, Blogs

To add a link to a documentation page, type @ to insert "@doc:" (or type "@doc:" yourself) and then start typing the function name. In the resulting search popup, select one of the doc topics matching the text you typed to convert it into a hyperlink.

Documentation links feature demo