使用 ttfamily 的数字

使用 ttfamily 的数字

我喜欢的线条人物\ttfamily

我想在数学模式中使用它们,作为方程编号和在 tikzpicutres 中使用它们。

关于数学模式,我使用amsmath,可以在将数字输入 时以我想要的方式显示数字\texttt{123546789},但这是一个累人的解决方案。 也一样$...$

放置这样的 tikzpicture 时:

\begin{figure}
\ttfamily
\input{test.tikz}}
\end{figure}

轴的编号样式不会改变。

这是一个最小的工作示例:

\documentclass{scrbook}
\usepackage{pgfplots} %for tikzpictures:
\usepackage{amsmath}
\usepackage[osf,sc]{mathpazo} %the font I use

\begin{document}
In math-mode:
\begin{align}
U=123456890\\ 
U=\texttt{123456890}\\
U=\mathtt{123456890}
\end{align}
The default figure style should be like in equation 0.2 and 0.3. 
\\
The equation numbering on the right side should be in this style: \texttt{(0.1)} \texttt{(0.2)} \texttt{(0.3)}
\\
Same with dollarsign-enviorment, the latter 2 should be default: 
$U=123456890$ $U=\texttt{123456890}$ $U=\mathtt{123456890}$
\begin{figure}
\ttfamily %makes only the labeling in \ttfamily, but I want labeling and numbering
\begin{tikzpicture}
\begin{axis}[%
width=10cm,
height=10cm,
scale only axis,
xmin=0,
xmax=10,
xlabel={4 5 6},
ymin=0,
ymax=20,
ylabel={8 10 12},
axis x line*=bottom,
axis y line*=left,
]
\end{axis}
\end{tikzpicture}%
\end{figure}
\end{document}

答案1

我觉得这很奇怪(更不用说丑陋了);但这份文件是你的。我希望当你看到结果时,你会改变主意。

\documentclass{scrbook}
\usepackage{pgfplots} %for tikzpictures:
\usepackage{amsmath}
\usepackage[osf,sc]{mathpazo} %the font I use

\sbox0{$\mathtt{\xdef\mathttfam{\the\fam}}$}
\newcommand\dottnumber[1]{%
  \mathcode`#1=\numexpr\mathcode`#1-"7000+"\mathttfam00\relax
}
\dottnumber{0}\dottnumber{1}\dottnumber{2}\dottnumber{3}\dottnumber{4}%
\dottnumber{5}\dottnumber{6}\dottnumber{7}\dottnumber{8}\dottnumber{9}%
\makeatletter
\renewcommand\tagform@[1]{\maketag@@@{($#1$)}}
\makeatother


\begin{document}
In math-mode:
\begin{align}
U=123456890\\ 
U=\texttt{123456890}\\
U=\mathtt{123456890}
\end{align}
The default figure style should be like in equation 0.2 and 0.3. 
\\
The equation numbering on the right side should be in this style: \texttt{(0.1)} \texttt{(0.2)} \texttt{(0.3)}
\\
Same with dollarsign-enviorment, the latter 2 should be default: 
$U=123456890$ $U=\texttt{123456890}$ $U=\mathtt{123456890}$
\begin{figure}
\ttfamily %makes only the labeling in \ttfamily, but I want labeling and numbering
\begin{tikzpicture}
\begin{axis}[
width=10cm,
height=10cm,
scale only axis,
xmin=0,
xmax=10,
xlabel={4 5 6},
ymin=0,
ymax=20,
ylabel={8 10 12},
axis x line*=bottom,
axis y line*=left,
]
\end{axis}
\end{tikzpicture}
\end{figure}
\end{document}

在此处输入图片描述

如果你真的想将 Courier 与 Palatino 一起使用,我没有足够的勇气展示这个组合的图片,请在以 开头的行前添加\sbox0

\usepackage{courier}
\DeclareMathAlphabet{\mathtt}{OT1}{\ttdefault}{m}{n}
\SetMathAlphabet{\mathtt}{bold}{OT1}{\ttdefault}{b}{n}

\eqref如果您希望引用方程式编号,请记住使用打字机字体。

请不要让你的读者遭受这种痛苦

相关内容