OriginLab Corporation - Data Analysis and Graphing Software - 2D graphs, 3D graphs, Contour Plots, Statistical Charts, Data Exploration, Statistics, Curve Fitting, Signal Processing, and Peak Analysis                     
 

8.12.1.1 Escape Sequences

Escape sequences and text formats

When applying special formatting to text objects on graphs, worksheets or layout pages, typically you would select the target text with your mouse and click a button on the Format or Style toolbars. When working with text objects using WYSIWYG methods, you typically are not aware of the hidden text formatting commands behind the toolbar buttons -- what we call escape sequences. However, there are places in the Origin interface where these escape sequences are seen and there are times when it is helpful to have a basic understanding of what they are and how they work.

All text labels (those created with the Text tool, the Add Text shortcut menu command, the LabTalk Label command, or any prefixes or suffixes that you type in text boxes) as well as text plotted from a Label column will use these escape sequences, even though, as mentioned, they may not be seen. All escape sequences begin with a backslash "\" character, and are followed by a control character that determines how the affected text is modified. Finally, the text to be modified follows the control character, and is enclosed in parentheses, like this:

\ControlCharacter(TheTextToBeModified)

Escape Sequences 01.png

When you use the buttons and drop-down lists on the Style and Format toolbars to format text labels, Origin automatically adds these formatting commands to the affected text. These formatting commands, while not visible in the text label itself, can be observed in the text label's Object Properties dialog box (Format: Object Properties).

For example, we could use the Text tool to create a text label that reads "Control," then highlight the text and click the Bold button (Format toolbar). The label as it appears on your graph or worksheet simply reads "Control" but what you see if you open the label's Object Properties dialog box is that your text is now enclosed by a "\b( )" sequence. It is the "\b( )" formatting command that causes the word "Control" to display in bold type. The practical significance of this is that you can explicitly use these special formatting commands to format your text -- in prefix or suffix text boxes, in the Object Properties dialog box, or with the LabTalk Label command when programmatically creating text labels -- in situations where the WYSIWYG text editing methods are not available to you.

Note that some supported escape sequences are interpreted by LabTalk while others are standard C-language escape sequences.

Available text formatting commands

Syntax Description Entering... Results in...

\v(text)

Override any escape sequences that are included in text.

This is particularly useful when displaying a path that includes a backslash '\' .

\v (C:\Samples\Programming)

Available Text Formatting Commands 1.png

\+(text)

Format text as superscript.

super\+(script)

Available Text Formatting Commands 2.png

\-(text)

Format text as subscript.

sub\-(script)

Available Text Formatting Commands 3.png

\=(text1,text2)

Format text1 as subscript, text2 as superscript.

script\=(sub,super)

Available Text Formatting Commands 4.png

\p%pointsize(text)

Change the point size of text. 200 doubles the size, 100 results in no change, etc.

change\p200(point)size

Available Text Formatting Commands 5.png

\i(text)

Format text as italics.

\i(italics)

Available Text Formatting Commands 6.png

\b(text)

Format text as bold.

\b(bold)

Available Text Formatting Commands 7.png

\u(text)

Format text as underline.

\u(underline)

Available Text Formatting Commands 15.png

\g(text)

Format text in Greek symbols.

\g(Greek)

Available Text Formatting Commands 8.png

\ab(text)

Display a bar above text.

\ab(X)

Available Text Formatting Commands 9.png

\ad(text)

Display a short line - a dot - above text.

\ad(A)

Available Text Formatting Commands 10.png

\at(text)

Display a tilde above text.

\at(A)

Available Text Formatting Commands 11.png

\(ASCII character code)

Displays the specified ASCII symbol.

\(169)

Available Text Formatting Commands 12.png

