包含单词和短语条目的表格

包含单词和短语条目的表格

这个问题可能有点傻,看起来很容易,在网上查过后就可以找到答案,但我还是来这里寻求帮助。这个问题看起来是这样的:

我想使用 LaTeX 创建一个表格。表格如下所示:

(LOGINtest.png)

我设法制作了一个表格,但它不是我所设想的那样。它看起来像这样:

(LOGINtest.png)

我使用的代码如下:

\documentclass[a4paper,twocolumn]{article}
\usepackage[margin=1in]{geometry}
\usepackage{multirow,booktabs}
\setlength\parindent{0pt}
\begin{document}

\begin{tabular}{|c|c|c|c|}
\hline
\multirow{2}{*}{USERNAME} & \multirow{2}{*}{PASSWORD} & Did the user denied access to the app when the user inputted wrong username or password? \\

                         &                          &  YES                    & NO \\
                    \hline
[email protected]          & 7221456                  &                         & \\ 
                     \hline
[email protected]    & password                 &                         &  \\
                     \hline
[email protected]           & 12A2ZAQR                 &                         & \\
                     \hline
[email protected]           & password                 &                         & \\
                     \hline

\end{tabular}

\end{document}

我的问题是:

我们如何使用 LaTeX 制作像上面第一张图片那样的表格?

我想知道阅读 LaTeX 的最佳书籍是什么......

答案1

这够了吗?

\documentclass[a4paper,twocolumn]{article}
\usepackage[margin=1in]{geometry}
\usepackage{multirow,booktabs}
\usepackage{amssymb}
\usepackage{array}

\newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}}
\setlength\parindent{0pt}
\begin{document}

    \begin{center}
        \begin{tabular}{@{}*{2}{c}*{2}{C{.5\linewidth}}@{}}
        \toprule
        \multirow{2}{*}{USERNAME} & \multirow{2}{*}{PASSWORD} & \multicolumn{2}{C{\linewidth}}{Did the user denied access to the app when the user inputted wrong username or password?} \\ \cmidrule{3-4}
                                  &                           &    YES     &                                                      NO                                                       \\ \midrule
             [email protected]      &          7221456          & \checkmark &                                                                                                               \\ 
          [email protected]   &         password          & \checkmark &                                                  \checkmark                                                   \\ 
             [email protected]       &         12A2ZAQR          & \checkmark &                                                                                                               \\ 
             [email protected]       &         password          &            &                                                  \checkmark                                                   \\ \bottomrule
    \end{tabular}
    \end{center}

\end{document}

enter image description here


编辑

修改代码以满足需求

\documentclass[a4paper,twocolumn]{article}
\usepackage[margin=1in]{geometry}
\usepackage{multirow}
\usepackage{amssymb}
\usepackage{array}

\newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}}
\setlength\parindent{0pt}
\begin{document}

    \begin{center}
        \begin{tabular}{*{2}{|c}*{2}{|C{.5\linewidth}}|}
            \hline
            \multirow{3}{*}{USERNAME} & \multirow{3}{*}{PASSWORD} & \multicolumn{2}{C{\linewidth}|}{Did the user denied access to the app when the user inputted wrong username or password?} \\ \cline{3-4}
            &                           &    YES     &                                                      NO                                                       \\ \hline
            [email protected]      &          7221456          & \checkmark &                                                                                                               \\ \hline
            [email protected]   &         password          & \checkmark &                                                  \checkmark                                                   \\ \hline
            [email protected]       &         12A2ZAQR          & \checkmark &                                                                                                               \\ \hline
            [email protected]       &         password          &            &                                                  \checkmark                                                   \\ \hline
        \end{tabular}
    \end{center}

\end{document}

enter image description here

相关内容