Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

MATLAB has the ability to "publish" code as an html document. It can include math by taking equations keyed in LaTeX notation, processing it with latex and embedding a bitmap image into the html. An example MATLAB file would be

%%
% With this equation, $x(t) = y(t)$, MATLAB only processes the math with LaTeX
%

running the MATLAB publish function would essentially internally convert this to

\documentclass{article}
\begin{document}
$x(t) = y(t)$
\end{document}

although everything may be enclosed in an \hbox. I can't really follow all the details of the MATLAB code as some of it is closed source.

\begin{edit} One potentially important piece of information I just found is that the MATLAB version of the article class has \input{size1\@ptsize.clo} commented out with the following comment

%% The following line causes the HG text to offset vertically and horizontally.

Apparently the good people at the Mathworks don't understand how to deal with LaTeX margins. Needless to say, this is why commands like \large don't work even when stuck in an \hbox. \end{edit}

The problem appears to be that MATLAB only processes the math with LaTeX. In how to scale math font only, you appear to need to be outside the math environment to change the font size. Is it possible to change the math font size from within the math environment? I think the MATLAB parser decides when to start and stop processing with latex based on $'s. Maybe there is some other way to exit mathmode.

share|improve this question
    
Did you try $\hbox{<font scaling command>$...$}$? –  Hendrik Vogt Jan 28 '13 at 12:48
    
Commands such as \tiny,\huge,etc should also work within the equation environment. However I don't think they work within the $$ environment. I'm not sure there is a way to do this in latex. But it seems there is a hack in matlab that will allow you to rescale: mathworks.de/matlabcentral/newsreader/view_thread/102987 –  myrtille Jan 28 '13 at 12:55
    
@HendrikVogt That approach doesn't work. What happens is that MATLAB essentially creates two tex files. The first containing $\hbox{<font scaling command>$ and the second with $}$. I was trying to express that problem with the last two sentences of the question. –  StrongBad Jan 28 '13 at 13:01
1  
@myrtille I don't think traditional font resizing (i.e., \huge) works in math mode. I am trying to avoid hacking the MATLAB script –  StrongBad Jan 28 '13 at 13:03
    
@DanielE.Shub It works inside the equation-environment, but not inside the $$ is what my test showed. Which is what I meant to say in my previous post. Sorry for the confsion –  myrtille Jan 28 '13 at 13:24
show 3 more comments

1 Answer

up vote 7 down vote accepted
+500

I can't quite see what matlab is doing less latex works than I would expect, however this sort of works to make the first expression larger:

So after a bit of trial and error and discussion in comments most of latex is enabled but you need to switch out of math mode, use a lower level font size change such as \fontsize{20}{25}\selectfont for 20pt font, and then switch back into math mode using \( not $ so as not to confuse matlab's scan for math fragments.

enter image description here

%%
% With this equation, 
% 
% MATLAB only processes the math with LaTeX

% $$e^{\pi i} + 1 = 0$$
% 
%
%%
% With this equation, $\hbox{\fontsize{20}{25}\selectfont\(z(t) = w(t)\)}$, MATLAB only processes the math with LaTeX
%
share|improve this answer
2  
I think I found a reason MATLAB is doing less LaTeX then you expected. The MATLAB class is mwarticle.cls and it is essentially the same as article.cls, except they do not load \input{size1\@ptsize.clo} so no size commands work. The comment in the code suggests they did this because they didn't understand the margins and not to prevent the sizing. –  StrongBad Jan 28 '13 at 20:55
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.