1

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=\mlttfamily\footnotesize]
    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?

1
  • I believe the font family fvm corresponds to the font BeraMono. I tried installing it as described here. Unfortunately I still get the warning TU/fvm/m/n can't be found.
    – Nukesub
    Commented Jan 10, 2021 at 20:07

1 Answer 1

1

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}\ttfamily\normalsize,
  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}\ttfamily\footnotesize]
    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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .