TransWikia.com

Matlab Prettifier Package Question

TeX - LaTeX Asked by Nukesub on February 6, 2021

I am having difficulties changing the font size of the matlab-prettifier package. Here is a MWE.
This works great if I am okay with the default font size. But it’s too big I think. I’d like to shrink it to something like footnotesize.

For reference, I am compiling with LuaLaTex.

documentclass{article}

% Preamble
% ===========================================
usepackage{fontspec} 
usepackage{amsmath}
usepackage{siunitx}
usepackage[numbered,framed]{matlab-prettifier}
usepackage{polyglossia}
setdefaultlanguage[variant=American]{english}
usepackage{unicode-math}

setmainfont{TeX Gyre Pagella}
setmathfont{TeX Gyre Pagella Math}

begin{document}
begin{lstlisting}[style=Matlab-editor]
    view([150 25])
    plot(t,sol(:,1))
    xlabel('Time')
    ylabel('Temperature u(0,t)')
    title('Temperature change at center of disc')
end{lstlisting}
end{document}

So I try do something like

begin{lstlisting}[basicstyle=mlttfamilyfootnotesize]
    view([150 25])
    plot(t,sol(:,1))
    xlabel('Time')
    ylabel('Temperature u(0,t)')
    title('Temperature change at center of disc')
end{lstlisting}

But it shows up as TeX Gyre Pagella (I think) and loses all syntax formatting. Definitely not the MATLAB editor font, like it shows when I use just style=Matlab-editor. I also get a warning saying Font shape `TU/fvm/m/n’ undefined. Maybe I am missing a font on my system?

One Answer

The source of matlab-prettifier has the following style definition as the 'base style' (starting at line 447, see the manual on page 34):

  language               = languageNormedDefd@mlpr,
  basicstyle             = color{black}ttfamilynormalsize,
  breaklines             = true,
  showspaces             = false,
  showstringspaces       = false,
  upquote                = true,
  rulecolor              = color{black!67},
  numberstyle            = color{black!33},
  mlscaleinline          = true,
  mlonlyheader           = false,

Adjusting the second line here results in smaller output:

documentclass{article}

% Preamble
% ===========================================
usepackage{fontspec} 
usepackage{amsmath}
usepackage{siunitx}
usepackage[numbered,framed]{matlab-prettifier}
usepackage{polyglossia}
setdefaultlanguage[variant=American]{english}
usepackage{unicode-math}

setmainfont{TeX Gyre Pagella}
setmathfont{TeX Gyre Pagella Math}

begin{document}
begin{lstlisting}[style=Matlab-editor,basicstyle=color{black}ttfamilyfootnotesize]
    view([150 25])
    plot(t,sol(:,1))
    xlabel('Time')
    ylabel('Temperature u(0,t)')
    title('Temperature change at center of disc')
end{lstlisting}
end{document}

enter image description here

Answered by Marijn on February 6, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP