我在一个表里面有子表,我希望子表的文本位于行的顶部,就像第二张图那样。
梅威瑟:
\documentclass[12pt,a4paper]{article}
\usepackage[latin1]{inputenc}
\usepackage{tabularx}
\newcommand{\listingsymbol}{\textbullet\thinspace}
\begin{document}
\begin{table}[]
\begin{tabularx}{\textwidth}{|l|p{2.5cm}|p{3cm}|X|}
\hline
item 0 & \begin{tabular}[x]{@{\listingsymbol}l@{}}
item 1\\
item 2\\
\end{tabular}
& \begin{tabular}[x]{@{\listingsymbol}l@{}}
item 1 \\
item 2\\
item 3\\
\end{tabular} &
\begin{tabular}[x]{@{\listingsymbol}p{139pt}@{}}
item 1\\
item 2\\
item 3.1 \newline item 3.2\\
item 4\\
\end{tabular} \\ \hline
\end{tabularx}
\end{table}
\end{document}
答案1
的可选参数tabular
是的“锚点” tabular
。我认为x
它什么也不做,但是t
(op)做了你想要的。
\documentclass[12pt,a4paper]{article}
\usepackage[latin1]{inputenc}
\usepackage{tabularx}
\newcommand{\listingsymbol}{\textbullet\thinspace}
\begin{document}
\begin{table}[]
\begin{tabularx}{\textwidth}{|l|p{2.5cm}|p{3cm}|X|}
\hline
item 0 & \begin{tabular}[t]{@{\listingsymbol}l@{}}
item 1\\
item 2\\
\end{tabular}
& \begin{tabular}[t]{@{\listingsymbol}l@{}}
item 1 \\
item 2 \\
item 3 \\
\end{tabular} &
\begin{tabular}[t]{@{\listingsymbol}p{139pt}@{}}
item 1 \\
item 2 \\
item 3.1 \newline
item 3.2 \\
item 4\\
\end{tabular} \\ \hline
\end{tabularx}
\end{table}
\end{document}