\boxed text as subscript
You can use \text
from amsmath
, but you need to help it as regards to the baseline.
\documentclass{book}
\usepackage{amsmath}
\usepackage{array}
\usepackage{siunitx}
\sisetup{retain-explicit-plus}
\makeatletter
\newcommand{\boxedarray}[2][c]{%
\begingroup
\let\current@f@size\f@size
\setlength\fboxsep{1pt}%
\text{\fbox{\fix@baseline$\begin{array}[#1]{c}#2\end{array}$}}%
\endgroup
}
\newcommand{\fixbaseline}{%
\ifx\f@size\current@f@size\else\ifx\f@size\sf@size\linespread{0.7}\else\linespread{0.5}\fi\fi
\selectfont
}
\makeatother
\begin{document}
The passenger moving with a velocity of \SI{+11}{m/s}, due in part to the
walking motion and in part to the train's motion. As
$\boxedarray{ PT \\ AT \\ CT }$
the passenger moving with a velocity of \SI{+11}{m/s}, due in part to the
walking motion and in part to the train's motion. As
\[
\vec{\mathbf{V}}_{\boxedarray{ PT \\ AT \\ CT }}
\]
\end{document}
For units, as already suggested, use siunitx
facilities.
I propose a very simple \subboxed
command, which ensures the maths will be in \scriptstyle and the value of \boxsep
is adjusted. In the maintext, I'd simply use a boxed \Vectorstack
from stackengine
.
Unrelated to the problem: I used the extensible vector arrows from esvec
, which look nicer than \vec
with a bold V.
\documentclass{book}
\usepackage{amsmath}
\usepackage{siunitx}
\usepackage[b]{esvect}
\usepackage[usestackEOL]{stackengine}
\newcommand{\subboxed}[1]{{\setlength{\fboxsep}{1pt}\boxed{\everymath{\scriptstyle}#1}}}
\begin{document}
The passenger moving with a velocity of \SI{+11}{\meter/\second}, due in part to the walking
motion and in part to the train's motion. As $\boxed{\Vectorstack{PT \\ AT \\ CT}}$ the passenger moving with a velocity of \SI{+11}{\meter/\second},
due in part to the walking motion and in part to the train's motion. As
\[\vv{\mathbf{V}}_{\subboxed{\substack{PT\\ AT \\ CT}}}
\]
\end{document}
A method with TABstacks:
\documentclass{book}
\usepackage{amsmath,scalerel,tabstackengine}
\TABstackMath
\TABstackMathstyle{\SavedStyle}
\renewcommand{\boxed}[1]{\ThisStyle{\fboxsep1pt\fbox{%
\setstackgap{L}{12\LMpt}\tabbedCenterstack{#1}}}}
\begin{document}
the passenger moving with a velocity of +11 m/s, due in part to the walking
motion and in part to the train's motion. As $\boxed{PT\\AT\\CT}$ the
passenger moving with a velocity of +11 m/s, due in part to the walking
motion and in part to the train's motion. As
\[
\vec{\mathbf{V}}_{\boxed{PT\\AT\\CT}}
\]
\end{document}