我在表格环境之外有一些文本,在表格环境之内也有一些文本。我希望表格环境之外的文本与表格环境第一行的文本对齐。
目前,表格环境外的文本相对于表格环境内的文本来说太低了。
梅威瑟:
\documentclass{article}
\usepackage[table]{xcolor}
\usepackage{array}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{float}
\usepackage{enumitem}
\usepackage[left=3mm, right=3mm,top=30mm,bottom=5mm,includehead=true,headsep=3pt]{geometry}
\begin{document}
In the context of using the itemize environment...
\begin{itemize}
\item I would like to have the text outside my table \quad \begin{tabular}{| b{26mm} | b{26mm}|} be in line with & the text inside \\ \hline blah blah blah & blah \end{tabular} the table.
\item but the word ``table'' (outside the tabular) is too high relative to the word ``be'' (inside the tabular).
\item Any thoughts?
\end{itemize}
\end{document}
以下是我输出的截图:
答案1
悼念:亨利·桑普曼(Henry Thumpman),单线补丁之王。
\documentclass{article}
\usepackage[table]{xcolor}
\usepackage{array}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{float}
\usepackage{enumitem}
\usepackage[left=3mm, right=3mm,top=30mm,bottom=5mm,includehead=true,headsep=3pt]{geometry}
\begin{document}
In the context of using the itemize environment...
\begin{itemize}
\item I would like to have the text outside my table \quad \begin{tabular}[t]{| b{26mm} | b{26mm}|} be in line with & the text inside \\ \hline blah blah blah & blah \end{tabular} the table.
\item but the word ``table'' (outside the tabular) is too high relative to the word ``be'' (inside the tabular).
\item Any thoughts?
\end{itemize}
\end{document}
答案2
供参考,使用{NiceTabular}
,nicematrix
您可以为表格的垂直对齐提供更多选项。
\documentclass{article}
\usepackage{xcolor}
\usepackage{nicematrix}
\usepackage{geometry}
\begin{document}
\begin{itemize}
\item \verb|[t]|: Aligned with the first row (even with a \verb|\hline| on top)
\begin{NiceTabular}[t]{|c|}
\hline
first row \\
\hline
second row \\
\hline
third row \\
\hline
fourth row \\
\hline
\end{NiceTabular}
\item \verb|[b]|: Aligned with the last row (even with a \verb|\hline| on bottom)
\begin{NiceTabular}[b]{|c|}
\hline
first row \\
\hline
second row \\
\hline
third row \\
\hline
fourth row \\
\hline
\end{NiceTabular}
\item \verb|[baseline=3]|: Aligned with a row given by its number
\begin{NiceTabular}[baseline=3]{|c|}
\hline
first row \\
\hline
second row \\
\hline
third row \\
\hline
fourth row \\
\hline
\end{NiceTabular}
\item \verb|[baseline=line-3]|: Aligned with an horizontal rule given by its number
\begin{NiceTabular}[baseline=line-3]{|c|}
\hline
first row \\
\hline
second row \\
\hline
third row \\
\hline
fourth row \\
\hline
\end{NiceTabular}
\end{itemize}
\end{document}
您需要多次编译(因为nicematrix
在后台使用 PGF/Tikz 节点)。