从当前页面开始缩放 tt 字体

从当前页面开始缩放 tt 字体

我的目标是从文档中的某个位置开始缩小 tt 字体。我通过使用以下方法实现了此目标\fontsize{7pt}{11pt}\selectfont

\documentclass[parskip=half-]{scrreprt}
\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\usepackage[headsepline,plainheadsepline,manualmark]{scrlayer-scrpage}

\begin{document}

\section{Test}


This is a normal text. \large{Large text}

\ttfamily
This is a tt family text. \large{Large text}

\fontsize{7pt}{11pt}\selectfont
This is a tt family text. \large{Large text}

\end{document}

在此处输入图片描述

问题是它的\large大小仍然和以前一样。

我该如何扩展一切?

答案1

不确定这样做的动机是什么。无论如何……

\documentclass[parskip=half-]{scrreprt}
\usepackage[T1]{fontenc}
%\usepackage[utf8]{inputenc}
\usepackage{lmodern}

\usepackage[headsepline,plainheadsepline,manualmark]{scrlayer-scrpage}

\DeclareFontFamily{T1}{smallercmtt}{\hyphenchar\font-1 }
\DeclareFontShape{T1}{smallercmtt}{m}{n}{
        <-9>    s*[0.7] ectt0800
        <9-10>  s*[0.7] ectt0900
        <10-12> s*[0.7] ectt1000
        <12-17> s*[0.7] ectt1200
        <17->   s*[0.7] ectt1728
      }{}


\begin{document}

\section{Test}

This is a normal text. {\Large Large text}

\texttt{This is a tt family text. {\Large Large text}}

\renewcommand{\ttdefault}{smallercmtt}
\texttt{This is a tt family text. {\Large Large text}}

\end{document}

在此处输入图片描述

请注意\large,与其他大小改变命令一样,不接受参数,而是一个效果永久的声明(遵守标准作用域规则)。

在示例中我使用的\Large只是为了更好地显示尺寸的差异。

答案2

使用fontspecxelatex/lualatex 下的包和 TTF/OTF 字体,Scale=可以使用该选项:

缩放字体

平均能量损失

\documentclass[parskip=half-]{scrreprt}
%\usepackage[T1]{fontenc}
%\usepackage[utf8]{inputenc}
%\usepackage{lmodern}
\usepackage{fontspec}
\setmainfont{Noto Serif}
\setsansfont{Noto Sans}
\setmonofont{Noto Sans Mono}

\usepackage[headsepline,plainheadsepline,manualmark]{scrlayer-scrpage}


\begin{document}

\section{Test}
This is a normal text. {\Large Large text} {\tiny Tiny text}


\sffamily
This is a sf family text. {\Large Large text} {\tiny Tiny text}

\ttfamily
This is a tt family text. {\Large Large text} {\tiny Tiny text}


Scaled:
\setmainfont{Noto Serif}[Scale=0.4]
\setsansfont{Noto Sans}[Scale=0.4]
\setmonofont{Noto Sans Mono}[Scale=0.4]

\section{Scaled Test}

\rmfamily
This is a normal text. {\Large Large text} {\tiny Tiny text}


\sffamily
This is a sf family text. {\Large Large text} {\tiny Tiny text}

\ttfamily
This is a tt family text. {\Large Large text} {\tiny Tiny text}

\end{document}

相关内容