lateximage

LaTeX image object for using LaTeX packges not supported by the builtin LaTeX text interpreter
411 téléchargements
Mise à jour 3 nov. 2015

Afficher la licence

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

Citation pour cette source

Kesh Ikuma (2024). lateximage (https://www.mathworks.com/matlabcentral/fileexchange/53474-lateximage), MATLAB Central File Exchange. Extrait(e) le .

Compatibilité avec les versions de MATLAB
Créé avec R2015a
Compatible avec toutes les versions
Plateformes compatibles
Windows macOS Linux
Catégories
En savoir plus sur Graphics Object Properties dans Help Center et MATLAB Answers
Remerciements

A inspiré : Hatchfill2

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Publié le Notes de version
1.2.3.0

(r6)
* Removed the nagging warning in R2015b for the use of 'feature('UseHG2')'

1.2.2.0

(r5)
* Hopefully this is the final fix for the printmode...

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
* Image's Clipping property is set to 'off' by default
* If LaTeX build failed, returns the auto-generated .tex file content
* Pre-HG2 enhancement: listening to figure size change
* Various bug fixes

1.0.1.0

* Fixed a bug for pre-r2014b
* Edited Description page

1.0.0.0