![双列文档中两个相邻小页面的垂直对齐(使用 paracol 创建)](https://linux22.com/image/474635/%E5%8F%8C%E5%88%97%E6%96%87%E6%A1%A3%E4%B8%AD%E4%B8%A4%E4%B8%AA%E7%9B%B8%E9%82%BB%E5%B0%8F%E9%A1%B5%E9%9D%A2%E7%9A%84%E5%9E%82%E7%9B%B4%E5%AF%B9%E9%BD%90%EF%BC%88%E4%BD%BF%E7%94%A8%20paracol%20%E5%88%9B%E5%BB%BA%EF%BC%89.png)
我有以下 MWE:
\documentclass{article}
\usepackage[a4paper,margin=1mm]{geometry}
\usepackage{paracol}
\usepackage{lipsum}
\usepackage{tabularray}
\begin{document}
\columnratio{0.4}
\begin{paracol}{2}
\lipsum[1]
\switchcolumn
\noindent
\begin{minipage}[t]{0.6\columnwidth}
{\fontsize{30}{36}\selectfont Huge Header\par}
{\Huge Huge Sub-Header\par}
\end{minipage}
\begin{minipage}[t]{0.4\columnwidth}
\begin{tabular}{|r|l|}
First & Second\\
First & Second\\
First & Second\\
First & Second\\
First & Second\\
First & Second\\
\end{tabular}
\end{minipage}
\\ \lipsum[1]
\end{paracol}
\end{document}
答案1
[t] 选项对齐第一行基线,而 tabular 的默认选项是 [c],即居中对齐。因此,第一个小页面的第一行基线与 tabular 的中心对齐。
这用于\raisebox
移动基线以与第一列的第一行对齐。请注意,这\ht\strutbox
取决于字体大小。 \topskip
会将其移动得太高。
\documentclass{article}
\usepackage[a4paper,margin=1mm]{geometry}
\usepackage{paracol}
\usepackage{lipsum}
\usepackage{tabularray}
\begin{document}
\columnratio{0.4}
\begin{paracol}{2}
\lipsum[1]
\switchcolumn
\noindent
\raisebox{\dimexpr \ht\strutbox-\height}{%
\begin{minipage}[t]{0.6\columnwidth}
{\fontsize{30}{36}\selectfont Huge Header\par}
{\Huge Huge Sub-Header\par}
\end{minipage}}%
\raisebox{\dimexpr \ht\strutbox-\height}{%
\begin{minipage}[t]{0.4\columnwidth}
\begin{tabular}{|r|l|}
First & Second\\
First & Second\\
First & Second\\
First & Second\\
First & Second\\
First & Second\\
\end{tabular}
\end{minipage}}\llap{\rule{\textwidth}{0.5pt}}% show baseline
\\ \lipsum[1]
\end{paracol}
\end{document}
答案2
这很棘手,因为小页面中的对齐方式[t]
将左列第一行的基线与右侧表格的中心对齐。您希望顶部对齐,为此,您需要为右侧表格也提供定位[t]
,和你必须\vspace{0pt}
从两侧顶部潜入。
\begin{minipage}[t]{0.6\columnwidth}
\vspace{0pt}
{\fontsize{30}{36}\selectfont Huge Header\par}
{\Huge Huge Sub-Header\par}
\end{minipage}
\begin{minipage}[t]{0.4\columnwidth}
\begin{tabular}[t]{|r|l|}
\noalign{\vspace{0pt}}
First & Second\\
First & Second\\
First & Second\\
First & Second\\
First & Second\\
First & Second\\
\end{tabular}
\end{minipage}