
Gibt es einen einfacheren Weg, anstatt diese Befehle zweimal zu schreiben?
\newfontfamily\codefont[
Scale=MatchLowercase,
Path = fonts/]
{Inconsolata-dz}
\setmonofont[
Scale=MatchLowercase,
Path = fonts/]
{Inconsolata-dz}
Ich habe so etwas \setmonofont{\codefont}
im Sinn, aber das scheint nicht zu funktionieren.
Antwort1
Ich bin nicht sicher, warum Sie das auf diese Weise tun möchten. Sie können jedoch einen NFSS-Familiennamen angeben, der folgendem entspricht \codefont
:
\newfontfamily\codefont[
NFSSFamily=Inconsolata,
Scale=MatchLowercase,
Path = fonts/
]{Inconsolata-dz}
\renewcommand{\ttdefault}{Inconsolata}
Vollständiger Test, bei dem ich Inconsolatazi4
die Path
Zeile verwendet und kommentiert habe.
\documentclass{article}
\usepackage{fontspec}
\newfontfamily\codefont[
NFSSFamily=Inconsolata,
Scale=MatchLowercase,
% Path = fonts/
]{Inconsolatazi4}
\renewcommand{\ttdefault}{Inconsolata}
\begin{document}
This should be Inconsolata: {\codefont Test of mono font}
This should be Inconsolata: \texttt{Test of mono font}
\end{document}
Antwort2
Sie können den Befehl in XeLaTeX verwenden \newfontfamily{}[]{}
und seine Syntax ist ähnlich wie\setmainfont
\documentclass{article}
\usepackage{fontspec}
\setmainfont[Extension=.ttf]{f1}
\newfontfamily{\myone}[Extension=.ttf]{f2}
\newfontfamily{\mytwo}[
BoldFont = f3_bold.ttf,
ItalicFont = f3_italic.ttf,
BoldItalicFont = f3_bold_italic.ttf
]{f3.ttf}
\begin{document}
fhsdfhhrth
{\myone gfhjjrjtyjsdjry}
{\mytwo dshthrsht\textbf{rjrtj} rtjjtrjjt \textit{dfhdhsrh} }
gthfrshtr
\end{document}