字体缩放:局部缩小所有字体大小

字体缩放:局部缩小所有字体大小

我的文档末尾有一个部分,其中包含各种元素,这些元素不会对该\small部分前面的书写做出简单的反应(例如\printbibliography,但也有一些自定义命令)。

现在我想用较小的字体打印此部分。我尝试将元素包装到中\scalebox,但这不会保留线宽。

scalefnt或包等解决方案relsize失败,因为明确使用字体命令的元素仍然不会受到影响。

理想情况下,我正在寻找一个环境,它将 等重新定义\normalsizesmall与当前值成比例的新值。如果这也会改变默认定义,那么对于我的目的来说,这是可以接受的。

作为一个最小的工作示例:

\documentclass[10pt]{scrartcl}
\usepackage{lipsum}
\usepackage{graphicx}
\usepackage[scale=0.9]{geometry}
\newcommand{\somecommand}{\LARGE THIS IS LARGE \small this is small \normalsize\lipsum[1]}
\begin{document}

\section*{This should be typeset in document default sizes}

\somecommand 

\section*{This should be typeset in a smaller font without requiring knowledge of the internals of \texttt{\string\somecommand}}

%% what should be put here?
\somecommand

\section*{Scalebox doesn't cut it, if only because it introduces a box.}

\scalebox{0.5}{\somecommand}

\section*{If I could get this to fill the linewidth it would suffice as a temporary solution.}

\scalebox{0.5}{\parbox{\linewidth}{\somecommand}}

\end{document}

编译形式

答案1

在此处输入图片描述

\RequirePackage{fix-cm}
\documentclass[10pt]{scrartcl}
\usepackage{lipsum}

\usepackage[scale=0.9]{geometry}
\newcommand{\somecommand}{\LARGE THIS IS LARGE \small this is small \normalsize\lipsum[1]}

\makeatletter
\let\zzfontsize\fontsize
\def\zz#1#2{{%
\def\fontsize##1##2{%
\@defaultunits\@tempdima##1pt\relax\@nnil
\@defaultunits\@tempdimb##1pt\relax\@nnil
\zzfontsize{#1\@tempdima}{#1\@tempdimb}}#2}}
\makeatother

\begin{document}


\section*{This should be typeset in document default sizes}

\somecommand 

\section*{This should be typeset in a smaller font without requiring knowledge of the internals of \texttt{\string\somecommand}}

%% what should be put here?
\zz{0.3}{\somecommand}

\section*{Scalebox doesn't cut it, if only because it introduces a box.}

\zz{0.5}{\somecommand}

\section*{If I could get this to fill the linewidth it would suffice as a temporary solution.}

\zz{2}{\somecommand}

\end{document}

相关内容