\boxed 文本作为下标

\boxed 文本作为下标

我们已经将\boxed内容设置为下标,

在此处输入图片描述

但下标大小没有更新,请建议如何使用\boxed定义设置脚本大小。

请查找 MWE 文件:

\documentclass{book}
\usepackage{amsmath}


\makeatletter
\renewcommand{\boxed}[1]{\fboxsep1pt\arraycolsep1pt\fbox{\m@th$#1$}}
\makeatother

\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{\begin{array}{c}
{PT}\\
{AT}\\
{CT}\\
\end{array}}$ 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{\begin{array}{c}
{PT}\\
{AT}\\
{CT}\\
\end{array}}}$$

\end{document}

答案1

使用 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}

在此处输入图片描述

答案2

您可以使用\textamsmath但您需要根据基线来帮助它。

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

对于单位,正如已经建议的那样,使用siunitx设施。

在此处输入图片描述

答案3

我建议使用一个非常简单的\subboxed命令,以确保数学运算符合 \scriptstyle 格式,并且 的值\boxsep已调整。在正文中,我只需使用带框\Vectorstack的即可stackengine

与问题无关:我使用了可扩展的矢量箭头esvec,它看起来比\vec粗体 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} 

在此处输入图片描述

答案4

这可能太天真了,但你不需要任何复杂的\makeatletter东西来装箱数组。

\documentclass{book}
\usepackage{amsmath}
\usepackage{siunitx}

\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  $\begin{array}{|@{\,}c@{\,}|}
\hline
{PT}\\
{AT}\\
{CT}\\
\hline
\end{array}$ 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
\[\vec{\mathbf{V}}_{\begin{array}{|@{\,}c@{\,}|}
\hline
{PT}\\
{AT}\\
{CT}\\
\hline
\end{array}}\]

\end{document}

在此处输入图片描述

当然,问题是读者是否想要这样的盒子。(至少我添加siunitx并替换了$$ ... $$\[ ... \]所以这可能不是完全没有意义的。)

相关内容