2

I would like to make an environment for the activities of book. I need some background color, and I thought to put on top the Pi digits 3.1415926 completing the textwidth (from left to right), sneaky (if posible) and decreasing fontsize. On bottom the next digits of Pi 535...(three point termination) the same format on top but froma right to left (number inverted). The idea is then to use it \begin{piact} some things \end{piact} This is posible? How? Thank!!!

  • 1
    Could you please be a bit more specific. What kind of "environment" do you think of? Is is a box or what is it? –  Sep 25 '18 at 04:03

1 Answers1

4

Can one make an environment with a border being the digits of pi and the font size is decreasing? Definitely. For instance with tcolorbox and a decorations.text example on p. 599 of the pgfmanual. Unfortunately, I do not understand what you want to have for the lower boundary, but if you explain this I will give it a shot. I struggle with the interpretation of three point termination and 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}

enter image description here

Here is a version in which the numbers are drawn along a sine curve. The sine function is not special, you may use any function.

\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}

enter image description here

How can one customize that? The important part is

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

where 2* means that there will be 2 minima and maxima of the sine, and of course you can replace sin by whatever function (as long as you do not cause dimension too large errors). Here, the lower function is shifted 1pt up and the upper function is shifted down. And the amplitude of the sine is given by 8pt, which you could also adjust.