# Vertical “stack” of letters, where every letter is rotated to sit on top of the letter beneath it [duplicate]

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.

• Welcome to tex,sx. – barbara beeton Sep 10 '19 at 19:30
• Welcome Tom! Your question might already have an answer at the link in my comment above. Add a comment if you disagree. – James Sep 10 '19 at 19:51
• I kind of disagree, that question does not say how to put an arbitrary string vertically (other than putting manual linebreaks). There might be another duplicate somewhere though. – Marijn Sep 10 '19 at 21:44
• @Marijn: True, but the OP doesn't say that manual linebreaks are not allowed either. Looks like we're getting some good non-Tikz answers below anyway. – James Sep 10 '19 at 23:11
• See the stackengine package: ctan.org/pkg/stackengine – Steven B. Segletes Sep 11 '19 at 0:50

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}
\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 5:54
• @HenriMenke Yes. This is meant to work for other words, too. The reason why I did that is that by default TikZ would space the characters according to their width, but after adding \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.) – user194703 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}

\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


• Just realized that in the original post it says “Environment”, not “Experiment”. Well... that is an exercise left to the reader. – Henri Menke Sep 11 '19 at 5:55