我怎样才能逐步缩放字母?

我怎样才能逐步缩放字母?

我怎样才能重现下面的图?

替代文本

该图来自 Knuth 的一篇旧论文,你可以从这里获取 http://www.math.lsa.umich.edu/~millerpd/docs/501_Winter08/Knuth79.pdf(第 364 页)

答案1

http://www.tug.org/texshowcase/,搜索“diminuendo.tex”

答案2

使用 LaTeX 代替纯 TeX:

\documentclass[landscape]{article}
\usepackage[T1]{fontenc}
\usepackage[a4paper]{geometry}
\usepackage{lmodern}
\usepackage{graphicx}
\usepackage{fp}

\newcommand*\PIfrac{141592653589793238462643383279502884197169399375105820974!!}

\pagestyle{empty}
\makeatletter
\newcount\cntm \cntm=1
\def\printNum#1{\expandafter\printNum@i#1\@nil}
\def\printNum@i#1#2#3\@nil{%
  \FPdiv{\Scale}{1}{\the\cntm}%
  \typeout{==:\Scale}%
  \scalebox{\Scale}{#1}\ifnum\the\cntm=1 \kern-10pt\fi%
  \advance\cntm by \@ne%
  \ifx#2!\else\expandafter\printNum@i#2#3\@nil\fi}
\makeatother
\begin{document}

\fontsize{6cm}{5.2cm}\selectfont
\scalebox{1.5}{3\kern-15pt,}\kern-20pt\printNum{\PIfrac}

\end{document}

替代文本

答案3

此代码遍历字符串中的每个标记并根据用户定义的函数对其进行缩放:

\documentclass{minimal}

\usepackage{graphicx} % For \scalebox
\usepackage{pgf}      % For arithmetic calculations

% Here are the macros to parse the string character-by-character:
\newcounter{numcharacters}
\def\decreasing#1{\setcounter{numcharacters}{0}\decreasinginternal{#1}}
\def\decreasinginternal#1{\ifx#1\relax\else\decreasingchar#1\enddecreasing\fi}
\def\decreasingchar#1#2\enddecreasing{\addtocounter{numcharacters}{1}\scaleString{#1}{\thenumcharacters}\decreasinginternal{#2}}

% This macro will be called on each character of the string:
\def\scaleString#1#2{\pgfmathparse{6/(#2+2)}\scalebox{\pgfmathresult}{#1}}

\begin{document}
  \decreasing{3.1415926535897932384626}%
\end{document}

以下是将 token i 缩放至 6/(i+2) 的结果: 3.1415926535897932384626

答案4

基于 eTeX 的解决方案

\newcount\currentStep
\currentStep = 1

% Do not increment step at 2nd iteration
\def\updateStep
  {\ifnum\currentStep = 2 
     \def\updateStep{\increment\currentStep}%
    \else \increment\currentStep
   \fi}

\def\Show#1%
  {\dontleavehmode\scale[width=\the\dimexpr\bodyfontsize/\currentStep\relax]{\hbox{#1}}%
   \updateStep}

\setupbodyfont[72pt]
\starttext
\startTEXpage
\handletokens 3{\kern-0,2em.\kern-0.1em}1415926535897932384626 \with\Show
\stopTEXpage
\stoptext

替代文本

相关内容