![用例](https://linux22.com/image/464898/%E7%94%A8%E4%BE%8B.png)
我正在解释一些使用希腊字符的代码,大胆的,斜体和重音。
默认字体不区分大胆的且不粗体。
\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}
使用\usepackage[lighttt]{lmodern}
可以让我区分大胆的和非粗体,但斜体变得倾斜,而希腊则保持大胆。
我想要的是:
- 区分大胆的和非粗体,
- 有工作斜体,
- 使用非粗体希腊字母,如δ,并且
- 继续使用重音符号。
用例
我对书中的代码片段有这些要求。下面,你可以看到缺少斜体评论。另一种选择是缺乏大胆的对于 Python 关键字。
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}
答案1
您可以使用xfakebold
包裹。
\documentclass{minimal}
\usepackage[LGR,T1]{fontenc}
\DeclareSymbolFont{ttgreek}{LGR}{cmtt}{m}{n}
\DeclareMathSymbol{\ttdelta}{\mathord}{ttgreek}{`d}
\usepackage[bold=0.3]{xfakebold}
\begin{document}
\texttt{Writing some \setBold\textbf{bold}\unsetBold, \textit{italic}, Greek $\ttdelta$, and accents \(\mathtt{\tilde{y}}\).}
\end{document}
答案2
拉丁现代打字机似乎有你需要的形式
\documentclass{article}
\usepackage[LGR,T1]{fontenc}
\renewcommand\ttdefault{lmtt}
\DeclareSymbolFont{ttgreek}{LGR}{lmtt}{m}{n}
\DeclareMathSymbol{\ttdelta}{\mathord}{ttgreek}{`d}
\begin{document}
\texttt{Writing some \textbf{bold} and \emph{italic} and
Greek $\ttdelta$ and accents $\mathtt{\tilde{y}}$.}
\end{document}
答案3
如果您不受 pdflatex 的约束,则可以使用 lualatex 和 newcomputer 现代字体。(粗体不是很粗,但您可以加粗它,请参见粗斜体):
\documentclass{article}
\usepackage{fontspec}
\setmonofont{NewCMMono10-Regular.otf}%
[%
ItalicFont=NewCMMono10-BookItalic.otf,%
BoldFont=NewCMMono10-Bold.otf,%
%BoldFeatures={FakeBold=2}, %bolder?
BoldItalicFont=NewCMMono10-BoldOblique.otf,%
BoldItalicFeatures={FakeBold=2}
]
\begin{document}
\texttt{Writing some \textbf{bold} and \emph{italic} and \emph{\textbf{bold italic}}\\
and Greek δ and accent ỹ}
\end{document}