\documentclass[11pt]{article}
\usepackage{minted}
\usepackage{fontspec}
\defaultfontfeatures[CalibriLight]{
Extension = .TTF ,
UprightFont = fonts/Calibri-Light ,
ItalicFont = fonts/Calibri-Light-Italic ,
BoldFont = fonts/Calibri-Light-Bold ,
BoldItalicFont = fonts/Calibri-Light-Bold-Italic
}
\defaultfontfeatures[Calibri]{
Extension = .TTF ,
UprightFont = fonts/Calibri-Light-Bold ,
ItalicFont = fonts/Calibri-Light-Bold-Italic ,
BoldFont = fonts/Calibri-Bold ,
BoldItalicFont = fonts/Calibri-Bold-Italic
}
\newfontfamily{\calibri}[Scale=1.2]{Calibri}
\setsansfont[Scale=1.2]{CalibriLight}
\setminted[matlab]{linenos=true, frame=single, framesep=5pt, fontsize=10pt}
\begin{document}
\inputminted{matlab}{file.m}
\end{document}
我只保留了与我的问题相关的部分源代码,我创建了自定义字体,因为我需要使用 Calibri 作为报告部分/小节标题。
上面的源代码给出了错误,但如果我将字体大小设置为 \small 之类的值而不是 10pt 这样的值,它就可以正常工作。
这些是 file.m 的内容:
clear 'all' clc load foobar; soundsc(foobar1, 8000); %soundsc(foobar1, 4000); %soundsc(foobar1, 2000);
这是我得到的错误:
! LaTeX Error: Something's wrong--perhaps a missing \item.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.8 \end{Verbatim}
Try typing <return> to proceed.
If that doesn't work, type X <return> to quit.
! LaTeX Error: Something's wrong--perhaps a missing \item.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.8 \end{Verbatim}
Try typing <return> to proceed.
If that doesn't work, type X <return> to quit.
)
Overfull \hbox (38.29774pt too wide) in paragraph at lines 1--28
[]\TU/lmr/m/n/10.95 10pt[][][]
[]
[1
] (test.aux) )
行号将与我上面提供的源相匹配,正如我之前提到的,只需将字体大小更改为 \small 而不是 10pt 即可解决问题,但这并不能达到我的要求。
在此先感谢您的帮助。
答案1
你误用了\defaultfontfeatures
:
\newfontfamily{\calibrilight}{Calibri-Light}[
Extension = .TTF,
Path = ./fonts/,
Scale = 1.2,
UprightFont = *,
ItalicFont = *-Italic,
BoldFont = *-Bold,
BoldItalicFont = *-Bold-Italic,
]
\setsansfont{Calibri}[
Extension = .TTF,
Path = ./fonts/,
Scale = 1.2,
UprightFont = *-Light-Bold,
ItalicFont = *-Light-Bold-Italic,
BoldFont = *-Bold,
BoldItalicFont = *-Bold-Italic,
]
完整示例(但使用 ClearSans 因为我没有 Calibri);调整字体名称以适合您。
\begin{filecontents*}{\jobname.m}
clear 'all'
clc
load foobar;
soundsc(foobar1, 8000);
%soundsc(foobar1, 4000);
%soundsc(foobar1, 2000);
\end{filecontents*}
\documentclass[11pt]{scrartcl}
\usepackage{minted}
\usepackage{fontspec}
\usepackage{lipsum}
\newfontfamily{\calibrilight}{ClearSans}[
% Extension = .TTF,
% Path = ./fonts/,
Scale = 1.2,
UprightFont = *,
ItalicFont = *-Italic,
BoldFont = *-Bold,
BoldItalicFont = *-BoldItalic,
]
\setsansfont{ClearSans}[
% Extension = .TTF,
% Path = ./fonts/,
Scale = 1.2,
UprightFont = *-Medium,
ItalicFont = *-MediumItalic,
BoldFont = *-Bold,
BoldItalicFont = *-BoldItalic,
]
\setminted[matlab]{linenos=true, frame=single, framesep=5pt, fontsize=\small}
\begin{document}
\section{This is in ClearSans}
\lipsum[1]
Normal sans: {\sffamily Whatever \textbf{bold}}
Light sans: {\calibrilight Whatever \textbf{bold}}
\inputminted{matlab}{\jobname.m}
\end{document}