4.0

4.0 | 2 ratings Rate this file 32 downloads (last 30 days) File Size: 1.68 KB File ID: #5442

untexlabel

by Giuseppe RidinĂ²

 

08 Jul 2004 (Updated 12 Jul 2004)

Build a string which used with a TeX interpreter shows exactly the string as it is ...

Download Now | Watch this File

File Information
Description

This function is useful to create a string label which use a Tex interpreter and avoid that character as "_" or "^" or "/" are iterpreted as Tex commands.  
 
Example:  
MYSTR = 'mydir\bfx_0.dat';  
 
If you use MYSTR in a text object with the Tex interpreter activated, it will show something unexpected because "\bf" and "_" will be considered as Tex commands and will produce the relative output on the screen (see text function help for details).  
 
If you use untexlabel(MYSTR) in the text object, than the string will be shown exactly as it is.  
Furthermore you could use, for example, ['\bf',untexlabel(MYSTR)] as text string to show it all as bold font.

MATLAB release MATLAB 6.1 (R12.1)
Zip File Content  
Other Files Discalmer.txt,
ReadMe.txt,
untexlabel.m
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (5)
12 Jul 2004 Matthew Simoneau Another alternative is to turn off the TeX interpreter like this:  
 
>> text(.5,.5,'D:\Work\foo','Interpreter','none')  
 
or  
 
title('D:\Work\foo','Interpreter','none')
13 Jul 2004 Giuseppe RidinĂ² Try this:  
 
  file = 'file_0_1';  
  CreateStruct.WindowStyle='non-modal';  
  CreateStruct.Interpreter='tex';  
  msgbox(['File ',file,' not found!'],'warning','warn',CreateStruct)  
  msgbox(['File \bf',file,'\rm not found!'],'warning','warn',CreateStruct)  
  msgbox(['File \bf',untexlabel(file),'\rm not found!'],'warning','warn',CreateStruct)  
 
You may note the difference among the 3 cases.
14 Nov 2005 V L Setting the default interpreter to 'none' can only be done for a few set of text objects, ie the axes labels and the axes' title. For example, legend and annotation texts cannot be set by this method, thus we are forced to use this fonction to do "as if" the interpreter is none.
14 Nov 2005 V L By setting the default interpreter, I mean set the default value for a property using the command :  
 
set(0,'DefaulttextInterpreter','none')  
 
This don't work for legends and annotation (perhaps others? I think for all objects that are inside axes)
19 Nov 2008 Chad Webb This utility works as advertised - as mentioned, only a select few text objects have the "Interpreter" property available, and this solves the case where that property is not available - I used it to properly display the underscores in a "waitbar" message. Nice work!
Please login to add a comment or rating.

Public Submission Policy

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.

Contact us at files@mathworks.com