Publishing Latex equations in MATLAB comments
58 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
MathWorks Support Team
il 9 Apr 2015
Modificato: MathWorks Support Team
il 3 Mar 2021
%
% $2+2 = 4$
When publishing an M file to HTML, how do I include Latex declarations in my MATLAB code so that equations are formatted nicely in HTML?
Risposta accettata
MathWorks Support Team
il 3 Mar 2021
Modificato: MathWorks Support Team
il 3 Mar 2021
When publishing MATLAB code to HTML, one can nicely format equations by declaring them in Latex written into the MATLAB code's comments. There are certain formatting restrictions that need to be observed in order for MATLAB to interpret the Latex correctly:
1. The Latex definitions must be in a comment directly below a code section delimiter (i.e. a "%%").
CORRECT:
%%
% $2 + 2 = 4$
INCORRECT:
%
% $2+2 = 4$
2. The Latex code, if declared inline with a sentence, must be placed between single dollar signs (corresponding with Latex math mode declarations).
%%
% Latex makes this equation pretty: $a^2 + b^2 = c^2$
3. Latex code can be declared in blocks, which are delimited by double dollar signs (i.e. "$$"). Latex that is output on its own line must be alone on a separate comment line and have one empty comment line above it.
%%
% $$a^2 +
% b^2 = c^2$$
OR
%%
% This is a block of latex that will be output on its own line:
%
% $$a^2 + b^2 = c^2$$
4. All Latex code that is placed on its own line must have only one space between the MATLAB comment sign (i.e. "%") and the dollar sign that signals the beginning of the Latex definition.
CORRECT:
%%
% $a^2 = b^2 + c^2$
INCORRECT:
%%
% $a^2 = b^2 + c^2$
For further information on Latex equations in MATLAB publishing, refer to the following documentation:
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su MATLAB Report Generator in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!