用数字 PI 数字装饰

用数字 PI 数字装饰

我想为书籍活动创建一个环境。我需要一些背景颜色,我想把 Pi 数字 3.1415926 放在顶部,完成文本宽度(从左到右),偷偷摸摸(如果可能的话)并减小字体大小。在底部,Pi 535 的下一个数字...(三点终止)顶部格式相同,但从右到左(数字反转)。然后的想法是使用它 \begin{piact} 一些事情 \end{piact} 这可能吗?怎么做?谢谢!!!

答案1

能否创建一个边框为数字pi且字体大小不断减小的环境?当然可以。例如,pgfmanual 第 599 页上的示例为和tcolorboxdecorations.text不幸的是,我不明白你想要的下限是多少,但如果你解释一下,我会试一试。我很难理解和的three point termination解释number inverted

\documentclass{article}
\usepackage[most]{tcolorbox}
\usetikzlibrary{math,decorations.text}
\usepackage{lipsum}
\tikzset{tedeco/.style n args={2}{decoration={text effects along path, 
text={#1},text align=center,
text effects/.cd,
    character count=\i, character total=\n,
    characters={text along path, evaluate={\c=\i/\n*100;},
text=orange!\c!blue, scale=-\i/\n+1.5},#2}}}
\newtcolorbox{piact}[1][]{enhanced,
colback=white,
boxrule=0mm,top=5mm,bottom=5mm,left=4mm,right=4mm,sharp corners,
overlay={%
\draw[thick,white] (frame.north west) rectangle (frame.south east);
\path[decorate,tedeco={3.141592653589793238462643383279502884197169399375105820974}{}] 
([xshift=2mm,yshift=-4mm]frame.north west) -- ([xshift=-2mm,yshift=-4mm]frame.north east);
\path[decorate,decoration={reverse path},
tedeco={44592307816406286208998628034825342117067982148086513282306647}{},
text effects={characters/.append={scale=-1}},] 
([xshift=2mm,yshift=1mm]frame.south west) -- ([xshift=-2mm,yshift=1mm]frame.south east);
}}

\begin{document}
\lipsum[1]

\begin{piact}
\lipsum[2]
\end{piact}

\lipsum[3]
\end{document}

在此处输入图片描述

这是将数字沿正弦曲线绘制的版本。正弦函数并不特殊,您可以使用任何函数。

\documentclass{article}
\usepackage[most]{tcolorbox}
\usetikzlibrary{math,decorations.text,calc}
\usepackage{lipsum}
\tikzset{tedeco/.style n args={2}{decoration={text effects along path, 
text={#1},text align=center,
text effects/.cd,
    character count=\i, character total=\n,
    characters={text along path, evaluate={\c=\i/\n*100;},
text=orange!\c!blue, scale=-\i/\n+1.5},#2}},
ini plot/.code={\xdef\xmin{\x1}\xdef\xmax{\x2}}}
\newtcolorbox{piact}[1][]{enhanced,
colback=white,
boxrule=0mm,top=9mm,bottom=9mm,left=4mm,right=4mm,sharp corners,
overlay={%
\draw[thick,white] (frame.north west) rectangle (frame.south east);
\path[decorate,tedeco={3.141592653589793238462643383279502884197169399375105820974\ldots}{}] 
let \p1=($([xshift=2mm,yshift=-4mm]frame.north west)$),
\p2=($([xshift=-2mm,yshift=-4mm]frame.north east)$)
in [ini plot] ([xshift=2mm,yshift=-4mm]frame.north west) 
plot[variable=\x,domain=\x1:\x2] ({\x*1pt},{-3pt+\y1+sin(2*(\x-\xmin)*(360/(\xmax-\xmin)))*8pt});
\path[decorate,decoration={reverse path},
tedeco={44592307816406286208998628034825342117067982148086513282306647\ldots}{},
text effects={characters/.append={scale=-1}}] 
let \p1=($([xshift=2mm,yshift=1mm]frame.south west)$),
\p2=($([xshift=-2mm,yshift=1mm]frame.south east)$)
in [ini plot] ([xshift=2mm,yshift=-4mm]frame.north west) 
plot[variable=\x,domain=\x1:\x2] 
({\x*1pt},{+1pt+\y1+sin(2*(\x-\xmin)*(360/(\xmax-\xmin)))*8pt});
}}

\begin{document}
\lipsum[1]

\begin{piact}
\lipsum[2]
\end{piact}

\lipsum[3]
\end{document}

在此处输入图片描述

如何定制?重要的是

({\x*1pt},{+1pt+\y1+sin(2*(\x-\xmin)*(360/(\xmax-\xmin)))*8pt})  

其中2*表示正弦函数有 2 个最小值和最大值,当然你可以sin用任何函数替换(只要不引起dimension too large errors)。这里,下部函数1pt向上移动,上部函数向下移动。正弦函数的振幅由 给出8pt,你也可以调整它。

相关内容