表格与表格外文本的对齐

表格与表格外文本的对齐

在图片中,我想知道是否可以将表格的第一行与单词“密文”对齐,而不是让表格垂直居中?

在此处输入图片描述

\documentclass[12pt,letterpaper]{article}
\usepackage[margin=1in]{geometry}
\usepackage{fancyhdr, float}

\usepackage{amsmath, amssymb, amsthm}
\usepackage{cleveref}
\usepackage{algorithm2e}
\usepackage{enumerate}
\usepackage{graphicx}

\lhead{... \\ ...}
\chead{\textsc{Homework 2}}
\rhead{... \\ ...}

\lfoot{}
\cfoot{}
\rfoot{\thepage}

\renewcommand{\headrulewidth}{0.01em}
\pagestyle{fancy}
\addtolength{\headsep}{1em}
\setlength{\headheight}{28pt}

\newcommand{\vigenere}{Vigen\`{e}re }
\newcommand{\colsp}{@{\hskip 0.2in}}

\newcommand{\comment}[1]{%
  \text{\phantom{(#1)}} \tag{#1}
}

\theoremstyle{definition}
\newtheorem*{answer}{Answer}
\theoremstyle{remark}
\newtheorem{claim}{Claim}
\newtheorem{lemma}{Lemma}

\begin{document}
\thispagestyle{fancy}

\subsection*{Chapter 4}

\begin{enumerate}
\item[\textbf{4.10.}]
    Encrypt each of the following \vigenere plaintexts using the given keyword and the \vigenere tableau (Table 4.1).
    \begin{enumerate}
    \item[(a)]
        Keyword: \texttt{hamlet} \\
        Plaintext: \texttt{To be, or not to be, that is the question.}
    \item[(b)]
        Keyword: \texttt{fortune} \\
        Plaintext: \texttt{The treasure is buried under the big W.}
    \end{enumerate}
\item[\textbf{4.11.}]
    Decrypt each of the following \vigenere ciphertexts using the given keyword and the \vigenere tableau (Table 4.1).
    \begin{enumerate}
    \item[(a)]
        Keyword: \texttt{condiment} \\
        Ciphertext: 
        \begin{tabular}{l \colsp l \colsp l \colsp l \colsp l}
            \texttt{r s g h z} & \texttt{b m c x t} & \texttt{d v f s q} & \texttt{h n i g q} & \texttt{x r n b m} \\
            \texttt{p d n s q} & \texttt{s m b t r} & \texttt{k u}       &                    &
        \end{tabular} 
    \item[(b)]
    \end{enumerate}
\item[\textbf{4.13.}]
\item[\textbf{4.20.}]
\item[\textbf{4.22.}]
\item[\textbf{4.23.}]
\end{enumerate}

\end{document}

答案1

使用\begin{tabular}[t]

在此处输入图片描述

代码:

\documentclass[12pt,letterpaper]{article}
\usepackage[margin=1in]{geometry}
\usepackage{fancyhdr, float}

\usepackage{amsmath, amssymb, amsthm}
\usepackage{cleveref}
\usepackage{algorithm2e}
\usepackage{enumerate}
\usepackage{graphicx}

\lhead{... \\ ...}
\chead{\textsc{Homework 2}}
\rhead{... \\ ...}

\lfoot{}
\cfoot{}
\rfoot{\thepage}

\renewcommand{\headrulewidth}{0.01em}
\pagestyle{fancy}
\addtolength{\headsep}{1em}
\setlength{\headheight}{28pt}

\newcommand{\vigenere}{Vigen\`{e}re }
\newcommand{\colsp}{@{\hskip 0.2in}}

\newcommand{\comment}[1]{%
  \text{\phantom{(#1)}} \tag{#1}
}

\theoremstyle{definition}
\newtheorem*{answer}{Answer}
\theoremstyle{remark}
\newtheorem{claim}{Claim}
\newtheorem{lemma}{Lemma}

\begin{document}
\thispagestyle{fancy}

\subsection*{Chapter 4}

\begin{enumerate}
\item[\textbf{4.10.}]
    Encrypt each of the following \vigenere plaintexts using the given keyword and the \vigenere tableau (Table 4.1).
    \begin{enumerate}
    \item[(a)]
        Keyword: \texttt{hamlet} \\
        Plaintext: \texttt{To be, or not to be, that is the question.}
    \item[(b)]
        Keyword: \texttt{fortune} \\
        Plaintext: \texttt{The treasure is buried under the big W.}
    \end{enumerate}
\item[\textbf{4.11.}]
    Decrypt each of the following \vigenere ciphertexts using the given keyword and the \vigenere tableau (Table 4.1).
    \begin{enumerate}
    \item[(a)]
        Keyword: \texttt{condiment} \\
        Ciphertext: 
        \begin{tabular}[t]{l \colsp l \colsp l \colsp l \colsp l}
            \texttt{r s g h z} & \texttt{b m c x t} & \texttt{d v f s q} & \texttt{h n i g q} & \texttt{x r n b m} \\
            \texttt{p d n s q} & \texttt{s m b t r} & \texttt{k u}       &                    &
        \end{tabular} 
    \item[(b)]
    \end{enumerate}
\item[\textbf{4.13.}]
\item[\textbf{4.20.}]
\item[\textbf{4.22.}]
\item[\textbf{4.23.}]
\end{enumerate}

\end{document}

相关内容