我搜索了如何在 LaTex 上创建 Julia 的代码,然后我成立 非常 好的 参考。但是,当代码中有粗体字母时,它无法正确编译,例如,
\documentclass{article}
\usepackage{minted}
\usepackage{fontspec}
\usepackage{polyglossia}
\usepackage{unicode-math}
\usepackage{xunicode}
\setmonofont{FreeMono} %switched to FreeMono
\begin{document}
\begin{minted}[breaklines,escapeinside=||,mathescape=true, linenos, numbersep=3pt, gobble=2, frame=lines, fontsize=\small, framesep=2mm]{julia}
using Convex, SCS, Plots, LaTeXStrings
N = 30 # N in the set {0, 1, ..., N}
n = 3 # order of the linear dynamical system
x_des = [7, 2, -6] # constraint ->
答案1
您需要一种带有 Unicode 数学字母的字体。我在这里使用 Stix Two Math。最简单的方法是直接使用它,就像这里一样,并放弃等宽字体。原则上,您可以制作一个 Lua 虚拟字体,强制等宽字体和/或为 ascii 范围使用不同的等宽字体。
\documentclass{article}
\usepackage{fontspec}
%\usepackage{polyglossia}
\usepackage{unicode-math}
\newfontfamily\stm{StixTwoMath}[NFSSFamily=stm]
\usepackage{minted}
%\usepackage{xunicode}
\setmonofont{FreeMono} %switched to FreeMono
\begin{document}
\begin{minted}[breaklines,escapeinside=||,mathescape=true, linenos, numbersep=3pt, gobble=2, frame=lines, fontsize=\small, fontfamily=stm, framesep=2mm]{julia}
using Convex, SCS, Plots, LaTeXStrings
N = 30 # N in the set {0, 1, ..., N}
n = 3 # order of the linear dynamical system
x_des = [7, 2, -6] # constraint ->
答案2
补充信息:您还可以使用本网站帮助您查看带有数学符号的字体。例如,我将在此处使用 JuliaMono 字体放置代码
\documentclass{article}
\usepackage{fontspec}
% \usepackage{unicode-math}
% \usepackage[utf8]{inputenc}
\usepackage{minted}
\newfontfamily \JuliaMono {JuliaMono-Regular.ttf}[
Path = /home/tapyu/.local/share/fonts/juliamono/,
Extension = .ttf
]
\newfontface \JuliaMonoRegular{JuliaMono-Regular}
\setmonofont{JuliaMonoRegular}[
Contextuals=Alternate
]
\begin{document}
\begin{minted}[breaklines,escapeinside=||,mathescape=true, linenos, numbersep=3pt, gobble=2, frame=lines, fontsize=\small, framesep=2mm]{julia}
using Convex, SCS, Plots, LaTeXStrings
N = 30 # N in the set {0, 1, ..., N}
n = 3 # order of the linear dynamical system
x_des = [7, 2, -6] # constraint ->