I'm looking for a simple method in tikz, where I can rotate text so that each letter in the text "sits" or is "stacked" on top of the successor letter. For example, the word "Environment" would appear as:
E
n
v
i
r
o
n
m
e
n
t
Thank you.
I'm looking for a simple method in tikz, where I can rotate text so that each letter in the text "sits" or is "stacked" on top of the successor letter. For example, the word "Environment" would appear as:
E
n
v
i
r
o
n
m
e
n
t
Thank you.
Usually I start answers with "If you do not mind loading TikZ, you could ..." but here one may say: If you do not mind not using TikZ you could use soul instead.
\documentclass{article}
\usepackage{soul}
\makeatletter
\def\SOUL@soeverytoken{%
{\the\SOUL@token}\par\noindent}
\makeatother
\begin{document}
\noindent\so{Environment}
\end{document}
This answer is inspired by this answer. If someone wants to downvote me (again) for quoting others, go ahead.
The TikZ library decorations.text offers advanced options such as
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.text}
\begin{document}
\begin{tikzpicture}[decoration={text effects along path,
text={Environment},
text effects/.cd,
path from text angle=-90,
path from text,
characters={text along path},
character widths={inner xsep=1pt},
style characters=mw with {blue,inner xsep=0.4pt},
style characters=bdfhjklt with {red,inner xsep=1.5pt},
style characters=i with {orange,inner xsep=2.2pt},
style characters=gpqy with {inner xsep=1.2pt}}]
\path [ decorate,
text effects={characters/.append={/utils/exec=\pgftransformresetnontranslations}}] (1,0); \end{tikzpicture}
\end{document}
Here \pgftransformresetnontranslations is used to "unrotated" the characters.
And since there seems to be a desire to employ as little packages as possible: you don't need any.
\documentclass{article}
\def\endpft{Yekitiyekitipeng}%<- something crazy
\def\rst{}
\def\pft#1#2\endpft{\ifx#2\endpft%
\else%
#1\\%
\def\rst{#2}
\pft#2\endpft%
\fi}
\newcommand{\vtext}[2][]{\begingroup\renewcommand{\arraystretch}{0.63}%
\begin{tabular}[#1]{@{}c@{}}%
\,\pft#2\endpft\rst%
\end{tabular}\endgroup}
\begin{document}
\vtext{Environment}
\end{document}
Whether or not it is worthwhile to have as little packages as possible is a different question. IMHO this is only the case if you get the same result with less packages. On the other hand, TikZ allows you to easily typeset the text along a curve, something that is hard to achieve without packages.
style characters=gpqy as far as I can see, none of these are actually part of the word “Environment”.
– Henri Menke
Sep 11 '19 at 05:54
\pgftransformresetnontranslations the relevant dimension is the height. So these style characters also serve the purpose of "fixing" the spacing. (There are alternative ways such as rotate but as far as I can see none of them will work for arbitrary curves in the way \pgftransformresetnontranslations does.)
–
Sep 11 '19 at 15:05
No TikZ, sorry.
\documentclass{article}
\usepackage{xparse}
\ExplSyntaxOn
\NewDocumentCommand{\stack}{O{c}m}
{
\begin{tabular}[#1]{@{}c@{}}
\tl_map_function:nN { #2 } \__tom_stack:n
\end{tabular}
}
\cs_new_protected:Nn \__tom_stack:n { #1 \\ }
\ExplSyntaxOff
\begin{document}
x\stack{Environment}\qquad x\stack[t]{Environment}\qquad x\stack[b]{Environment}
\end{document}
We simply map the argument to populate a tabular. The optional argument sets the reference point just like for tabular (the x in the examples shows the reference point).
With MetaFun
\startMPpage
string s ;
s := "Experiment" ;
for i = 1 upto length s:
label(substring (i - 1, i) of s, (0,-i*.5cm)) ;
endfor ;
\stopMPpage
stackenginepackage: https://ctan.org/pkg/stackengine – Steven B. Segletes Sep 11 '19 at 00:50