带有表格的迷你页面忽略垂直对齐

带有表格的迷你页面忽略垂直对齐

我正在尝试对齐minipage包含列表的 。使用tabular列表的环境会导致 minipage 忽略该[t]选项(或任何其他选项,据我所知)。另一方面,使用description环境会产生正确的结果,但我不喜欢它如何对齐item[]具有不同长度的 s,因此更喜欢使用表格。

梅威瑟:

\documentclass{article}
\begin{document}
    \textbf{One set of notes.}
    \begin{minipage}[t]{0.5\linewidth}
        \begin{tabular}{@{}r@{ }l@{}}
            Note 1: & This is the first note \\
            Note 2: & This is the second note \\
            Note 3: & This is the third note \\
            Note 4: & This is the fourth note \\
        \end{tabular}
    \end{minipage}

    \textbf{Another set of notes.}
    \begin{minipage}[t]{0.5\linewidth}
        \begin{description}
            \item[Note 1:] This is the first note \\
            \item[Note 2:] This is the second note \\
            \item[Note 3:] This is the third note \\
            \item[Note 4:] This is the fourth note \\
        \end{description}
    \end{minipage}
\end{document}

结果显示在底部的图像中。

有没有办法在tabulara 内部使用minipage承认垂直对齐?

忽略对齐选项

答案1

操作[t]对齐将minipage其内容与内部锚点的顶部对齐minipage。由于minipage内部在中间有一个锚点 - 由tabular块提供,minipage因此“顶部”位于块的(垂直)中间。

为了避免这种情况,请将锚点也指定tabular为op:[t]

在此处输入图片描述

\documentclass{article}
\begin{document}
\textbf{One set of notes.}
\begin{minipage}[t]{0.5\linewidth}
  \begin{tabular}[t]{@{}r@{ }l@{}}
    Note 1: & This is the first note \\
    Note 2: & This is the second note \\
    Note 3: & This is the third note \\
    Note 4: & This is the fourth note \\
  \end{tabular}
\end{minipage}

\textbf{Another set of notes.}
\begin{minipage}[t]{0.5\linewidth}
  \begin{description}
    \item[Note 1:] This is the first note \\
    \item[Note 2:] This is the second note \\
    \item[Note 3:] This is the third note \\
    \item[Note 4:] This is the fourth note \\
  \end{description}
\end{minipage}
\end{document}

由于minipage/\parbox框中基线设置的已知问题,你最好将整个组合设置minipagetabular嵌套中tabular

\begin{tabular}[t]{@{}p{0.5\linewidth}@{}}
  \begin{tabularx}{\linewidth}[t]{@{}r@{ }X@{}}
    Note 1: & This is the first note \\
    Note 2: & This is the second note \\
    Note 3: & This is the third note \\
    Note 4: & This is the fourth note \\
  \end{tabularx}
\end{tabular}

我插入了一个tabularxinner 允许固定宽度的0.5\linewidth结构。

相关内容