\shortstack 和表格中的垂直对齐?

\shortstack 和表格中的垂直对齐?
\documentclass{report}
\usepackage{lipsum}
\begin{document}
\begin{tabular}{cp{4cm}}
\hline
\shortstack{A\\B\\C\\D} & \lipsum[1] \\
\hline
\end{tabular}
\end{document}

结果是 :

------------------------------------
A
B
C
D    Lorem ipsum dolor sit amet,
     consectetuer adipiscing elit.
     Ut purus elit, vestibulum
     ut, placerat ac, adipiscing
     vitae, felis. Curabitur
     dictum gravida mauris. Nam
------------------------------------

虽然我想实现:

------------------------------------
A    Lorem ipsum dolor sit amet,
B    consectetuer adipiscing elit.
C    Ut purus elit, vestibulum
D    ut, placerat ac, adipiscing
     vitae, felis. Curabitur
     dictum gravida mauris. Nam
------------------------------------

如何使用来实现这一点\shortstack

PS我找到了解决方案\matrix \ShortStack 对齐- 我很好奇这是否可以做\shortstack

答案1

重要的是削减“子堆栈”的深度

\documentclass{report}
\usepackage{amsmath} % for \smash[b]{...}
\usepackage{lipsum}

\newcommand{\blap}[1]{\smash[b]{\begin{tabular}[t]{@{}c@{}}#1\end{tabular}}}

\begin{document}

\begin{tabular}{cp{4cm}}
\hline
\blap{A\\B\\C\\D}
& \lipsum[1] \\
\hline
\end{tabular}

\end{document}

在下面的图片中,左边是我的代码的结果,右边是另一个建议的代码

在此处输入图片描述

\documentclass{article}

\usepackage{amsmath}

\newcommand{\blap}[1]{%
  \smash[b]{\begin{tabular}[t]{@{}c@{}}#1\end{tabular}}}

\begin{document}

\begin{tabular}{cp{4cm}}
\hline
\blap{A\\B\\C\\D}
&
some text to fill four lines
some text to fill four lines
some text to fill four lines
some text to fill four lines
some text to fill four lines
\\
\hline
\end{tabular}\qquad
\begin{tabular}{cp{4cm}}
\hline
\vbox to 0pt{\hbox{
\shortstack{A\\B\\C\\D}
}\vss}
&
some text to fill four lines
some text to fill four lines
some text to fill four lines
some text to fill four lines
some text to fill four lines
\\
\hline
\end{tabular}

\end{document}

答案2

我在这里找到了解决方案:https://tex.stackexchange.com/a/23848/7128

所以我想分享一下。

我采用了宏:

\newcommand{\blap}[1]{\vbox to 0pt{\hbox{#1}\vss}}

以下是完整的工作示例:

\documentclass{report}
\usepackage{lipsum}
\begin{document}
\begin{tabular}{cp{4cm}}
\hline
\vbox to 0pt{\hbox{
\shortstack{A\\B\\C\\D} 
}\vss}
& \lipsum[1] \\
\hline
\end{tabular}
\end{document}

相关内容