我使用 Julia 的最小代码示例
\documentclass{article}
\usepackage[cache=false]{minted}
\begin{document}
\inputminted{julia}{polynomial_regression.jl}
\end{document}
在
# Polynomial Features ϕ = [1,x,x²,x³,...,xⁿ]' of Degree n
ϕ(x,n) = (x' .^ collect(range(0, stop=n, length=(n+1))))';
function polynomial_regression(x,y,xq,n)
答案1
我能确定的最佳解决方案是手动定义所有缺失的字符
\DeclareUnicodeCharacter{3B4}{$\bm{\delta}$}
\DeclareUnicodeCharacter{3B8}{$\bm{\theta}$}
\DeclareUnicodeCharacter{3BB}{$\lambda$}
\DeclareUnicodeCharacter{3BC}{$\mu$}
\DeclareUnicodeCharacter{3BC}{$\pi$}
\DeclareUnicodeCharacter{3C3}{$\sigma$}
\DeclareUnicodeCharacter{3C0}{$\pi$}
\DeclareUnicodeCharacter{3D5}{$\bm{\phi}$}
直到不再显示错误。如果有人知道更优雅的方法,请添加!
答案2
在旧版工具链中
加载旧式文本编码用 来输入您需要的内容fontenc
,然后用 填充所有缺失的字符\newunicodechar
。
\documentclass{article}
\usepackage[LGR, T1]{fontenc}
\usepackage{textcomp}
\usepackage[utf8]{inputenc} % The default since 2018
\usepackage{lmodern, newunicodechar}
\usepackage[cache=false]{minted}
% To fit within the width allowed on TeX.SX:
\usepackage[paperwidth=10cm]{geometry}
% ϕ(U+03D5) is the math symbol with a vertical stroke. It is in OML.
\renewcommand\textphisymbol{\ensuremath{\mathtt{\phi}}}
\newunicodechar{ⁿ}{\textsuperscript{n}}
%
答案3
为了进行比较,以下是拉丁现代数学作为“单声道”字体产生的结果:
平均能量损失
\documentclass[12pt]{article}
\usepackage{minted}
%\usepackage{xcolor}
\usepackage{fontspec}
%\usepackage{newunicodechar}
\setmonofont{Latin Modern Math}
\begin{document}
\begin{minted}{Julia}
# Polynomial Features ϕ = [1,x,x²,x³,...,xⁿ]' of Degree n
ϕ(x,n) = (x' .^ collect(range(0, stop=n, length=(n+1))))';
function polynomial_regression(x,y,xq,n)