需要有关font和siunitx问题的帮助?

时间:2022-08-26 12:02:35

I don't really understand anything about fonts, as much as I have tried to read about them. I ultimately just wanted a font that kinda looked like it was written in a typewriter style, which also had clear math symbols to read. I found an example somewhere here on the stackexchange (see link below), used pdflatex to compile it, I thought it looked ok. But some of the math fonts, when using siunitx look squashed in the inline math mode.

我对字体一无所知,就像我试图阅读它们一样。我最终只想要一种看起来像是用打字机风格编写的字体,它也有清晰的数学符号可供阅读。我在stackexchange上找到了一个例子(见下面的链接),用pdflatex编译它,我认为它看起来不错。但是一些数学字体在使用siunitx时看起来在内联数学模式中被压扁了。

My minimum working example is this:

我的最低工作范例是:

\documentclass[a4paper,openany]{book}

\usepackage[variablett]{lmodern}  % line 2  
\renewcommand*\familydefault{\ttdefault} % line 3
\usepackage{siunitx}

\sisetup{
    detect-all = true,
    detect-inline-family = text,
    detect-inline-weight = text
}

\begin{document}

\noindent normal text: [\SI{5}{\milli\meter\squared}] \\ 
inline math mode: $[\SI{5}{\milli\meter\squared}]$ \\
mm 

\end{document}

If I just use the default fonts, i.e. remove line 2 and 3, then use siunitx, the "mm" looks like the same font as the text.

如果我只使用默认字体,即删除第2行和第3行,然后使用siunitx,“mm”看起来就像文本一样。

Can anyone help me prevent the text getting squashed like this, or suggest an alternative font that won't have this issue?

任何人都可以帮我阻止文本像这样被压扁,或建议一个不会有这个问题的替代字体?

Link: \textbf does not work with cmvtt style

链接:\ textbf不适用于cmvtt样式

EDIT: I edited the MWE with \sisetup but was not able to fix the issue.

编辑:我用\ sisetup编辑了MWE,但无法解决问题。

1 个解决方案

#1


2  

One option is to turn off automatic detection of the mode, and specify siunitx to always use text mode, which will use \texttt instead of \mathtt (which is the squished up one).

一种选择是关闭模式的自动检测,并指定siunitx始终使用文本模式,这将使用\ texttt而不是\ mathtt(这是压扁的)。

需要有关font和siunitx问题的帮助?

\documentclass[a4paper,openany]{book}

\usepackage[variablett]{lmodern}  % line 2  
\renewcommand*\familydefault{\ttdefault} % line 3
\usepackage{siunitx}

\sisetup{
    detect-mode=false,
    mode=text,
}

\begin{document}

    \noindent 
    normal text: [\SI{5}{\milli\meter\squared}] \\ 
    inline math mode: $[\SI{5}{\milli\meter\squared}]$ \\
    mm \\
    $\mathtt{mm}$

\end{document}

#1


2  

One option is to turn off automatic detection of the mode, and specify siunitx to always use text mode, which will use \texttt instead of \mathtt (which is the squished up one).

一种选择是关闭模式的自动检测,并指定siunitx始终使用文本模式,这将使用\ texttt而不是\ mathtt(这是压扁的)。

需要有关font和siunitx问题的帮助?

\documentclass[a4paper,openany]{book}

\usepackage[variablett]{lmodern}  % line 2  
\renewcommand*\familydefault{\ttdefault} % line 3
\usepackage{siunitx}

\sisetup{
    detect-mode=false,
    mode=text,
}

\begin{document}

    \noindent 
    normal text: [\SI{5}{\milli\meter\squared}] \\ 
    inline math mode: $[\SI{5}{\milli\meter\squared}]$ \\
    mm \\
    $\mathtt{mm}$

\end{document}