答案1
感谢 campa 的评论(谢谢!),我得出了以下多个版本:
- 高于基线
- 数学对齐
- 以基线为中心
- 水平居中于基线
\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{cd}
\usetikzlibrary{backgrounds,positioning}
\usetikzlibrary{shapes,shapes.geometric,shapes.misc}
\usepackage{graphicx}
\begin{document}
\setlength{\fboxsep}{0pt}
\makeatletter
%% https://tex.stackexchange.com/questions/528774/excess-vertical-space-in-vdots/528775#528775
\DeclareRobustCommand\cvdotsAboveBaseline{%
\vbox{\baselineskip4\p@ \lineskiplimit\z@%
\hbox{.}\hbox{.}\hbox{.}}
}
\makeatother
\DeclareRobustCommand{\cvdotsCenterMathline}{%
% vcenter is used to center the argument on the 'math axis', which is at half the height of an 'x', or about the position of a minus sign.
\vcenter{\cvdotsAboveBaseline}%
}
\DeclareRobustCommand{\cvdotsCenterBaseline}{%
\raisebox{-.5\height}{%
$\cvdotsAboveBaseline$%
}%
}
\DeclareRobustCommand{\chdots}{%
\raisebox{-.5\height}{%
\rotatebox{90}{% Maybe better options than rotatebox...
$\cvdotsAboveBaseline$%
}%
}%
}
\DeclareRobustCommand{\chdotsLdots}{% Has a small space on the right and left, which chdots does not have
\raisebox{\dimexpr\depth-.5\totalheight\relax}{$\ldots$}%
}
\begin{tikzpicture}
\node[fill=red] (A) {A};
\node[fill=blue,below=of A] (B) {B};
\path (A) -- (B) node[midway,anchor=center] {\makebox[0pt][r]{$n$ }$\cvdotsCenterMathline$};
\end{tikzpicture}
% Show baseline then vdots:
Order: Original, above baseline, aligned for math, centered on baseline, horizontal and centered on baseline (2 versions):\\
ABCp\rule{2cm}{0.1pt}\fbox{$\vdots$}\fbox{$\cvdotsAboveBaseline$}\fbox{$\cvdotsCenterMathline$}\fbox{$\cvdotsCenterBaseline$}\fbox{$\chdots$}\fbox{$\chdotsLdots$}
\end{document}