I want to stack vertically like this
t
e
x
t
1
9
I found various answers that works, either using custom commands or stackengine (e.g. Vertical text (not in table)).
None of these answers works when part of the text is a variable, e.g.
\Longstack{t e x t {} \value}
\vvv{text \value}
Is there a way to make these work? E.g. for Longstack, is there a way to "insert space" between characters in \value so that Longstack parses the string properly?
Full example -
\documentclass{article}
\usepackage{xstring}
\usepackage{stackengine}
\makeatletter
\protected\def\vvv#1{\leavevmode\bgroup\vbox\bgroup\xvvv#1\relax}
\def\xvvv{\afterassignment\xxvvv\let\tmp= }
\def\xxvvv{%
\ifx\tmp@sptoken\egroup\ \vbox\bgroup\let\next\xvvv
\else\ifx\tmp\relax\egroup\egroup\let\next\relax
\else
\hbox to 1.1em{\hfill\tmp\hfill}% centred
\let\next\xvvv\fi\fi
\next}
\makeatother
\newcommand{\myvar}{17}
\begin{document}
\Longstack{p a g e {} \myvar{}}
\vvv{page\myvar{}}
\end{document}


\def\value{...}. – egreg Feb 18 '21 at 18:24