publishLaTeX
by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - Auxiliary function
Introduced first in SolidGeometry 2.1.1, Creation date: 2015-03-13, Last change: 2025-09-14
displays on screen a LaTeX formula
Description
This is an auxiliary function useful if the publish mode of Matlab is used. In this case it is possible to insert formulas in the documentation. Most probably MathWorks will integrate this feature soon by a more convenient principle.
Example Illustration
Syntax
publishLaTeX(str)
Input Parameter
str: | | String that contains the formula |
Examples
publishLaTeX ('$\displaystyle A_{i, j, k}^{-n+2} $')
publishLaTeX('$\displaystyle\frac{\alpha}{\pi}X$');
publishLaTeX('$\displaystyle\frac{\alpha}{\pi}X_{12345t}$');
Copyright 2015-2025 Tim C. Lueth. All rights reserved. The code is the property of Tim C. Lueth and may not be redistributed or modified without explicit written permission. This software may be used free of charge for academic research and teaching purposes only. Commercial use, redistribution, modification, or reverse engineering is strictly prohibited. Access to source code is restricted and granted only under specific agreements. For licensing inquiries or commercial use, please contact: Tim C. Lueth
Algorithm (Workflow)
This function, publishLaTeX, is designed to display a LaTeX formula on the screen using MATLAB's figure window. It is particularly useful when using MATLAB's publish mode to include formulas in documentation.
Input Parameters
- str: A string that contains the LaTeX formula to be displayed.
Algorithm Steps
- The function begins by closing all existing figure windows with
close all;.
- A new figure window is created and stored in variable
a. The axes are turned off, and the hold state is set to on.
- The menu bar and toolbar of the figure window are removed using
set (gcf,'MenuBar','none'); and set (gcf,'ToolBar','none');.
- Font size
fs is set to 16, and a height factor h is set to 2.
- The size of the figure window is defined with
xsize=500; and ysize=60;. The ysize is adjusted by multiplying h with fs.
- The position and size of the figure window are set using
set (gcf,'Position',[680 558 xsize ysize]);.
- A text object is created at position (0, 0.5-(1/h)/2) with the LaTeX string
str using text function. The text is interpreted as LaTeX and displayed with the specified font size fs.
This function is a simple utility to render LaTeX formulas in a MATLAB figure window, providing a visual representation of mathematical expressions.
Algorithm explaination created using ChatGPT on 2025-08-18 23:27. (Please note: No guarantee for the correctness of this explanation)
Last html export of this page out of FM database by TL: 2025-09-21