I'm explaining some code that uses Greek characters, bold, italic, and accents.
The default font does not differentiate between bold and non-bold.
\documentclass{minimal}
\usepackage[LGR,T1]{fontenc}
\DeclareSymbolFont{ttgreek}{LGR}{cmtt}{m}{n}
\DeclareMathSymbol{\ttdelta}{\mathord}{ttgreek}{`d}
\begin{document}
\texttt{Writing some \textbf{bold}, \emph{italic},
Greek $\ttdelta$, and accents $\mathtt{\tilde{y}}$.}
\end{document}
Using \usepackage[lighttt]{lmodern}
lets me distinguish between bold and non-bold, but the italic becomes slanted and the Greek keeps being bold.
What I want is:
- differentiate between bold and non-bold,
- have a working italic,
- use non-bold Greek letters like δ, and
- keep using accents.
Use case
I have these requirements for the code snippets in my book.
Below, you can see the lack of italic for the comments.
The alternative was a lack of bold for the Python keywords.
Then, we compute \(\Fi\) and \(\vzchk\) with the following algorithm.
\begin{CodeEnv}
\pydef dict_inference(net, \m\ce, \m\cc):
\m\vz0 = net.sample_latent() \mc{# initial guess, all zeros}
\m\vzchk = compute_\m\vzchk(\m\ce, \m\vz0)
t2 = net.top2(\m\vzchk) \mc{# get top-2 (t2) units}
\m\vzchk2 = compute_\m\vzchk(\m\cc, t2)
\m\cF = \m\ce(\m\vzchk2) \mc{# compute the free energy}
\pyreturn \m\cF, net.pad(\m\vzchk2)
\end{CodeEnv}
\begin{compactenum}
\item compute \(\vzchk\) by minimising \(\ce(\vz)\),
\item zero all but the two most active components of the code \(\vzchk\),
\item minimise \(\cc(\vz)\) wrt these two components,
\item evaluate and return \(\Fiy = \ce(\vzchk)\) and \(\vzchk\).
\end{compactenum}
Best Answer
You can use the
xfakebold
package.