giving inline latex same baseline as text

10 views (last 30 days)
Chuck
Chuck on 2 Mar 2025
Edited: Chuck on 8 Mar 2025
In my comment I'm explaining that my signal is represented by e^-jwt (and in latex ) now in this text you can see that the word 'latex' and the expression have the same baseline, but when I run it in 'Publish' I get this:
As you can see the LaTeX code appears like a superscript vs having the same baseline as my other text. What am I doing wrong?

Answers (2)

Umeshraja
Umeshraja on 5 Mar 2025
Hi @Chuck,
I understand you are encountering an alignment issue when publishing inline comments containing expressions like (e^{-j\omega t} ). To address this, consider using the LaTeX syntax ( e^{-j\omega t} ) instead of writing out "exp." Additionally, ensure that you enclose your inline LaTeX expressions within single dollar signs ($) as demonstrated below:
%
% This is an inline expression: $e^{-j\omega t}$.
%
Alternatively, could use HTML markup for better control over text alignment as shown below
% <html>This is an expression: <i>e<sup>-j&omega;t</sup></i>.</html>
To know more, please refer to the following documentation on LaTex Equations in Publishing Markup
Hope this helps!
  5 Comments
Umeshraja
Umeshraja on 5 Mar 2025
Hi @Chuck,
Removing parentheses looks much better as shown below
%% Demonstrate the Bug
%
% This is a bug (well it demonstrates the bug)
%
% the following expression, $e^{-j{\omega}t}$, is a phasor
% As you can see $\cos {\omega t} + \sin {\omega}t$ from
% the screen shot it isn't aligned correctly
% when the comment is published.
%
Chuck
Chuck on 5 Mar 2025
It seems to change the baseline a bit but removing the parenthsis from sin and cos makes writing something that is mathematically comprehensible difficult 😃. In the bug code there is but one parameter but in my code there is another parameters so it would be which here, in this comment looks great so obviously Mathworks knows how to make this work, what I'm trying to figure out it why it doesn't work in MATLAB?

Sign in to comment.


Umeshraja
Umeshraja on 7 Mar 2025
Hi @Chuck,
A potential workaround for your issue is to use the Live Editor (.mlx) instead of a plain script (.m). You can then export it as a PDF, which should help avoid the unusual behavior you're experiencing. I've attached a screenshot for reference, where you can see the expected output.
For more information, you might find this MATLAB Answers post helpful:
  1 Comment
Chuck
Chuck on 8 Mar 2025
Edited: Chuck on 8 Mar 2025
I appreciate you trying to help, I really do. As an experiment I downloaded and installed MathJax. MathJax is a package that allows you to put inline LaTeX and display LaTeX equations into your web pages (or PDF documents). If I take the .html file that was "generated" by MATLAB (it ends up in the HTML folder), include the mathjax script callout and change the inline math delimiters to \( and \) (note that Mathjax can be configured to recognize the dollar signs but I was keeping changes to a minimum here.) and replace the callout to the badly generated png image. The image below shows how that renders in a browser window.
All of the math is precisely aligned with the text baseline and easy to read. If someone from Mathworks reads this, Mathjax has an Apache license you can use it in your product and it will both fix this bug and it will make your product more useful. I have attached and uploaded the changed html file (as a .txt file because it won't let me upload html directly).
But between you and I this is just a MATLAB bug that needs fixing. I don't believe Mathworks has a workaround for this bug at this time so this question will remain unanswered.

Sign in to comment.

Products


Release

R2024b

Community Treasure Hunt

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

Start Hunting!