跨小页面列的水平对齐

跨小页面列的水平对齐

我正在尝试在一个页面上创建多个列,其内容在这些列上水平对齐。我习惯\minipage在一个页面上创建多个列,然后应用命令\vspace{}以水平对齐的方式将每列的内容隔开。由于\vspace{}项目从中心向外隔开,因此需要大量的手动反复试验才能将不同类型的上下文对齐到每列。

我的代码

但即使采用手动反复试验的方法,我似乎也无法做到这一点。第二列最上面的表格和第三列和第四列最上面的文本应该从与第一列中的“1. Point 1”相同的高度开始,但事实并非如此。此外,第一张和第二张表格粘在一起了,尽管\vspace{}它们之间有一个。有没有更自动化的方法来实现正确的对齐?有\minipage适合此目的的工具吗?如果您对此有任何建议,我将不胜感激。

这是我用来获取上述输出的代码:

\documentclass{article}
\usepackage[margin=1.0in]{geometry}

\begin{document}
\begin{minipage}{0.17\textwidth}%
\textbf{Heading 1}
\begin{enumerate}
    \item Point 1 \\
    \vspace{1.3cm}
    \item Point 2 \\
    \vspace{1.3cm}
    \item Point 3
    \vspace{1.3cm}
\end{enumerate}
\end{minipage}%
\begin{minipage}{0.29\textwidth}%
\begin{tabular}{|l | c | c | c |}
    \hline
    &One&Two&Three \\ \hline
    ABCD&$\times$&& \\ \hline
    ABCD&&$\times$& \\ \hline
\end{tabular}
\vspace{12mm}
\begin{tabular}{|l | c | c | c |}
    \hline
    &One&Two&Three \\ \hline
    ABCD&$\times$&& \\ \hline
    ABCD&&$\times$& \\ \hline
\end{tabular}
\vspace{12mm}
\begin{tabular}{|l | c | c | c |}
    \hline
    &One&Two&Three \\ \hline
    ABCD&$\times$&& \\ \hline
    ABCD&&$\times$& \\ \hline
\end{tabular}
\end{minipage}%
\hfill
\begin{minipage}{0.23\textwidth}%
\begin{tabular}{p{\textwidth}}
    This is an example. This line may go all along the end and wrap afterwards to the next as seen here.\\
    \vspace{6mm}
    This is an example. This line may go all along the end and wrap afterwards to the next as seen here.\\
    \vspace{6mm}
    This is an example. This line may go all along the end and wrap afterwards to the next as seen here.\\
\end{tabular}
\end{minipage}%
\hfill
\begin{minipage}{0.23\textwidth}%
\begin{tabular}{p{\textwidth}}
    This is an example. This line may go all along the end and wrap afterwards to the next as seen here.\\
    \vspace{6mm}
    This is an example. This line may go all along the end and wrap afterwards to the next as seen here.\\
    \vspace{6mm}
    This is an example. This line may go all along the end and wrap afterwards to the next as seen here.\\
\end{tabular}
\end{minipage}%
\end{document}

答案1

就像是

在此处输入图片描述

请注意,tex 给出了许多有关坏盒子的警告,在这种情况下不应忽视这些警告。

主要问题是使用[t]来顶部对齐小页面,而从不使用\\它来结束段落,并且表格p{\textwidth}不适合,除非您使用它@{}p{\textwidth}@{}来删除列填充,或者像这里一样直接删除表格,因为单列表格没有多大用处。

如果您想要使第 2 点、每个列中的第二个表格和第二段对齐,最简单的方法就是将它们放在小页面的第二行,而不是先输入第一列的所有内容,然后再输入第二列的所有内容。

\documentclass{article}
\usepackage[margin=1.0in]{geometry}
\usepackage{array}

\begin{document}
\section*{Heading 1}
\begin{minipage}[t]{0.17\textwidth}%

\begin{enumerate}\setlength\itemsep{12pt}
    \item Point 1

    \item Point 2 % never end a paragraph with \\

    \item Point 3

\end{enumerate}
\end{minipage}%
\begin{minipage}[t]{0.31\textwidth}%
\begin{tabular}[t]{|l | c | c | c |}
    \firsthline
    &One&Two&Three \\ \hline
    ABCD&$\times$&& \\ \hline
    ABCD&&$\times$& \\ \hline
\end{tabular}

\vspace{12mm}
\begin{tabular}[t]{|l | c | c | c |}
    \hline
    &One&Two&Three \\ \hline
    ABCD&$\times$&& \\ \hline
    ABCD&&$\times$& \\ \hline
\end{tabular}

\vspace{12mm}
\begin{tabular}[t]{|l | c | c | c |}
    \hline
    &One&Two&Three \\ \hline
    ABCD&$\times$&& \\ \hline
    ABCD&&$\times$& \\ \hline
\end{tabular}
\end{minipage}%
\hfill
\begin{minipage}[t]{0.23\textwidth}%
\setlength\parskip{12pt}
    This is an example. This line may go all along the end and wrap afterwards to the next as seen here.

    This is an example. This line may go all along the end and wrap afterwards to the next as seen here.

    This is an example. This line may go all along the end and wrap afterwards to the next as seen here.
\end{minipage}%
\hfill
\begin{minipage}[t]{0.23\textwidth}%
\setlength\parskip{12pt}

    This is an example. This line may go all along the end and wrap afterwards to the next as seen here.

    This is an example. This line may go all along the end and wrap afterwards to the next as seen here.

    This is an example. This line may go all along the end and wrap afterwards to the next as seen here.
\end{minipage}%
\end{document}

在此处输入图片描述

相关内容