\y(')
\y(")

Displays a full height prime or a full height double prime. To display it as a combining prime/double prime, use superscript like \+(\y(')) or \+(\y(")).

\g(c)\=(3,\y('))

Available Text Formatting Commands 12b.png

\f:fontname(text)

Displays text using the fontname font. You can abbreviate fontname, as long as you use enough letters for the name to be unique.

\f:Wide Latin(font)

Available Text Formatting Commands 13.png

\cnumber(text)

Displays text in the color located at position number in the Color drop-down lists.

\c2(red)

Available Text Formatting Commands 14.png

\q(text)

Render the text (LaTeX markup) as a LaTeX object.
Notes: Require installing the 2017 LaTeX App

\q(\varphi_{\mu, \sigma^{2}}(X))

Available Text Formatting Commands 16.png

Note: The \g( ) text formatting command uses the Symbol font by default, but it can be made to use other font sets by modifying the selection in the Greek drop-down list on the Text Fonts tab of the Options dialog box (Tools: Options).

To use Greek symbols you must have the TrueType "Symbol" font in your printer, or have font generation software (for example, Adobe Type Manager).

A note on entering the backslash "\" character in text labels

When you are creating/editing a text label using the standard WYSIWYG methods, you can directly enter the backslash character into the label. It will not be interpreted as an escape sequence.

So, for instance, to type...

This file is located at C:\MY FILES

...you simply type the text, just as it reads, into the text label.

Note that Origin handles WYSIWYG insertion of the backslash by automatically inserting a second backslash character into your text string in a "behind the scenes" fashion. When in WYSIWYG mode, you see only a single backslash character. However, opening the object's Properties dialog box, will show that a second backslash character (see the picture below) has been added (Do not remove the second backslash character in this dialog box as this will break the text label, as explained below).

Escape Sequences 2.png

Use of the backslash "\" character in the Object Properties dialog box

A backslash character ("\") entered directly into the Object Properties dialog box is interpreted as an escape sequence.

For example, if you type the following in the Object Properties dialog box:

This file is located at C:\MY FILES

Origin displays:

This file is located at C:MY FILES

Note that the backslash doesn't display. If an unsupported option or no parenthesis follows the backslash character, then the backslash character is ignored and does not display. Therefore, if entering or editing text in the Object Properties dialog box, you must do one of the following if you require display of the backslash character:

  • Enter a double backslash \\ into the string (example: "This file is located at C:\\MY FILES").
  • Use the \v( ) escape sequence (example: "This file is located at \v(C:\MY FILES)").

There is yet a third method for displaying a backslash character in a label created using the Object Properties dialog box:

  1. Enter text in the Object Properties dialog box literally (entering only a single "\" character (see the picture below) -- not the double "\\"), then click OK.
    Escape Sequences 03.png
  2. Open the Command Window and enter the following at the command line:
ObjectName.verbatim=1 <ENTER>
Where ObjectName is the Object Name (as it appears in the Programming Control dialog box).

The backslash character now displays properly in your text label.

Note: The ObjectName.verbatim method is also useful when performing similar actions (inserting file path information via string variables) using the WYSIWYG text editing methods. While the WYSIWYG methods support direct entry of the backslash "\" character, backslashes are not properly handled when they are part of a string (as, for instance, a file path).

For an example of how this is handled in a text object created using WYSIWYG methods, see Linking Text Objects to Data and Variables.

A note concerning escape sequences and graph Themes

Graph Themes allow you to copy the properties of one text object and paste them to another text object. However, there are some properties of text objects which cannot be copied and pasted. If the text object property is created by inserting an escape sequence into the text object, it cannot not be applied to another text object.

To understand which text formatting options cannot be pasted to other text objects, you can begin by creating a text object and selecting it with a single mouse click. Here, you see that some Format and Style toolbar buttons -- Bold, Italic, Underline, etc. -- are not available (the buttons are grayed out), whereas others -- Greek, Increase Font/Decrease Font, Font Color, etc. -- are available.

Escape Sequences 04.png

Those buttons and drop-down lists that are not available when the text object is selected, require an escape sequence to create the format option and it is these format options which are not carried over when copying a format and pasting it to another text object.

 

© OriginLab Corporation. All rights reserved.