![将表格外部的文本与表格内部的文本对齐](https://linux22.com/image/439800/%E5%B0%86%E8%A1%A8%E6%A0%BC%E5%A4%96%E9%83%A8%E7%9A%84%E6%96%87%E6%9C%AC%E4%B8%8E%E8%A1%A8%E6%A0%BC%E5%86%85%E9%83%A8%E7%9A%84%E6%96%87%E6%9C%AC%E5%AF%B9%E9%BD%90.png)
我在表格环境之外有一些文本,在表格环境之内也有一些文本。我希望表格环境之外的文本与表格环境第一行的文本对齐。
目前,表格环境外的文本相对于表格环境内的文本来说太低了。
梅威瑟:
\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 节点)。