对齐两个单独的制表符

对齐两个单独的制表符

我有多个连续的表格,每个表格分为两列。我希望左列居中,第一列宽度相同,列之间的分隔线位于相同的水平位置,最后一列宽度为 3.5 倍并左对齐。

举一个粗略的例子:

                                  Centered Header 1
       The text           Now I have the first description of a longish sentence.
    here Centered         And the second description.
         Text             Finally there is the third.

                                  Centered Header 2
Divided about the same    Remember, this is an example
         Area             So it would be in actual LaTeX typeset... Please see below.

相反,当运行以下代码时,我得到:

...
\vspace{\notationgap}
\begin{minipage}{\textwidth}
\centerline{\bf Sets and Graphs}
\bgroup
\def\arraystretch{1.5}
\begin{tabular}{cp{3.25in}}
$\displaystyle \sA$ & A set\\
$\displaystyle \R$ & The set of real numbers \\
% NOTE: do not use \R^+, because it is ambiguous whether:
% - It includes 0
% - It includes only real numbers, or also infinity.
% We usually do not include infinity, so we may explicitly write
% [0, \infty) to include 0
% (0, \infty) to not include 0
$\displaystyle \{0, 1\}$ & The set containing 0 and 1 \\
$\displaystyle \{0, 1, \dots, n \}$ & The set of all integers between $0$ and $n$\\
$\displaystyle [a, b]$ & The real interval including $a$ and $b$\\
$\displaystyle (a, b]$ & The real interval excluding $a$ but including $b$\\
$\displaystyle \sA \backslash \sB$ & Set subtraction, i.e., the set containing the elements of $\sA$ that are not in $\sB$\\
$\displaystyle \gG$ & A graph\\
$\displaystyle \parents_\gG(\ervx_i)$ & The parents of $\ervx_i$ in $\gG$
\end{tabular}
\egroup
\index{Scalar}
\index{Vector}
\index{Matrix}
\index{Tensor}
\index{Graph}
\index{Set}
\end{minipage}

\vspace{\notationgap}
\begin{minipage}{\textwidth}
\centerline{\bf Indexing}
\bgroup
\def\arraystretch{1.5}
\begin{tabular}{cp{3.25in}}
$\displaystyle \eva_i$ & Element $i$ of vector $\va$, with indexing starting at 1 \\
$\displaystyle \eva_{-i}$ & All elements of vector $\va$ except for element $i$ \\
$\displaystyle \emA_{i,j}$ & Element $i, j$ of matrix $\mA$ \\
$\displaystyle \mA_{i, :}$ & Row $i$ of matrix $\mA$ \\
$\displaystyle \mA_{:, i}$ & Column $i$ of matrix $\mA$ \\
$\displaystyle \etA_{i, j, k}$ & Element $(i, j, k)$ of a 3-D tensor $\tA$\\
$\displaystyle \tA_{:, :, i}$ & 2-D slice of a 3-D tensor\\
$\displaystyle \erva_i$ & Element $i$ of the random vector $\rva$ \\
\end{tabular}
\egroup
\end{minipage}

...

在此处输入图片描述

答案1

arrayw{c}{1in}包提供了具有固定宽度(第二个参数)和居中对齐(第一个参数)的列类型。最小示例:

\documentclass{article}
\usepackage{amsmath}
\usepackage{array}
\renewcommand{\arraystretch}{1.5}
\begin{document}
\centerline{\bfseries Sets and Graphs}
\begin{tabular}{w{c}{0.7in}p{3.25in}}
$\displaystyle A$ & A set\\
$\displaystyle R$ & The set of real numbers \\
$\displaystyle \{0, 1\}$ & The set containing 0 and 1 \\
$\displaystyle \{0, 1, \dots, n \}$ & The set of all integers between $0$ and $n$\\
$\displaystyle [a, b]$ & The real interval including $a$ and $b$ \\
\end{tabular}

\vspace{1cm}
\centerline{\bfseries Indexing}
\begin{tabular}{w{c}{0.7in}p{3.25in}}
$\displaystyle a_i$ & Element $i$ of vector $a$, with indexing starting at 1 \\
$\displaystyle a_{-i}$ & All elements of vector $a$ except for element $i$ \\
$\displaystyle A_{i,j}$ & Element $i, j$ of matrix $A$ \\
\end{tabular}
\end{document}

在此处输入图片描述

相关内容