lateximage
LaTeX support provided by the MATLAB Graphics engine is limited at a time, especially to add complex equations on a figure. lateximage creates an image object which behaves like a text object with full LaTeX support.
To create a LaTeX equation, simply call lateximage like 'text' function call, e.g.,
h = lateximage(0.5,0.5,'\boldsymbol{\xi} + \boldsymbol{\zeta}') % built-in interpreter cannot handle \boldsymbol
Included lateximage_demo.m illustrates a more elaborate usage.
Main Features:
* Supports many of the standard Text Properties: Position, String, FontSize, FontSmoothing, HorizontalAlignment, VerticalAlignment, Rotation, Color, BackgroundColor, EdgeColor, and LineWidth
* By default, LaTeX string is assumed to be in the equation mode. To create a regular LaTeX text, set EquationOnly option to false
* Auto-scales the image object to maintain the FontSize via actively listening to the axes size and limit PostSet events
* Exposing full LaTeX support with "standalone" document class: fully customizable document class options, LaTeX packages, document preamble, and document body text
* Print-ready. Text will appear correctly both on screen and on paper (or image). Printed text resolution can be increased via OverSamplingFactor option.
Usage Notes:
* Supports both HG2 (r2014b and later) and pre-HG2 Matlab versions
* Right before print/export the figure with lateximage objects, run 'lateximage -printmode on' so that the lateximage objects are properly scaled during print operation.
* This function should only be used if the built-in LaTeX interpreter *cannot* interpret the desired LaTeX string. The built-in interpreter (with a text object) results in a better image output than the image-based solutions, including this submission.
* In R2014b and later, experiment with OverSamplingRate setting for better output, especially for EPS output. >=20 seems to produce better, acceptable results.
* For onscreen usage, keep OverSamplingRate = 1 for the best appearance
Requirements:
* latex and dvipng executable must be available via system path. For Windows systems, simply installing MikTeX would take care of it
TODOs:
* Margin option is not functional yet. dvipng squashes the specified margin in LaTeX file. If anyone knows how to work around this, shoot me a message. The goal of this function is keep external dependency to those in LaTeX distribution only
* Apply OverSamplingRate only when -printmode is on
* <strike>Further investigate a way to listen to the events during print to make scaling more reliable</strike> It appears to be working with a mysterious scaling factor of 2
引用格式
Kesh Ikuma (2024). lateximage (https://www.mathworks.com/matlabcentral/fileexchange/53474-lateximage), MATLAB Central File Exchange. 检索时间: .
MATLAB 版本兼容性
平台兼容性
Windows macOS Linux类别
- MATLAB > Graphics > Graphics Objects > Graphics Object Properties >
- MATLAB > Graphics > Graphics Objects > Graphics Object Programming >
标签
致谢
启发作品: Hatchfill2
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!版本 | 已发布 | 发行说明 | |
---|---|---|---|
1.2.3.0 | (r6)
|
||
1.2.2.0 | (r5)
|
||
1.2.1.0 | (v1.2.1) * Bug fix: listening to Axes' XLim change |
||
1.2.0.0 | v1.2 - Improved print output scaling |
||
1.1.0.0 | * Added demo script
|
||
1.0.1.0 | * Fixed a bug for pre-r2014b
|
||
1.0.0.0 |