![如何将文本与表格单元格的顶部对齐?](https://linux22.com/image/442526/%E5%A6%82%E4%BD%95%E5%B0%86%E6%96%87%E6%9C%AC%E4%B8%8E%E8%A1%A8%E6%A0%BC%E5%8D%95%E5%85%83%E6%A0%BC%E7%9A%84%E9%A1%B6%E9%83%A8%E5%AF%B9%E9%BD%90%EF%BC%9F.png)
到目前为止
\documentclass{article}
\usepackage{tabularx}
\usepackage{enumitem}
\setlist{topsep=0em,nosep}
\begin{document}
\section{test}
\begin{tabularx}{\linewidth}{r|X}
test text 1 & \begin{minipage}{\linewidth}
test text 2
\begin{itemize}
\item test item 1
\item test item 2
\end{itemize}
\end{minipage}
\end{tabularx}
\end{document}
但是,我希望“测试文本 1”与“测试文本 2”内联。我该如何实现?
答案1
实现这种对齐的最简单方法是设置锚minipage
操作处的要点[t]
:
\documentclass{article}
\usepackage{tabularx}
\usepackage{enumitem}
\setlist{topsep=0em,nosep}
\begin{document}
\section{test}
\begin{tabularx}{\linewidth}{r|X}
test text 1 & \begin{minipage}[t]{\linewidth}
test text 2
\begin{itemize}
\item test item 1
\item test item 2
\end{itemize}
\end{minipage}
\end{tabularx}
\end{document}