How to bold, italics sentence using fprintf in matlab?
333 次查看(过去 30 天)
显示 更早的评论
How to bold , italics sentence using fprintf in matlab
0 个评论
采纳的回答
Walter Roberson
2011-12-1
There is no mechanism for that, just as there is no mechanism for color or underlining or blinking.
fprintf() is for transferring characters, and characters do not have inherent attributes or font properties.
Having said that: some output destinations interpret the characters they receive, and do so in such a way that character or font information can be attached.
See http://blogs.mathworks.com/desktop/2009/05/25/colorizing-text-output/ and http://www.mathworks.com/matlabcentral/fileexchange/24093
The above are for output to the command window. If you happen to be outputting to a terminal emulator (e.g., if you are running matlab -nodesktop) then you may be able to take advantage of the ANSI sequences for text attributes: http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
更多回答(1 个)
Ryan Friedman
2019-5-1
You can print bold only (not italics) using fprinf as shown below.
fprintf('Hello <strong> bold </strong> world.\n')
>> Hello bold world.
8 个评论
Steven
2023-11-24
Works nicely in the MATLAB console window (R2023b)
Unfortunatly when using publish() to create a pdf or html document the same example apears as 'Hello <strong> bold </strong> world.' in the document.
Victoria Serrano
2024-1-30
I'm having the same issue when using publish() to create the PDF. Has anyone found the solution?
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Migrate GUIDE Apps 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!